What is the recommended code (ideally in C#) for stopping the movement of a continuous rotation servo from a 3rd party manufacturer using the new EZ-B v4 controller?
Here's the code I have that's already working to spin a servo in one direction, then the opposite direction, and then stop: (The code for stopping the servo is a real kludge; seems like there should be something better.)
BodyConnection.EZB.Servo.SetServoPosition(Servo.ServoPortEnum.D16, Servo.SERVO_MAX); Thread.Sleep(1000); BodyConnection.EZB.Servo.SetServoPosition(Servo.ServoPortEnum.D16, Servo.SERVO_MIN); Thread.Sleep(1000); BodyConnection.EZB.Servo.SetServoPosition(Servo.ServoPortEnum.D16, 108); Thread.Sleep(100); BodyConnection.EZB.Servo.ReleaseServo(Servo.ServoPortEnum.D16);
Although this code works, it's a real kludge to use 108 to stop the servo. (That's just the magic number I found through trial and error that has the effect of stopping the servo.) Servo.SERVO_OFF doesn't work, because it's set to 1, not 108. It just spins the servo at a pretty fast speed in the same direction as Servo.SERVO_MIN. Servo.SERVO_CENTER also doesn't work, because it's set to 90 and spins the servo, albeit a little slower.
Is there a cleaner approach to stopping a continuous rotation servo? Something better than the code I have above?
Thanks.Skip to comments