I am having a problem with the JoystickDigitalToMotorAndLimit function.
It appears to me that the forward and reverse limit switches are flipped in the function block.
I am using this function to control the arm on a protobot.
I used the online code to confirm that positive values raise the arm and negative values lower the arm.
I also used the online code to confirm that my lower (forward) limit switch is plugged into digital port 6 and my upper (reverse) limit switch is plugged into digital port 7.
I can make it work by flipping the port numbers in the function block. That makes me think that there may be a bug in EasyC. Please check it out and if there is not a bug, please explain what I’m doing wrong.
Joystick #: 1
Channel #: 6
Forward Direction: ← for me, lower the arm
Button #: 1 ← down button
Motor Value: -127
Limit Switch: 6 ← I have to make this 7 to make it work
Reverse Direction: ← for me, raise the arm
Button #: 2 ← up button
Motor Value: 127
Limit Switch: 7 ← I have to make this 6 to make it work
Thanks!
Do you have the motor geared or direct driven?
Geared. I know, every gear reverses the direction of rotation.
However, I think I took that into account when I set my motor’s direction. I used the online code to verify that the arm was moving in the direction I wanted it to (+up/reverse and -down/forward).
Does this occur when you try it?
Yes, we did all of our testing using our basebot and the protobot, both of which are geared. We will probably change the layout of the dialog so it matches the “Joystick to Motor w/Limit” dialog and just calling the limits positive and negative limits.
The problem I’m having isn’t with the names. The problem is that the limit switch associated with ‘forward’ is really associated with ‘reverse’ and the limist switch associated with ‘reverse’ is really associated with ‘forward’… If you changed the names to positive and negative, the problem would still exist.
If you look at the other dialog you will see what I mean. The limits should not be associated with a joystick direction. They are just endpoints for the motor to stop against. The direction changes with gearing, and side on which the motor is mounted.