View Single Post
  #13   Spotlight this post!  
Unread 03-02-2007, 09:56
N7UJJ N7UJJ is offline
Teacher
AKA: Allan Cameron
FRC #5465 (BinaryBots)
Team Role: Teacher
 
Join Date: Jan 2004
Rookie Year: 2002
Location: Phoenix, AZ
Posts: 253
N7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond repute
Re: PWM Problem with Default Code

Here is the section of source code that is found in file user_routines.c that maps the joystick inputs to the PWMs




/*---------- Analog Inputs (Joysticks) to PWM Outputs-----------------------
*--------------------------------------------------------------------------
* This maps the joystick axes to specific PWM outputs.
*/
pwm01 = p1_y;
pwm02 = p2_y;
pwm03 = p3_y;
pwm04 = p4_y;
pwm05 = p1_x;
pwm06 = p2_x;
pwm07 = p3_x;
pwm08 = p4_x;
pwm09 = p1_wheel;
pwm10 = p2_wheel;
pwm11 = p3_wheel;
pwm12 = p4_wheel;

/*---------- 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);





Note that if you are using two joystick drive, that pwm01 and pwm02 should be connected to the motor speed controler, but if you want to use 1 joystick drive, the motor speed controlers should be contected to pwm13 and the other to pwm15. You would not have to modify the code one bit.

However, if you want to modify the code to change the way the joysticks control the pwms, then the above section of the source code is the place to do it.

Last edited by N7UJJ : 03-02-2007 at 09:57. Reason: spelling errors