Scaling values
blueice
Posts: 12
Hello,
I'm getting a value varying from 0 to 180...and i need to get it to correspond to 1100 to 120...
0 must correspond to 1100...
according to this link:
http://forums.parallax.com/showthread.php?p=519918
Using the above method i can get 0 to 180 to correspond to 120 -1100,but how do i do it the opposite way
ie 0-180 to 1100 to 120
Thank you for your time
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
**·ice**
Gerard Sequeira
Machinegrid.com·:: Robots at Work!!
Parallel Port Tutorials,
Autonomous Robots,
PIC16F84a Temperature Controller
·
I'm getting a value varying from 0 to 180...and i need to get it to correspond to 1100 to 120...
0 must correspond to 1100...
according to this link:
http://forums.parallax.com/showthread.php?p=519918
Jon Williams said...
Since you're getting 0 - 255 now (I don't have a part to test so I will have to go with your assertion -- though it doesn't match the data sheet), you can use a simple equation to get your desired output range from the pot's span.
You want 0 - 255 to become 330 to 1230 ... so try this mx+b equation:
adc = adc */ $388 + 330
How does it work? Well, your output range has a span of 900, so you divide that by 255 (max pot value)·to get the slope (3.5294 -- the 'm' in mx + b). We can use the */ operator to multiply by fractions (in increments of 1/256). To use */ you take your fractional value (3.5294) and multiply it by 256; you 903.5 -- round up to 904.· I like to convert to HEX as I can see the whole part in the upper byte, the fractional part in the lower byte.· 904 in hex is $388.· Of course, we have to add the minimum value; then we're done.
Using the above method i can get 0 to 180 to correspond to 120 -1100,but how do i do it the opposite way
ie 0-180 to 1100 to 120
Thank you for your time
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
**·ice**
Gerard Sequeira
Machinegrid.com·:: Robots at Work!!
Parallel Port Tutorials,
Autonomous Robots,
PIC16F84a Temperature Controller
·
Comments
That's not to say one of the guys doesn't have a good idea.
BUT, what type of sensor is it?· Might it be possible to rearrange a circuit (if it's a passive type of device?!).
You might try an inverting op-amp with a DC boost at the end?!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
How would the stamp handle the sign....or does it matter?· 180 - 0 = -180.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
The new equation becomes:· scaleVal = ((180 - inputVal) */ $571) + 120
The equation assumes that inputVal never exceeds 180.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 1/20/2005 2:42:34 PM GMT
Apparently I pressed too hard when I shaved my head this morning...must've taken some brain cells with it!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."