Quote:
|
Originally Posted by railerobotics
I am trying to set up a two joystick drive(tank drive) but I am a little confusing on how to actually go about doing this.
|
Ok, you may have noticed the four ports on the operator interface. Find out which two your two joysticks are plugged in.
pX_y is the value that we want. It's the value of the y axis on the joystick plugged into port
X. So if you want to find the value of the y axis on a joystick plugged into port 1, it would be
p1_y. These values are between 0 and 254. 127 is neutral, 0 is full reverse and 254 is full forward.
Now look on your robot controller. There is a set of 16 3-pin male headers. This is where your motors are connected. They are labeled 1-16. Find out which one the motor you wish to control is on. You can set these motors to a value between 0 and 254, same as the joysticks. The macro for these is
pwmXX where
XX is a value between 01 and 16. To set it to a value you simply do
pwmXX = 127;
Now, linking them together. If a motor can take in a value between 0 and 254, and a joystick can output a value between 0 and 254, this becomes very easy.
pwmXX = pZ_y;
Where
XX is the value between 01 and 16; depending on what port your motor is connected to.
Z is varying depending on what port your joystick is connected to.
Good luck.