Simple Digital Current Meter (DCM) using PIC microcontroller (Schematic + code + Proteus simulation)

Summary of Simple Digital Current Meter (DCM) using PIC microcontroller (Schematic + code + Proteus simulation)


This article demonstrates building a simple Digital Current Meter (DCM) using a 16-bit PIC microcontroller and a series shunt resistor to measure current with ±10mA tolerance. It utilizes Ohm's Law, converting voltage drops across the shunt into current readings via a 10-bit ADC, displayed on an LCD. The project includes C code compatible with PIC24/DsPIC33/30, MPLAB X IDE, and Proteus v8.0 simulations.

Parts used in the Digital Current Meter:

  • 16-bit PIC Microcontroller (PIC24, DsPIC33, or DsPIC30)
  • Shunt resistance (100mΩ)
  • LCD display connected to PortB
  • ADC module (10-bit)
  • Fix resistors (R4 = 10kΩ and R6 = 10kΩ)
  • Dummy variable resistor (RV1)
  • MPLAB X IDE
  • C30 Compiler
  • Proteus Simulation v8.0

This post would provide a working example of how to make a simple Current Meter (DCM) using 16bit PIC microcontroller and a series shunt resistance. We have very precise ammeter current measurement with a 10bit ADC and with a tolerance of ±10mA.

You may download code and Proteus Simulation from the download section at the bottom of this post. I am using MPLAB X IDE, C30 Compiler and Proteus Simulation on v8.0. This code is written in C Language and will work on PIC24, DsPIC33 and DsPIC30 (16bit microcontroller) by slightly changing the code.Simple Digital Current Meter (DCM) using PIC microcontroller (Schematic + code + Proteus simulation)

In this post I supposed that you know following things if not then please go through following posts before proceeding with this.

·         How to Blink an LED. (Click here)
·         How to interface an LCD. (Click here)
·         How to configure ADC module. (Click here)
·         Digital Voltmeter. (Click here)

The science behind measuring current is to add a known shunt resistance in the path from which current is flowing so the voltage drop on this shunt resistance is measured by ADC channel. By using Ohm’s Law we can find the current in particular path (As current is same in a loop). This shunt resistance is very small of some milliohms with higher wattage typically 1-10W depending upon particular application.

Proteus Simulation:

In the following figure 1. I used a fix resistor (R4 = 10kΩ and R6 = 10kΩ) for 2.5V reference voltage for ADC. And a dummy variable resistor for simulating this circuit for various current measurements. A shunt resistance with a resistance of 100mΩ is used in series with the path in which we are going to measure current. I am using ADC channel AN1 for measurement of voltage drop across shunt resistance. I used LCD on PortB.Simple Digital Current Meter (DCM) using PIC microcontroller (Schematic + code + Proteus simulation) schematic

In the following figure 2. Animation shows that when I increase/decrease resistance from variable resistor RV1 the current in the path changes as shown by a current probe named shunt resistance. And the value that is measured by current probe is same as that we measured through ADC and is displayed on LCD with a tolerance of ±10mA.

Code:

In the following figure 3. This is main function in which I first initialize LCD, then I configure ADC with Channel 1. And a loop which only calls a function named DisplayCurrent() which is responsible for displaying measured current flowing through shunt resistance on LCD.

 

 

For more deail: Simple Digital Current Meter (DCM) using PIC microcontroller (Schematic + code + Proteus simulation)

Quick Solutions to Questions related to Digital Current Meter:

  • What is the primary method for measuring current in this project?
    The science involves adding a known shunt resistance in the current path and measuring the voltage drop across it using an ADC channel.
  • How precise is the ammeter current measurement described?
    The device provides very precise measurements with a tolerance of ±10mA.
  • Which microcontrollers are compatible with the provided C code?
    The code works on PIC24, DsPIC33, and DsPIC30 by making slight changes to the code.
  • What software tools were used for development and simulation?
    The project uses MPLAB X IDE, C30 Compiler, and Proteus Simulation version 8.0.
  • Which ADC channel is used for the voltage measurement?
    ADC channel AN1 is used to measure the voltage drop across the shunt resistance.
  • What are the values of the fixed resistors used for the reference voltage?
    Resistors R4 and R6 are both 10kΩ, used to create a 2.5V reference voltage for the ADC.
  • How does the Proteus simulation verify the circuit accuracy?
    The simulation shows that the value measured by the current probe matches the value measured through the ADC and displayed on the LCD.

About The Author

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 research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter