Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Changing 1 joystick code to 2 (rookie team) (http://www.chiefdelphi.com/forums/showthread.php?t=25642)

Brawler006 19-02-2004 21:03

Changing 1 joystick code to 2 (rookie team)
 
We are a rookie team and we have noobies working on the C code.
We see the code for 1 joystick drive i.e.

/*---------- 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.
*/
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

etc....

This is a 4 motor robot and we need one joystick to control the left side and a second joystick to control the right side.
HELP US PLEASE!!!! WE HAVE NO IDEA WHAT WE ARE DOING!!! :ahh: :ahh:

Thanks,
A Rookie Team

Rickertsen2 19-02-2004 21:10

Re: Changing 1 joystick code to 2 (rookie team)
 
Quote:

Originally Posted by Brawler006
We are a rookie team and we have noobies working on the C code.
We see the code for 1 joystick drive i.e.

/*---------- 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.
*/
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

etc....

This is a 4 motor robot and we need one joystick to control the left side and a second joystick to control the right side.
HELP US PLEASE!!!! WE HAVE NO IDEA WHAT WE ARE DOING!!! :ahh: :ahh:

Thanks,
A Rookie Team

Ok i can help you. Just tell me what ports your joysticks are connected to and what PWMs your motors are connected to, and i'll tell you what to change.

KenWittlief 19-02-2004 21:10

Re: Changing 1 joystick code to 2 (rookie team)
 
in the default code, the outputs are mapped to:

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;

so you could simply use the Y cables and put the two right motors on pwm01 and the two left motors on pwm02

or edit the code above to put the same signal on two outputs - if you want your right motors on pwm1 and pwm2 and your left motors on 3 and 4, change it to

pwm01 = p1_y;
pwm02 = p1_y;
pwm03 = p2_y;
pwm04 = p2_y;

BTW - this code is in the file user_routines.c - after you edit it you have to pull down the menu and 'make' your code (let it compile)

PS- make a backup copy of your default code somewhere first :^)

Joel J 19-02-2004 21:12

Re: Changing 1 joystick code to 2 (rookie team)
 
Quote:

Originally Posted by Brawler006
We are a rookie team and we have noobies working on the C code.
We see the code for 1 joystick drive i.e.

/*---------- 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.
*/
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

etc....

This is a 4 motor robot and we need one joystick to control the left side and a second joystick to control the right side.
HELP US PLEASE!!!! WE HAVE NO IDEA WHAT WE ARE DOING!!! :ahh: :ahh:

Thanks,
A Rookie Team

Code:

pwm13 = pwm14 = p1_y;
  pwm15 = pwm16 = p2_y;

Now, the joystick going into Port 1 of the OI will control your left motors and the joystick into port 2 will control the right motors.. assuming of course that the left motors are plugged into pwm13 and pwm14, and the right motors are plugged into pwm15 and pwm16. That help you out any? Two joystick drive is usually just a direct output from the joystick to the PWMs.. its the one stick code that takes a bit of work.

Astronouth7303 20-02-2004 16:30

Re: Changing 1 joystick code to 2 (rookie team)
 
ps- It's faster to compile by hitting F10, it won't recompile what you didn't change.

ChrisA 20-02-2004 17:00

Re: Changing 1 joystick code to 2 (rookie team)
 
This piece of code can be found already created in the default code in the user_routines.c file.

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.
  */ 
  pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
  pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);



All times are GMT -5. The time now is 15:31.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi