Quote:
|
Originally Posted by Mike Soukup
No, the workaround is as Sven stated, fix the range in software. All you need to do is determine the min & max values of each joystick axis and create a function that linearly maps the smaller joystick range to the full 0-254 range. Just make sure you have two mapping functions, one for below 127 and one for above. Then calibrate your speed controllers for the full 0-254 range. We've been using this method for at least 3 years.
|
I've often wondered how I could linearize a range of values to another range of values, such as 137-235 linearized to 137-254. But, not being a software guru, yet, I am not certain how to do this without several "if, if else, else" statements turning the output into a multi stepped scale. Something like:
if (P2y > 135 && P2Y <= 145)
PWM02 = 140
if else (P2Y > 145 && P2y <= 155)
PWM02 =150
etc. etc. etc.
As you can see, not too smooth a response. So the question is, what code would you use to linearly map one range to another?