acs712 current sensor

Thread Starter

mahmut_kelesoglu

Joined Aug 12, 2022
67
ı need to use acs712 current sensor with arduino for sensing the current. as my researches, for calculating the current, first, one have to calculate voltage by using analog output value of the sensor. then, by using this voltage, calculate the current by dividing voltage value to resistance value.
the part that ı want to ask is "ıs it not a cuurent sensor? why it does not give the current value? how can ı calculate the current?"
actuallt my circuit and code runs very well on proteus, but in real circuit, the sensor gives stupid values.
my circuit and code is attached.
thanks in advance.
 

Attachments

Ian0

Joined Aug 7, 2020
8,947
Did you take into account that ACS712 is a bi-directional current sensor, and that the output with zero current is half the supply voltage?
 

eetech00

Joined Jun 8, 2013
3,653
ı need to use acs712 current sensor with arduino for sensing the current. as my researches, for calculating the current, first, one have to calculate voltage by using analog output value of the sensor. then, by using this voltage, calculate the current by dividing voltage value to resistance value.
the part that ı want to ask is "ıs it not a cuurent sensor? why it does not give the current value? how can ı calculate the current?"
actuallt my circuit and code runs very well on proteus, but in real circuit, the sensor gives stupid values.
my circuit and code is attached.
thanks in advance.
The model is not very good.
The real part has a 2.5v offset. The offset has to be removed, usually by an opamp.
 

Ian0

Joined Aug 7, 2020
8,947
The model is not very good.
The real part has a 2.5v offset. The offset has to be removed, usually by an opamp.
If the ACS712 shares the same power supply as the microcontroller then zero current will give an a/d result of 0x8000 (assuming a 16-bit A/D or a left-justfied 16-bit result). All you have to do is subtract 0x8000 from the A/D reading to give a two's complement number.
 

dendad

Joined Feb 20, 2016
4,370
A trick you can try is to offset the reading by carefully positioning a magnet near the ACS712 as the device is a Hall sensor. Then you can have the full range for DC.
 

eetech00

Joined Jun 8, 2013
3,653
ı need to use acs712 current sensor with arduino for sensing the current. as my researches, for calculating the current, first, one have to calculate voltage by using analog output value of the sensor. then, by using this voltage, calculate the current by dividing voltage value to resistance value.
the part that ı want to ask is "ıs it not a cuurent sensor? why it does not give the current value? how can ı calculate the current?"
actuallt my circuit and code runs very well on proteus, but in real circuit, the sensor gives stupid values.
my circuit and code is attached.
thanks in advance.
Post your proteus files.
 

ronsimpson

Joined Oct 7, 2019
2,796
Use the filter capacitor on pin 6.
It is common to average 10 numbers because of noise.
Do not make hardware answers. Use software.
If you make one circuit you can make it any way that works. But, when we make millions this must be different. We make the "2.5 offset" in EEPROM because some parts need 2.55 and some need 2.45 and you can calibrate so every time, zero current = zero number. (note that "2.5V" is not right, it is actually 1/2 the supply voltage)
Also,
The data sheet has x.x mV/A which depends on which part number you are using. The Data Sheet indicates +/-4% error. We calibrate each part and save the error in EEPROM so all boards read correctly.
1665769261345.png
1665769320105.png
 
Top