I am working on a project that utilizes the NXTServo from Mindsensors. The project is an arm that uses 9 servos (two are in a Y-harness to accomodate for NXTServo's 8 ports). Anyways, I have the program working with regular servos, but i am having trouble when I try to use continuous rotation servos. I understand that when I give a command to move the servo to a certain position, the servo will continue to rotate as there is no feedback mechanism in place. However, I have no idea how to stop this rotation. My code always gets stuck waiting for that servo's feedback, which it will never get. So... how would I go about setting it up so that it "breaks" the command for the servo to go to a position, or maybe only makes it last for a certain amount of time?
Just to make things a little clearer, I am using NXC along with the standard libraries for NXTServo and PSP-Nx that I got from the Mindsensors website. I have tried variations of the following, basically putting the "if button is pressed, set position to x" statement in a while loop so that it only executes while the button is pressed, but this doesn't fix it.
Code: Select all
// Pos_Servo2 is the value for the position of servo #2, if it wasn't clear :P
while (currState.square == 1) {
if (currState.square == 1) {
Pos_Servo2 += 10;
NXTServo_SetPosition(S1, ServoAddr, 2, Pos_Servo2);
}
else {
Pos_Servo2 = 1500;
NXTServo_SetPosition(S1, ServoAddr, 2, Pos_Servo2);
}
}
Thanks!