Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   1 joystick controls not turning properly (http://www.chiefdelphi.com/forums/showthread.php?t=66318)

andrew_4_life 27-03-2008 20:40

1 joystick controls not turning properly
 
When I load this code, the drive seems to mess up. Going forward and back is fine, but it won't turn to the correct side. When I turn "RIGHT" it turns "LEFT", when I turn "LEFT" it turns "RIGHT"
I've also tried switching the PWN cables but that just really messed up the controls because it was going backwards.


Code:


 
 /*---------- 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 ---------------------------------------------
  p1_x = 255 - p1_y;
  p1_y = 255 - pwm05;

  pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127);
  pwm02 = Limit_Mix(2000 + p1_y - p1_x + 127);

We also tried this: (reversing the signs
Code:

 
pwm01 = Limit_Mix(2000 + p1_y - p1_x +127);
  pwm02 = Limit_Mix(2000 + p1_y + p1_x - 127);


Bongle 27-03-2008 20:43

Re: 1 joystick controls not turning properly
 
before the 1 joystick drive portion, do this:

p1_x = 254 - p1_x

This will make the math controlling the 1-joystick drive believe that the joystick is facing the opposite direction than it is.

Alan Anderson 27-03-2008 21:48

Re: 1 joystick controls not turning properly
 
Quote:

Originally Posted by andrew_4_life (Post 725878)
When I load this code, the drive seems to mess up. Going forward and back is fine, but it won't turn to the correct side. When I turn "RIGHT" it turns "LEFT", when I turn "LEFT" it turns "RIGHT"
I've also tried switching the PWN cables but that just really messed up the controls because it was going backwards.

It sounds like you just need to redefine which direction is "forward" on your robot. :)

Seriously, Bongle has a suggestion that will work. You could also fix it in hardware by swapping the motor connections on the output of the speed controllers. That will make the motors run in the proper direction.

andrew_4_life 27-03-2008 23:05

Re: 1 joystick controls not turning properly
 
Quote:

Originally Posted by Alan Anderson (Post 725916)
It sounds like you just need to redefine which direction is "forward" on your robot. :)

Seriously, Bongle has a suggestion that will work. You could also fix it in hardware by swapping the motor connections on the output of the speed controllers. That will make the motors run in the proper direction.

I'll test out Bongle's suggestion tomorrow when I have access to the robot. But your suggestion of switching the motor connections on the output for the victors won't work because then it will drive backwards when I tell it to drive forwards. You suggestion can easily be done by swapping the PWM cables, but like I said, it makes everything backwards and still turns incorrectly though.

BigJ 28-03-2008 01:22

Re: 1 joystick controls not turning properly
 
This year, for some reason, every single one of our joysticks was giving us the wrong (opposite) 0-255 numbers on the x-axis. We had to flip it in code.


All times are GMT -5. The time now is 00:59.

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