Pages: [1]   Go Down
Author Topic: 1-5V scaling signal  (Read 408 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2586
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

TY worked well.

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

UK
Offline Offline
Faraday Member
**
Karma: 100
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:

float lbs;
int v;

v = analogRead(0);

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

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

I only provide help via the forum - please do not contact me for private consultancy.

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2586
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: [1]   Go Up
Jump to: