0% found this document useful (0 votes)
15 views

I229896 - B - ENA FA23 Lab 09 - Design DC, AC Voltmeter Using Arduino

Good boy All notes good notes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

I229896 - B - ENA FA23 Lab 09 - Design DC, AC Voltmeter Using Arduino

Good boy All notes good notes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Electrical Network Analysis

(EL-2004)
LABORATORY MANUAL
Spring 2024

LAB 09
Design of DC/AC Voltmeter using Arduino
Waqar Ahmad

________________________________________ __________ ___ _______


STUDENT NAME ROLL NO SEC DATE

______________________________________
LAB ENGINEER SIGNATURE & DATE

MARKS AWARDED: /10


___________________________________________________________________________
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES (NUCES), ISLAMABAD

Prepared by: Engr. Aamer Munir Version: 1.0


Verified by: Engr. Azhar Rauf Date: 18 October, 2023
Last Edited by: Arslan Ahmed Date: 18 October, 2023
Design of DC/AC Voltmeter using Arduino LAB: 09

LAB
09 Design DC/AC Voltmeter using Arduino
:
Learning Objectives:
In this lab session you will learn how to:
1. Measure DC voltage using Arduino
2. Convert AC voltage to DC voltage
3. Measure AC voltage using Arduino

Tools needed:
1. PC running Windows Operating System and Arduino IDE
2. Arduino UNO Board Kit
3. USB Cable
4. One 5V Light Emitting Diode (LED)
5. LCD Module
6. Potentiometer (5KΩ or 10KΩ)
7. Resistor of 220Ω
8. Breadboard
9. Jumper wires
10. Operational amplifier IC (741)
11. Function Generator

Prior to this lab, your laptop must have Arduino IDE already installed and running.
You are expected to have run the simple programs listed in
File -> Examples -> Basic

Also, your Arduino kit must have the LCD module installed and working.
You are also expected to have run the simple LCD programs listed in:
File -> Examples -> Liquid Crystal

DC Voltmeter:

Reading Analog input on the Arduino

It is relatively simple to use an Arduino to measure voltages. The Arduino has several analog input
pins that connect to an analog-to-digital converter (ADC) inside the Arduino. The Arduino ADC is a
10-bit converter, meaning that the output value will range from 0 to 1023. We will obtain this value by
using the analogRead() function. If you know the reference voltage -- in this case, we will use 5V --
you can easily calculate the voltage present at the analog input (this is known as calibration).

In this experiment, we will make a digital voltmeter capable of measuring up to 5V using an Arduino
board and a 16x2 LCD.

Use a jumper wire connected to Arduino pin A0 to connect to the point whose voltage is to be
measured with respect to the GND.

Electrical Network Analysis NUCES, ISLAMABAD Page 2 of 9


Lab
Design of DC/AC Voltmeter using Arduino LAB: 09

Digital Voltmeter Sample Code:

The following is the code for the DVM.

#include "LiquidCrystal.h"

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;


LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
float input_voltage = 0.0;
float temp=0.0;

void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2); //set up the LCD's number of columns and rows:
lcd.print("DVM by your regn");
}

void loop()
{
//Conversion formula for voltage
int analog_value = analogRead(A0);
input_voltage = (analog_value * 5.0) / 1024.0;

if (input_voltage < 0.1)


{
input_voltage = 0.0;
}

Serial.print("v = ");
Serial.println(input_voltage);

lcd.setCursor(0, 1);
lcd.print("Voltage = ");
lcd.print(input_voltage);

delay(300);
}
Note:
The lines of code that begin with 'Serial.' are not
needed for interfacing with LCD. Instead, they are to
print out the output on the Serial Monitor. It is a
good tool for debugging to see whether the code is
working fine or not. If the LCD is not showing anything
but the Serial Monitor is, may mean the connections
with the LCD module are faulty and/or the LCD module
itself is faulty.

You need to understand the interfacing of both LCD and analog input.

Electrical Network Analysis NUCES, ISLAMABAD Page 3 of 9


Lab
Design of DC/AC Voltmeter using Arduino LAB: 09

Lab Task # 1:

Replicate the above mentioned code and design a DC voltmeter of 0-10V range. Use DC power
supply.

Note: Input voltage should not be increased by 7 V.

*attach image here

Paste only the relevant changes in the modified code for Voltmeter in the space given below (and
submit on GCR):

Electrical Network Analysis NUCES, ISLAMABAD Page 4 of 9


Lab
Design of DC/AC Voltmeter using Arduino LAB: 09

AC Voltmeter:

In this lab we will also look at measuring AC voltages. We will use the Function Generator to generate
AC signals. We will then proceed to measure the AC voltage of the signal.

We have to follow some steps to convert the AC voltage into DC and to measure it with an Arduino.
We must scale the voltage down since Arduino’s will only be able to measure the voltage between 0V-
5V. We also have to keep in mind that Arduino will not measure the negative voltage, so after signal
conversion our negative peak should be greater than zero.

Waveform Showing Peak, Peak-to-Peak, and RMS value

https://www.engineersgarage.com/contribution/arduino-based-voltmeter

As before, we employ a voltage divider circuit to scale down the Function Generator voltage to
measurable quantity. We will also use a half wave rectifier diode in series with the voltage divider
circuit to prevent the negative cycles from entering the circuitry. This is shown in the figure below.

Schematic diagram for Scale Down the input voltage

Calculation:
In the above circuit, diode is used as a half rectifier. The output of the half wave rectifier is the average
DC voltage, which can be calculated by using the following formula:

Electrical Network Analysis NUCES, ISLAMABAD Page 5 of 9


Lab
Design of DC/AC Voltmeter using Arduino LAB: 09

Resistors R1 and R2 form a voltage divider that scales down the rectified DC voltage. This is done in
such a way that when the input voltage is maximum, the voltage drop across R2 should not be more
than 5V.

Measuring AC voltage:

The ADC of the Arduino then measures the maximum DC voltage or the Peak voltage ‘Vp’ of the AC
waveform.

The voltage of the sinusoidal AC voltage is then expressed in terms of its ‘Root Mean Square’ (RMS)
value. Recall that the RMS voltage is an equivalent DC voltage value corresponding to a sinusoidal
AC waveform, which can provide the same amount of Power to a device as the sinusoidal AC voltage
does.

The RMS value of the AC voltage VRMS can be calculated from the peak voltage ‘Vp’ using the
following equation;

The voltage drop at the rectifier diode also needs to be considered, hence

Since the Arduino captures voltage signal at any moment, we employ the following code to calculate
the maximum V2 voltage from 500 samples to obtain maximum voltage of sinusoidal AC waveform.
Lab Task # 2:
Build a
for(int i=0;i<500;i++); half-wave
rectifier
{
and attach
adc_value=analogRead(A0);
if(voltage_peak_value<adc_value)
voltage_peak_value=adc_value;
else;
delay(10);
}

dc_voltage_vo=voltage_peak_value*(5.0/1024.0);
ac_voltage=dc_voltage_vo*0.707;

Electrical Network Analysis NUCES, ISLAMABAD Page 6 of 9


Lab
Design of DC/AC Voltmeter using Arduino LAB: 09

an
appropriate voltage divider to measure up to 10V AC using Arduino. Document all your steps clearly.

Space for calculation:

Electrical Network Analysis NUCES, ISLAMABAD Page 7 of 9


Lab
Design of DC/AC Voltmeter using Arduino LAB: 09

Paste your code in the space given below (and submit on GCR):

Important Note:
The marks for this lab will be awarded based on the way you
work during the lab -- the way you build your circuit,
troubleshoot in case something is not working and do
anything the instructor tells you to do.

Electrical Network Analysis NUCES, ISLAMABAD Page 8 of 9


Lab

You might also like