View Single Post
  #13   Spotlight this post!  
Unread 24-04-2008, 22:30
JimWright949's Avatar
JimWright949 JimWright949 is offline
The Owen Day of Seattle
AKA: Jim Wright
FRC #4542 (Titanium Talons)
Team Role: Mentor
 
Join Date: Sep 2003
Rookie Year: 2003
Location: Redmond, WA
Posts: 94
JimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to beholdJimWright949 is a splendid one to behold
Re: Joystick Input Mapping

Hmm, at this point what I would have you do, is put the robot up on blocks and download the code to it to see what happens. However since I'm not near you, I can't have you do that.

What your code will do is just move the robot forward or backward, there will not be any turning. To turn you can copy some code.

If you are using the FrcCode_2007_8722 code base from the ifi site, find the user_routines.c file, and on line 238 you will find this code:

/*---------- 1 Joystick Drive ----------------------------------------------
*--------------------------------------------------------------------------
* This code mixes the Y and X axis on Port 1 to allow one joystick drive.
* Joystick forward = Robot forward
* Joystick backward = Robot backward
* Joystick right = Robot rotates right
* Joystick left = Robot rotates left
* Connect the right drive motors to PWM13 and/or PWM14 on the RC.
* Connect the left drive motors to PWM15 and/or PWM16 on the RC.
*/
p1_x = 255 - p1_y;
p1_y = 255 - pwm05;

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

This maps one joystick to two motors (really four but two are the same). After these lines add:

pwm13 = curve[pwm13];
pwm14 = curve[pwm14];
pwm15 = curve[pwm15];
pwm16 = curve[pwm16];

That will give you the one joystick drive and the curve that you want.

You will have to add the curve array from my post above to the code, put it somewhere like line 31 which is outside of functions.

-Jim