The default code for single joy stick drive is
pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm02 = Limit_Mix(2000 + p1_y - p1_x + 127);
however with this code our robot turns right when joystick is forward , and goes forward when the joy stick is pushed to the left.
Mathematically
pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm02 = 254-Limit_Mix(2000 + p1_y + p1_x - 127);
would solve the problem, assuming 254 is the maximum value for the PWM since I dont have the robot with me I can not tell if this will work. Could you please tell me if this will work, if not could you please tell me why or point me in the right direction.
I am not to sure on the code. I was looking at it with my mentor tonight because we kind of wanted to see how the code worked, for certain reasons . From what i learned tonight is that Limit_Mix is a function. I didn’t know if you knew that or not?? I don’t see though why your joystick is doing that. We are currently using a older joystick that was i think in the 2003 kit, we haven’t really messed with using the new ones. So i don’t know if it is just a problem with the new ones or not. I assume you are using the new joysticks that came in the kit? Also if i was you i would check the wiring going to the speed controllers and from the speed controllers, there could be a problem there.
As far as the code you did to correct that problem, i am not sure if that will work or not. Especially since i am kind of just learning C. However i am not sure if you can “legally” do “254-Limit_Mix” i don’t know if C will compile that or not.
If i remember right the answer would be yes the max is 254 and the min is 0. And doing it mathimatically if 127 is “stop” (center) 127 + 127 = 254 and 127 - 127 = 0 so i would assume so. And i am assuming thats the same way you guessed 254.
hmm well thanks for the help you got me in the right direction, When you mentioned it was a function(which i knew but was kind of ignoring) it made me realize i should check the function in the code when i found it the whole thing made sense, I would be happy to explain if any one has the same problem. Basically I think this should work, If any one knows other wise please let me know, I will post when I get a chance to test it tomorrow
Once you are convinced the math is OK, there is still one more possible thing to check.
The Limit Mix function absolutely requires that the joysticks be calibrated.
If the calibration is off, the robot will go in different directions than where the joystick is pointed.
The lights on the operator interface show if p1_y and p2_y are calibrated.
For single joystick, the p1_y and p1_x need to be calibrated.
Calibration is when both y and x values are 127 when the joystick is centered.
Hope this helps.
We tried to do tank drive last year and it was awful. But then again we had an insanely fast robot last year. We should probably try it again this year with what will hopefully be a slower bot.
I actually have found tank drive better than single joystick drive. Although i do have to admit it depends on the game for that season. To me with tank drive you seem to have a lot more control. But then again that also depends on what kind of drive system you have, ex. : 2 wheel, 4 wheel, 6 wheel. But yeah either one is fine with me, they both work great.