Attempting to Attach to Two Servo Controllers Simultaneously

Topics: Developer Forum
Coordinator
Sep 24, 2006 at 10:34 PM
Hello,

I am in the midst of writing an application to operate a sensor head equipped with two servoes providing two axes of motion. I have two individual servo controllers with separate USB connections (PhidgetServo 1-Motor) and I am having difficulty getting both .NET servo objects to correctly associate with the servo controllers. I use the open() method on each servo object (see sample code below) passing it the serial number of the servo controller as returned from the PhidgetManager sample application. The servo_Attach method is called for the first servo (serial number: 14453), but not the second servo (serial number: 14656). I have also tried using the open() method without the serial number, but this produced this same results.

Any thoughts or advice would be most appreciated. An excerpt of my code is enclosed below:

Thanks,

James Y. Wilson
Embedded MVP

namespace PanTilt
{
public partial class Form1 : Form
{
public const int POSITION_MIDDLE = 128;

private Phidgets.Servo _servoHorizontal;
private Phidgets.Servo _servoVertical;

public Form1()
{
InitializeComponent();
}

void servo_Detach(object sender, DetachEventArgs e)
{
}

void servo_Attach(object sender, AttachEventArgs e)
{
if (InvokeRequired)
{
Invoke(new AttachEventHandler(servo_Attach),
new object[] { sender, e });
}
else
{
CenterServoes();
}
}

private void Form1_Load(object sender, EventArgs e)
{
_servoHorizontal = new Phidgets.Servo();
_servoVertical = new Phidgets.Servo();

servoHorizontal.Detach += new DetachEventHandler(servoDetach);
servoHorizontal.Attach += new AttachEventHandler(servoAttach);
_servoHorizontal.open(14453);

servoVertical.Detach += new DetachEventHandler(servoDetach);
servoVertical.Attach += new AttachEventHandler(servoAttach);
_servoVertical.open(14656);
}

private void CenterServoes()
{
// If the servo is present, then move it to the middle of its range.
if (_servoHorizontal.Attached)
{
servoHorizontal.servos0.Position = POSITIONMIDDLE;
}

if (_servoVertical.Attached)
{
servoVertical.servos0.Position = POSITIONMIDDLE;
}
}
}
}
Coordinator
Sep 29, 2006 at 4:53 PM
This is a bug. We have it fixed, but finishing the new functionality in Phidget21 will take several more days.

Chester
Coordinator
Oct 4, 2006 at 3:03 PM
Okay, I look forward to the fix when it is available. I will keep my eye out for the new release.

If there is anything I can do to help let me know.

Jim
Coordinator
Nov 3, 2006 at 9:37 PM
We've posted a new release that fixes (among many other things) this bug.

Chester