Go to Post I got dragged into FIRST against my will, and it was the best thing that's ever happened to me. - Liz C [more]
Home
Go Back   Chief Delphi > Technical > Control System
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   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,369
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?
  #2   Spotlight this post!  
Unread 04-05-2005, 01:39
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Joysticks

Quote:
Originally Posted by billbo911
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...So the question is, what code would you use to linearly map one range to another?
Use the equation for a line, y = mx + b.
Take the input value x, multiply it by a factor m, and add an offset b to yield the output value y. The factor can be a floating point value, or to save time you can multiply by an integer and divide by another integer.
To determine the m and b constants, use algebra to solve the pair of equations for the known input and output values.
  #3   Spotlight this post!  
Unread 04-05-2005, 10:15
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,369
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 Alan Anderson
Use the equation for a line, y = mx + b.
Take the input value x, multiply it by a factor m, and add an offset b to yield the output value y. The factor can be a floating point value, or to save time you can multiply by an integer and divide by another integer.
To determine the m and b constants, use algebra to solve the pair of equations for the known input and output values.

Thank You Alan

I knew it would be a relatively simple solution.
My years removed from Algebra are many, too many in fact, so some portions of my memory need a little refresh. This will help tremendously.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2004-2005 Joysticks kjohnson Control System 3 11-04-2005 23:39
Pressure sensative Joysticks Validius General Forum 1 15-03-2005 13:59
number of joysticks Waste General Forum 21 27-01-2005 15:04
need joysticks! Tom Bottiglieri General Forum 14 24-02-2004 09:36
AVB joysticks..and other analogue joysticks tml240 Kit & Additional Hardware 6 07-02-2004 12:45


All times are GMT -5. The time now is 06:03.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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