Thread: Joysticks
View Single Post
  #10   Spotlight this post!  
Unread 03-05-2005, 17:55
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,355
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Joysticks

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?