Our driver this year wants a kind of “transmission” in the programming, where if he has a switch up the speed is halfed(or any other number I suppose) for both motors. Or if it’s down it drives normally. I have the function all set for the switch and everything, what’s throwing me off is trying to half the motor speed in arcade drive. I have the entire thing done in tank drive, with the switch “transmission” and everything, the problem is in arcade drive… It’s driving me crazy trying to think about it and any help would be appreciated. Thanks.
~Brad.
In general, a good way to alter an output by a constant factor is:
pwm01 = (pwm01-127)*0.5+127
This will give you half the magnitude of your original output… change the 0.5 to taste. (Also, be careful, and pretend that this is pseudo-code. Because PWM values are stored as unsigned chars, you may get some interested errors with casting when you go in reverse. Maybe cast pwm01 as an int first?)
Ahh, I got it. I’ll get my outputs from the joystick, then half them… I was trying to find a way to do it incorporating it into the joystick function (x - y + 127 or x + y - 127) type thing. But doing it after I get those number is just as good, thanks.