DavyJones ...
Sorry ... but that one gets sent to the "Locker".
Yup, we were talking about an ACS712 from Allegro in that thread.
But, hell_pk had also specified 10-bit A/D with a 2.61V VREF-.
You seem to be using 8-bit A/D without a reference, so yes, things are going to be different ...
With VREF+ = 5V, and VREF- = 0V, at 8-bit ... each A/D step is 0.0196V. (5 / 255)
The ACS712 idles at 2.5V, and with 8-bit resolution that's an A/D reading of 127.
And assuming you are using the default 66mv/A sensitivity, the formula looks like this ...
(ADvalue - 127) * 196 / 66
Which should give 1 decimal of precision ... 10.0amps = 100
With quite a bit of integer truncation due to the 8-bit resolution.<hr>
ADD:
That only works with positive currents, so to make sure it never sees negative numbers, you can add this before the formula to limit the A/D values ...
ADvalue = ADvalue MAX 127
hth,





Bookmarks