Go Down

Topic: 1-5V scaling signal (Read 491 times) previous topic - next topic

ninjay

I have search the forums. And did not find my answer. Sorry in advance if it was there.

I have a scale with measures 0-1300 LBS. It provides a 1-5V output signal.

How can make the arduino give the correct output weight? I cannot figure the scale for the 1-5V.

Riva

Assuming the scale in linear then use the map() function http://arduino.cc/en/Reference/Map
Something like lbs = map( V, 0, 1023, 0, 1300) where V is the value you read from the analogue input.
I might seem like an idiot but remember it takes one to know one.
Forum user generally fall into three categories (the good, the bad & the a**hole) what category do you fit in?

retrolefty

I would assume that because of the 1vdc 'zero offset' in your weight signal the mapping function should be setup as follows:

Code: [Select]
lbs = map( V, 205, 1023, 0, 1300);

Lefty

ninjay

TY worked well.

Curios is there a way to do this mathematically without mapping?

majenko

Code: [Select]


float lbs;
int v;

v = analogRead(0);

lbs = (float)(v-205) / (1024.0-205.0) * 1300.0;

PeterH


is there a way to do this mathematically without mapping?


All map() does is apply an offset and scale to the value you give it - in other words, it is implementing the 'mathematical' approach you mention (although I think you'll find that mathematicians refer to this as 'arithmetic').
I only provide help via the forum - please do not contact me for private consultancy.

Riva


Curios is there a way to do this mathematically without mapping?

From the map() reference link I supplied.
Quote
For the mathematically inclined, here's the whole function

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}


Thanks retrolefty for pointing out my error, I really must read the posts properly  :smiley-red:
I might seem like an idiot but remember it takes one to know one.
Forum user generally fall into three categories (the good, the bad & the a**hole) what category do you fit in?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy