Projects   /   Sensors & Temperature   /   PIC16F1847

A brief overview of Allegro ACS712 current sensor using PIC16F1847 (Part 2)

Part 2 turns ACS712 theory into a working DC current meter: the sensor output feeds AN0 on the PIC16F1847, and firmware converts it to amps for a 16x2 LCD.

Published
Updated

At a glance

CategorySensors & Temperature
PIC modelPIC16F1847
Reading time~3 min
Jump to a section
  1. Experimental circuit setup
  2. Quick Solutions to Questions related to DC Current Meter:
  3. Related projects

Summary of A brief overview of Allegro ACS712 current sensor using PIC16F1847 (Part 2)

This article details the implementation of a DC current meter using an ACS712-05B sensor and a PIC16F1847 microcontroller. The system measures analog voltage output via an ADC channel, converts it to current values through firmware, and displays results on a 16x2 LCD. A key feature highlighted is the ratiometric nature of the sensor, which ensures calculation accuracy even if supply voltage fluctuates.

Parts used in the DC Current Meter:

  • ACS712-05B breakout module
  • PIC16F1847 microcontroller
  • 16×2 character LCD
  • 2.7 Ω (rated 2 Watt) resistor
  • 1 nF filter capacitor
  • 100 nF decoupling capacitor
  • Power on LED
  • 2-pin terminal block
  • PIC16F1847 breadboard module
  • Experimenter's I/O board

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.

Allegro current sensor

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.

I am using my PIC16F1847 breadboard module along with the Experimenter’s I/O board to demonstrate this experiment.

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.

 

For more detail: A brief overview of Allegro ACS712 current sensor using PIC16F1847 (Part 2)

  • How is the actual load current displayed?
    The actual load current is displayed on a 16×2 character LCD after being processed by the firmware.
  • Can the power supply fluctuate without affecting the equation?
    Yes, the final equation relating current and count remains the same even if the power supply fluctuates due to the ratiometric output.
  • What happens to the sensitivity if Vcc changes to 4.0 V?
    The sensitivity changes proportionally, for example to 0.148 mV, but the calculation equation stays valid.
  • Which microcontroller is used for this project?
    The project uses a PIC16F1847 microcontroller with its ADC channel.
  • Where is the sensor output connected?
    The output of the sensor module goes to AN0, which is pin 17 of the microcontroller.
  • What component is used to vary the current in the experiment?
    A varying dc voltage is applied to vary the current through the series resistor.
  • Does the sensor require a reference voltage separate from the supply?
    No, the microcontroller uses the supply voltage (+5V) as the reference for A/D conversion.
  • What capacitors are included on the ACS712-05B breakout module?
    The module has a 1 nF filter capacitor between pin 6 and ground and a 100 nF decoupling capacitor between power supply lines.
Development Boards & Kits · PIC16F1847

Breakout board for PIC16F1847 microcontroller

This is an improved version of my 18-pin PIC16F series breadboard module that I have used in many of my PIC tutorials...

Audio, Sound & Radio · PIC16F1847

PIC16F1847 and AR1010 Based FM Radio Music Box

This is my first Instructable post. I made a Digital FM Radio box using this cheap AR1010 FM Radio receiver module that...

Communication & Interfacing · PIC16F1847

A brief overview of Allegro ACS712 current sensor. Part 2 – Interface the sensor with a PIC microcontroller

In the first part of this discussion, the features of ACS712 device were briefly discussed. Now we will use that theory to...

Sensors & Temperature

Spectrum Analyzer using TMS320F28023DA with Proteus Simulation

Introduction This project demonstrates a real-time audio spectrum analyzer using the TMS320F28023DA Piccolo microcontroller, simulated in Proteus VSM. The system captures an...

Sensors & Temperature

DHT22 Low Cost Humidity Sensor using PIC18F25K20 with Proteus Simulation

IntroductionThis microcontroller project demonstrates how to interface a DHT22 (RHT03) digital temperature and humidity sensor with a PIC18F25K20 using Proteus simulation.The project...

Sensors & Temperature

Crafting a Microcontroller-Based Temperature Monitoring System

Abstract As technological advancements progress, processes become increasingly intricate, demanding a corresponding expansion in the parameters necessary for efficient analysis. Data acquisition,...

Ibrar Ayyub

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough...