View Single Post
  #5   Spotlight this post!  
Unread 16-01-2006, 17:34
Mike's Avatar
Mike Mike is offline
has common ground with Matt Krass
AKA: Mike Sorrenti
FRC #0237 (Sie-H2O-Bots (See-Hoe-Bots) [T.R.I.B.E.])
Team Role: Programmer
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Watertown, CT
Posts: 1,003
Mike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond reputeMike has a reputation beyond repute
Re: Controlling motors

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.
__________________
http://www.mikesorrenti.com/