Close
0%
0%

Arduino Negative Voltmeter

3-Channael voltmeter with ability to measure both negative & positive voltages on the same circuit or 3 different circuits simultaneously

Similar projects worth following
Introduction
Stuck with only one multimeter/voltmeter ? But, sometimes you need to check 2 or 3 voltages as the same time. Then this is something you might consider making, a real DC voltmeter !

Designed with commonly available components and easy to understand code, can measure both positive and negative voltages simultaneously on 3 nodes in a single circuit or 3 separate circuits.

https://www.youtube.com/watch?v=XVYsdZYpMV0

Introduction

Stuck with only one multimeter/voltmeter ? But, sometimes you need to check 2 or 3 voltages as the same time. Then this is something you might consider making, a real DC voltmeter !

Designed with commonly available components and easy to understand code, can measure both positive and negative voltages simultaneously on 3 nodes in a single circuit or 3 separate circuits.

Demonstration

Measuring voltages across resistor and battery on 2 different circuits

Hardware

Following hardware are used to build this device:-

  • Arduino Uno: Uploading code on the ATmega328P microcontroller
  • ATmega328P: 8-bit micro with Arduino Bootloader and built-in 10 bit ADC
  • 128x32 1306 OLED Display with I2C interface: Display Voltages
  • LM324 OpAmp: Analog signal conditioning for ADC
  • 4cm x 6 cm FR4 protoboard: Circuit board for the build
  • 10k multiturn pot: Adjusting zero (half AREF) voltage
  • TP4056 module: LiPo battery charging
  • LiPo battery: 300mAh rechargable battery to power the device

Hardware

Hardware

Working Principle: AFE Explained

Normally, ATmega328P (Arduino Uno) can measure voltages between Gnd and AVCC range (i.e. 0 to 5V) without any voltage divider resistors network. If internal AREF is enable, it can measure voltages between Gnd and AREF range (i.e. 0 to 1.1 V). With some voltage divider, it is possible to measure higher voltages than 5V. These are all positive voltages with respect to Gnd.

But it can not measure any voltages below Gnd, meaning it can't measure negative voltages. The problem is that, ATmega328P has a single ended ADC, which by default makes measurement with respect to Gnd.

The solution is, don't make measurement with respect to Gnd anymore.

Real voltmeters have COM (Black) and V(Red) terminals, you connect COM to one node, V to another node on a circuit. The voltage reads on V node with respect to COM node.

You need to build an (AFE) Analog Front End, some sort of signal conditioning circuit to generate a COM like behavior. This COM node should have a voltage somewhere in between AVCC and Gnd. Ideally, half AVCC volts but for this design it's half AREF.

When external voltage measurements are taken with respect to COM, you can easily measure both positive and negative voltages !

Please check the following circuit carefully :

Differential measurement with 2 single ended ADC channels

Differential measurement with 2 single ended ADC channels

So, what's happening here ? Internal reference AREF is enabled on ATmega328P (from firmware/code in void setup). AREF pin has 1.1 V. Now, ADC measurement has an effective range of 0 to 1.1 volts.

Next, using a LM324 Opamp this 1.1 AREF voltage is buffered, meaning we still have 1.1 voltage from the first Opamp's output. A 10k multiturn trim pot is set exactly to 5k to produce 550mV (half AREF) volts. This 550 mV signal is buffered with the second Opamp. 550 mV signal is also connected to ADC Ch - 0. It should read 512 (half of 10 bit).

There is a voltage divider network consist of 5 Mega Ohms (two 10M in parallel) and 100 Kilo Ohms resistor, which is connected to the output of second Opamp.

I am defining, lower resistor end (100k) as COM and higher resistor (5M) end as V on this voltage divider network. The mid point of this divider is connected to ADC Ch - 1. When no external voltage is applied to this divider, ADC Ch - 1 should read 512 (because of 550 mV)

When an external voltage is applied, the voltage divider mid point voltage will shift above or below 550 mV. If external voltage on V is higher (positive voltage) with respect to COM, it will shift above 550 mV, If external voltage on V is lower (negative voltage) with respect to COM, it will shift below 550 mV. The ADC Ch - 1 reading will change accordingly. Using this change in ADC reading we can calculate external voltages.

Why use AREF instead of AVCC ?

This design is LiPo battery powered, a full charge LiPo will start from 4.2 Volts and gradually the voltage will drop. So, AVCC...

Read more »

main.c

Arduino code

plain - 4.38 kB - 08/03/2023 at 20:39

Download

  • 1 × ATmega328P Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × Arduino Uno dev board
  • 1 × LM324 Quad Opamp
  • 1 × 1306 OLED 128x32
  • 1 × Multi-Turn Precision Potentiometer- 10k ohms

View all 14 components

  • 1
    Working Principle: AFE Explained

    Normally, ATmega328P (Arduino Uno) can measure voltages between Gnd and AVCC range (i.e. 0 to 5V) without any voltage divider resistors network. If internal AREF is enable, it can measure voltages between Gnd and AREF range (i.e. 0 to 1.1 V). With some voltage divider, it is possible to measure higher voltages than 5V. These are all positive voltages with respect to Gnd.

    But it can not measure any voltages below Gnd, meaning it can't measure negative voltages. The problem is that, ATmega328P has a single ended ADC, which by default makes measurement with respect to Gnd.

    The solution is, don't make measurement with respect to Gnd anymore.

    Real voltmeters have COM (Black) and V(Red) terminals, you connect COM to one node, V to another node on a circuit. The voltage reads on V node with respect to COM node.

    You need to build an (AFE) Analog Front End, some sort of signal conditioning circuit to generate a COM like behavior. This COM node should have a voltage somewhere in between AVCC and Gnd. Ideally, half AVCC volts but for this design it's half AREF.

    When external voltage measurements are taken with respect to COM, you can easily measure both positive and negative voltages !

    Please check the following circuit carefully :

    Differential measurement with 2 single ended ADC channels

    Differential measurement with 2 single ended ADC channels

    So, what's happening here ? Internal reference AREF is enabled on ATmega328P (from firmware/code in void setup). AREF pin has 1.1 V. Now, ADC measurement has an effective range of 0 to 1.1 volts.

    Next, using a LM324 Opamp this 1.1 AREF voltage is buffered, meaning we still have 1.1 voltage from the first Opamp's output. A 10k multiturn trim pot is set exactly to 5k to produce 550mV (half AREF) volts. This 550 mV signal is buffered with the second Opamp. 550 mV signal is also connected to ADC Ch - 0. It should read 512 (half of 10 bit).

    There is a voltage divider network consist of 5 Mega Ohms (two 10M in parallel) and 100 Kilo Ohms resistor, which is connected to the output of second Opamp.

    I am defining, lower resistor end (100k) as COM and higher resistor (5M) end as V on this voltage divider network. The mid point of this divider is connected to ADC Ch - 1. When no external voltage is applied to this divider, ADC Ch - 1 should read 512 (because of 550 mV)

    When an external voltage is applied, the voltage divider mid point voltage will shift above or below 550 mV. If external voltage on V is higher (positive voltage) with respect to COM, it will shift above 550 mV, If external voltage on V is lower (negative voltage) with respect to COM, it will shift below 550 mV. The ADC Ch - 1 reading will change accordingly. Using this change in ADC reading we can calculate external voltages.

    Why use AREF instead of AVCC ?

    This design is LiPo battery powered, a full charge LiPo will start from 4.2 Volts and gradually the voltage will drop. So, AVCC will also change. But internal reference AREF has constant 1.1 Volts. That's why I chose AREF.

    If other microcontrollers are used, which do not have AREF, you can use TL431 IC to generate reference voltage !

    Why use LM324 Opamp ?

    LM324 IC has 4 Opamps in a single package, widely available and it's output can go (very close) to Gnd. It also works with any supply voltage between 3 to 32 volts.

    You can always use better Opamps (Precision, Low Noise, Rail-to-Rail)

  • 2
    Voltage Calculation Formula

    Measured voltage with ADC will be a tiny fraction of actual voltage applied. That's why following formula is used inside the firmware to calculate back the actual voltage:-

    Formula

  • 3
    Voltage Divider Resistor: Range vs Resolution
    • Selecting the right input resistor R_Low and R_High is important because the values of resistors will determine the effective voltage measurement range based on this formula :

    <b>+/- V = (R_High / R_Low) / 2</b>

    • R_High and R_Low must have a watt rating which can handle the measurement voltage, should satisfy following formula :

    <b>V < sqrt ((R_High + R_Low) * P)</b>

    • Input impedance of a voltage measurement device must be in the order of hundreds of Kilo Ohms to few Mega Ohms to minimize the loading effect :

    R_High + R_Low > hundreds of kOhms to few MOhms

    For this project, this voltmeter can measure +/- 25 volts with R_High = 5M (or 5000k) and R_Low = 100K with 1/10 watt rating, which satisfy above 3 conditions

    • Next comes measurement resolution which is limited by actual ADC resolution and the effective measurement range you want to set. ADC resolution is the smallest incremental voltage that can be recognized.

    Measurement Resolution = Measurement Range / ADC Resolution

    • For example : If the measurement range is set +/- 5 V with 10 bit ADC, you should get a resolution of about 10 mV in that range. But for this design with +/- 25 V of measurement range (of total 50V), resolution is about 49 mV.
    • Resolution also depends on how many digits are shown in the display. This design only shows 1 digit after decimal point, so 49 mV resolution could be as high as 100 mV or 0.1 volt.

    Example : Suppose a fresh AA battery reads 1.627 volts with a Fluke voltmeter, but this voltmeter may read only 1.5 or 1.6 or 1.7 volts

    • For better range or resolution select microcontroller with 12 bit ADC or more
    • Reduce measurement range to increase resolution
    • Reduce resolution to increase range or measure bigger voltages

View all 6 instructions

Enjoy this project?

Share

Discussions

Per Jensen wrote 07/30/2024 at 22:04 point

There's a typo in the title "3-Channael" - It should be *channel.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates