Quote:
Originally Posted by bizarospooky
neat so, baisically ignore the function stuff and do something like in the operator control
If(Joystick_1(that's the desired)>rampspeed(that's the actual? with it starting at 127))
{
rampspeed+=2
SetPWM(1, rampspeed)
}
Something like that?
|
That will work, but I like how you break the steps out into functions. That's good style and will make it easier to tweak your code. Because you want to add limits (make sure rampspeed stays between 0 and 254), perhaps a deadband (127 +- 10 maybe), or maybe some PID (for greater control). Also consider how your code will handle different situations:
1. If you go from forward to reverse, do you really want to wait for your ramp to count through neutral before it changes direction?
2. If you are going full forward and need to stop (joystick in neutral) do you want to wait for the code to count to neutral?
Good luck!