Calibration problem using map function

I'm measuring voltage on an analog pin and using map to convert the data to volts (*5/1023 is inaccurate) but the result is not linear. I calibrated the top and bottom of the range, but in between it is inaccurate. eg: V = map(raw, 514,858,228,400) (mv) 228 = 228 247 = 250 328 = 338 357 = 369 372 = 386 390 = 394 400 = 400 Average of 20 reads. Nano.

Any ideas? Would there be different results on other pins?

Can you post the full code, and also a set of data like that including the value of raw that it's getting fed for each value?

Northland: I'm measuring voltage on an analog pin and using map to convert the data to volts (*5/1023 is inaccurate) but the result is not linear. I calibrated the top and bottom of the range, but in between it is inaccurate. eg: V = map(raw, 514,858,228,400) Any ideas? Would there be different results on other pins?

So you are mapping from 514 to 858 as data from the analog pin to 228 to 400 as output from the map function?

map(value, inputLow, inputHigh, outputLow, outputHigh)

So 514 raw input should give you 228 from the map function?

And in the table is the first column input and second column output or vice versa?

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks… Tom… :slight_smile:
What Vref are you using?
What model Arduino do you have.

Never mind, I found testing other pins that a6 and a7 are fried, was using a0. Something bad happened. So this nano can't be used for that job anyway since I needed all 22 outputs.

Thanks

Those can’t all be from the same map() function. The last two points aren’t linear.
screenshot.59.png

Hi,

See comment #7 http://forum.arduino.cc/index.php?topic=123176.0

Analog pins A6 and A7 are weird. They can only be used for analogRead()

best, Michael

Edit: Props to DrAzzy