Go Down

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

#### ninjay

##### Aug 09, 2012, 05:32 pm
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

#1
##### Aug 09, 2012, 05:38 pm
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.
Don't PM me for help as I will ignore it.

#### retrolefty

#2
##### Aug 09, 2012, 05:48 pm
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

#3
##### Aug 09, 2012, 08:53 pm
TY worked well.

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

#### majenko

#4
##### Aug 09, 2012, 10:25 pm
Code: [Select]
`float lbs;int v;v = analogRead(0);lbs = (float)(v-205) / (1024.0-205.0) * 1300.0;`

#### PeterH

#5
##### Aug 10, 2012, 12:48 am

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').

#### Riva

#6
##### Aug 10, 2012, 08:18 am

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
Don't PM me for help as I will ignore it.

Go Up