Log in

View Full Version : Inverting Joysticks?


The yellowdart
20-02-2006, 18:19
The electrical guys and i have wired the robot and everything. All the wiring is pretty neat and tidy, but we have a problem.... we have 2 right handed transmissions and need to invert one of our joysticks.

I was just wondering what i would do in the code to invert the joysticks. Any and all help or ideas would be greatly appreciated.

**we dont wanna rewire anything, we would like to change the code

sanddrag
20-02-2006, 18:30
It is very easy to just swap the wires on the motor side of the victor. If you want to do it in the program, replace all your pwm values with 254-whateveryoucurrentlyhave That should invert it.

The yellowdart
20-02-2006, 19:01
we only need it switched for one joystick.....will doing 254 - whatever really invert, or is there a command to invert it?

Travis Hoffman
20-02-2006, 19:24
joystickvar = 254 - joystickvar;


That's all you need.

Keith Watson
20-02-2006, 19:53
we only need it switched for one joystick.....will doing 254 - whatever really invert, or is there a command to invert it?Yes, it really inverts it. There is no command although you could right your own function.

It is very easy to just swap the wires on the motor side of the victor.On one of our motors this is what our programmer chose to do. Just swap the red and black wires on the output. It's probably helpful to document that someplace in case the wires are ever disconnected and need to be reconnected in the correct place.

Idaman323
20-02-2006, 20:05
Wow I didn't think of it being as easy as 254-p1_y.......

I came up with 127-(p1_y-127) which essentially does the same thing... I think to much...