Axes in Default Code?

Hi, I’ve been looking over the 2007 default code and making adjustments where necessary; however, I’ve encountered something that doesn’t seem right to me. Under the one-joystick drive section, I see this code:

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

I haven’t actually downloaded the code to the robot, but it seems like the first two lines would switch the X and Y axes. I made a simple program that allowed me to input joystick values and it gave me the right/left drive values, and it gave me the backwards output I expected. It seems to me like removing those first two lines should solve the problem. Is this normal? Are the axes switched? Should I go ahead and remove those two lines?

Thanks,
Dylan

Haven’t seen those first 2 lines you wrote, but if you connect the PWM13 to the right motor(victor) and PWM15 to the left, it will all work.

hey, that code is assuming that the shaft of the two motors are facing each other…

if you mount your motors with the shafts pointing away from each other then your motors will run backwards (up on joystick means drive backwards, left on joystick causes robot to turn right).

you need to invert the signal in the code to support the motors aligned with shafts facing away.

try this modification:

p1_x = p1_y- 255 ;
p1_y = pwm05 - 255;

slloyd

now here’s a question for you…

what does pwm05 have to do with the joystick? on our robot nothing is even plugged into pwm05… why is this part of the single joystick X/Y mixing operation code?

:confused: i have no idea…

slloyd

Before that bit of code, the program sets p1_y to pwm06 and p1_x to pwm05.

thx for the clarification

i wonder if that is safe? i mean, what if i connected something to PWM05?

maybe the single joystick control code should default to:

p1_x_unmodified = p1_x;

p1_x = 255 - p1_y;
p1_y = 255 - p1_x_unmodified;

eh?