Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Dampening function for driving. (http://www.chiefdelphi.com/forums/showthread.php?t=51750)

Brad Voracek 13-01-2007 14:06

Dampening function for driving.
 
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.

jgannon 13-01-2007 14:12

Re: Dampening function for driving.
 
In general, a good way to alter an output by a constant factor is:
Code:

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

Brad Voracek 13-01-2007 14:18

Re: Dampening function for driving.
 
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.


All times are GMT -5. The time now is 01:21.

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