A brief overview of Allegro ACS712 current sensor using PIC16F1847 (Part 2)
In the first part of this discussion, the features of ACS712 device were briefly discussed. Now we will use that theory to implement the ACS712 sensor to make a simple DC current meter. The analog output voltage from the sensor is measured through an ADC channel of the PIC16F1847 microcontroller. A voltage to current conversion equation will be derived and implemented in the firmware of the PIC microcontroller and the actual load current will be displayed on a character LCD.
Experimental circuit setup
We are going to setup a test experiment to demonstrate the use of ACS712 to measure a DC current. I am using an ACS712-05B breakout module (you can find them cheap on ebay) for this purpose. It has got a 1 nF filter capacitor connected between pin 6 and ground, a 100 nF decoupling capacitor between power supply lines, and a power on LED soldered on the board. The power supply and output lines are accessible through header pins on one side, whereas, the current terminals are connected to a 2-pin terminal block on the opposite side, as shown below.
The experimental circuit diagram of the DC current meter is shown below. A 2.7 Ω (rated 2 Watt) resistor is connected in series with the current terminals and a varying dc voltage is applied to vary the current through the resistor and the current path. The output of the sensor module goes to AN0 (pin 17) ADC channel of the PIC16F1847 microcontroller. A 16×2 character LCD is used to display the measured current output.
The microcontroller uses the supply voltage (+5V) as reference for A/D conversion. The digitized sensor output is processed through software to convert it to the actual current value. The mathematics involved in the process is described in the white board below.
Important note: The calculations shown above considered supply voltage Vcc = Vref = 5.0 V. Interestingly, the final equation relating I and Count remains the same even the power supply fluctuates. For example, suppose Vcc fluctuates and becomes 4.0 V. Then, the sensitivity of the ACS712-05B also changes to 0.185 x 4/5 = 0.148 mV. If you repeat the above calculations with Vcc = Vref = 4.0 V and sensitivity = 0.148 mV, you will end up with the same equation for I and Count. This was possible because of the ratiometric output of the ACS712 sensor.
JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw
Current Project / Post can also be found using:
- acs712 with pic microcontroller