Nothing Special   »   [go: up one dir, main page]

Digital Voltmeter Using Arduino: University of Zakho Faculty of Science Department of Computer Science Microprocessor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

University of Zakho

Faculty of Science
Department of Computer Science
Microprocessor

Report
Digital Voltmeter Using Arduino

Prepared by:

Abdulhakeem Ashti

Ibrahim juma

Salih Yaseen

Haval Anwar

Zher Mohammed Salih

may, 2020

Supervisor:

Mr. Omar M. Malallah


Contents
ABSTRACT ........................................................................................................................................................................... 2
NTRODUCTION .................................................................................................................................................................. 3
Voltage measurement ........................................................................................................................................................... 4
Digital Voltmeter ................................................................................................................................................................... 5
Component of Digital voltmeter .......................................................................................................................................... 6
Liquid Crystal Display (LCD) ........................................................................................................................................... 12
Potentiometer ...................................................................................................................................................................... 14
Circuit diagram ................................................................................................................................................................... 15
Circuit design ...................................................................................................................................................................... 17
Circuit working ................................................................................................................................................................... 19
Probleme .............................................................................................................................................................................. 20
Programming....................................................................................................................................................................... 21
Flow chart for project ......................................................................................................................................................... 24
Examples of voltages ........................................................................................................................................................... 25
CONCLUSION And future Work..................................................................................................................................... 27
References ............................................................................................................................................................................ 28

1
ABSTRACT

It's easy to make a simple digital voltmeter using an Arduino and 16x2 liquid crystal display
(LCD). It's 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 ten-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 5 V--you can easily calculate the voltage present at the analog
input.
To display the measured voltage, we will use a liquid crystal display (LCD) that has two lines of
16characters. LCDs are widely used to display data by devices and it has a lot of electrical
appliances.
This project will also show you how to measure voltages above
the reference voltage by using a voltage divider.

2
NTRODUCTION

A digital voltmeter (DVM) attains the required measurement by converting the analog input
signal into digital and when necessary by discrete-time processing of the converted values.
The measurement result is presented in a digital form that can be coded as a decimal BCD
code or a binary code the main factors that characterize DVMs are speed automatic
operation and programmability in particular they presently offer the best combination of
speed and accuracy lf compared with other available voltage-measuring instruments
moreover capability of automatic operations and program-mability make DVMs very useful
in application where flexibility high speed and computer controllability are requied A
typical application field is therefore that of automatically operated systems when a DVM is
directly interfaced to a digital signal processing (DSP) and used to convert the analog input
voltage into a sequence of sampled values it is usually called an analog-to-digital converter
(ADC)

Figure (1-1)basic DVM diagram

3
Voltage measurement

Is one of the most basic measurements in the electronic measurement. Generally, an electronic
measuring instrument is classified roughly by voltage measurement, current (or charge)
measurement, and measurement of both (electric power and impedance). For example, the
oscilloscope is a measuring instrument that displays the voltage value sensed by the tip of the
probe on the screen as a time waveform, and it can be called a voltmeter in a broad sense
because the physical value of the target measurement is the voltage. However, at present this is
a measuring device focused on the high-speed response and sampling rate exceeding several
GHz or more, and generally the precision and resolution of the voltage measurement is not
high. The digital multi meter is the most basic ammeter and voltmeter, and various lineups like
the hand-held type, bench top type etc. are available. It is most widely used for general voltage
measurement because high accuracy and high resolution voltage measurement devices are
available, though it does not match the oscilloscope with respect to speed. The electrometer has
the function of current and voltage measurement similar to the digital multi meter. When
focusing attention on the voltage measurement, it can be positioned with the voltmeter
characterized by the high input resistance at the measuring terminal by comparing with the
digital multi meter. The advantage of the voltage measurement using the electrometer is
described in this document.

4
Digital Voltmeter

A digital voltmeter (DVM) attains the required measurement by converting the analog input
signal into digital and when necessary by discrete-time processing of the converted values. The
measurement result is presented in a digital form that can be coded as a decimal BCD code or a
binary code the main factors that characterize DVMs are speed automatic operation and
programmability in particular they presently offer the best combination of speed and accuracy lf
compared with other available voltage-measuring instruments moreover capability of automatic
operations and programmability make DVMs very useful in application where flexibility high
speed and computer controllability are required A typical application field is therefore that of
automatically operated systems when a DVM is directly interfaced to a digital signal processing
(DSP) and used to convert the analog input voltage into a sequence of sampled values it is
usually called an analog-to-digital converter (ADC)

5
Component of Digital voltmeter

Arduino Uno 328p

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14
digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz
ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. Shown
in [4]
Table 2-1 Features of Arduino Uno 328p.[5]

Microcontroller ATmega328p

Operating Voltage 5V

Input Voltage 7-12V


(recommended)

Input Voltage (limit) 6-20V

Digital I/O Pins 14 (of which 6 provide PWM output)

PWM Digital I/O Pins 6

6
Analog Input Pins 6

DC Current per I/O Pins 20 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 32 KB (ATmega328P) of which 0.5


KB used by boot loader

SRAM 2 KB (ATmega328P)

EEPROM 1 KB (ATmega328P)

Clock Speed 16 MHZ

LED-BUILTIN 13

Length 68.6 mm

Width 53.4 mm

Weight 25 g

7
It contains everything needed to support the microcontroller shown in igure (2-1); simply
connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to
get started.[6]

Figure (2-1) Arduino Uno 328p

The Uno 328p can be powered vin the USB connection or with an DC supply of 6 to 20 volts.

Figure (2-2) USB and DC input

8
If supplied with less than 7V however, the 5V pin may supply less than five volts and the board
may become unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.[6]
The digital pins are as follows:Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit
(TX) TTL serial data. On the Arduino Diecimila, these pins are connected to the corresponding
pins of the FTDI USB-to-TTL Serial chip. On the Arduino BT, they are connected to the
corresponding pins of the WT11 Bluetooth module. On the Arduino Mini and LilyPad Arduino,
they are intended for use with an external TTL serial module (e.g. the Mini-USB Adapter ) .
External Interrupts: 2 and 3. These pins can be con igured to trigger an interrupt on a low value,
a rising or falling edge, or a change in value. See the attach Interrupt() function for details.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analog Write() function. On
boards with an ATmega8, PWM output is available only on pins 9, 10, and 11.
BT Reset: 7. (Arduino BT-only) Connected to the reset line of the bluetooth module.
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication,
which, although provided by the underlying hardware, is not currently included in the Arduino
language.
LED: 13. On the Diecimila and LilyPad, there is a built-in LED connected to digital pin 13.
When the pin is HIGH value, the LED
is on, when the pin is LOW, it's off.[7]

Figure (2-3) digital pins

9
Analog Pins
In addition to the specific functions listed below, the analog input pins support 10-bit analog-to-
digital conversion (ADC) using the analog Read() function. Most of the analog inputs can also
be used as digital pins: analog input 0 as digital pin 14 through analog input 5 as digital pin 19.
Analog inputs 6 and 7 (present on the Mini and BT) cannot be used as digital pins.

I2C: 4 (SDA) and 5 (SCL). Support I2C (TWI)


communication using the Wire library (documentation on the

Wiring website.[7]

Figure (2-4) analog pins

10
Power Pins
VIN (sometimes labelled "9V"). The input voltage to the Arduino board when it's using an
external power source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the power jack,
access it through this pin. Note that different boards accept different input voltages ranges,
please see the documentation for your board. Also note that the LilyPad has no VIN pin and
accepts only a regulated input.
The regulated power supply used to power the microcontroller 5V and other components on the
board. This can come either from VIN via an on-board regulator, or be supplied by USB or
another regulated 5V supply.

V3: (Diecimila-only) A 3.3 volt supply generated by the on-

board FTDI chip.

GND: Ground pins.[7]

Figure (2-5) power pins

11
Other Pins:
AREF: Reference voltage for the analog inputs. Used with analog Reference.

Reset: (Diecimila-only) Bring this line LOW to reset the microcontroller. Typically used to add
a reset button to shields

which block the one on the board.[7]

Liquid Crystal Display (LCD)

LCD (Liquid Crystal Display) screen is an electronic display module and ind a wide range of
application. A 16x2 LCD display is very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other multi segment
LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of
displaying special & even custom characters (unlike in seven segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD
each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, command
and Data shown in igure (2-6).
The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several
interface pins at once to control the display. The interface consists of the following pins:
A register select (RS) pin that controls where in the LCD's memory you're writing data to. You
can select either the data register, which holds what goes on the screen, or an instruction
register, which is where the LCD's controller looks for instructions on what to do next.
A read/write R/W pin that select
reading mode or writing mode.
An Enable pin that enables writing
to the register 8data pins (D0 -
D7). The states of these pins (high
or low) are the bits that you're
12
writing to a register when you write, or the values you're reading when you read.
There's also a display constrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight
(Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and
turn on and off the LED backlight, respectively.

Figure (2-6) LCD

The process of controlling the display involves putting the data that form the image of what you
want to display into the data registers, then putting instructions in the instruction register. The
LiquidCrystal Library simplifies this for you so you

don't need to know the low-level instructions.[8]

13
Potentiometer
A potentiometer is a manually adjustable variable resistor with 3 terminals. Two terminals
are connected to both ends of a resistive element, and the third terminal connects to a sliding
contact, called a wiper, moving over the resistive element. The position of the wiper determines
the output voltage of the potentiometer. The potentiometer essentially functions as a variable
voltage divider. The resistive element can be seen as two resistors in series(potentiometer
resistance), where the wiper position determines the resistance ratio of the first
resistor to the second resistor
A potentiometer is also commonly known as a potmeter or pot most common form of potmeter
is the single turn rotary potmeter. This type of pot is often used in audio volume control
(logarithmic taper) as well as many other applications. Different materials are used to construct
potentiometers, including carbon composition, cermet, wirewound, conductive plastic or metal
film.[9]

Figure (2-7) potentiometer

14
Circuit diagram
The circuit diagram is shown in igure (3-1)

uno

15
Figure (3-1) circuit diagram

16
Circuit design

In this project we implement an arduino for digital voltmeter using a related technology. For
measuring voltage less than or equal to 50.
Pin 1 and 2 (Vss and Vdd) of the LCD power supply pins for display. They are connected to
ground and +5V supply respectively. Pin 3 (Vee) of the LCD is the contrast adjust pin of the
display. It is connected to the wiper terminal of the 5KΩ POT while the other terminals of the
POT are connected to +5V supply and ground respectively.
The next three pins of the LCD are control pins. Pins 4 and 6 (RS and E) of the LCD are
connected to digital input/output pins 8 and 9 of Arduino respectively. Pin 5 (RW) of the LCD
is connected to ground.
The next connections are with respect to data pins. The LCD is used in 4-bit data mode and
hence data pins D4 to D7 are used. Connect pins 11 to 14 (D4 to D7) of the LCD are connected
to digital input/output pins 4 to 7 of the Arduino. Pins 15 and 16 are the supply pins of the
backlight LEDs. Pin 15 (LED+) of the LCD is connected to +5V supply . Pin 16 (LED-) of the
LCD is connected to ground.
The output of the voltage divider circuit consisting of 100KΩ resistor and 10KΩ resistor is
connected to the analog input pin A0 of the Arduino UNO with other end of the 100KΩ resistor
connected to the voltage to be measured and the other end of the
10KΩ resistor connected to the ground.
The ground terminal of the input voltage to be measured and
Arduino UNO must be common.[10]

17
Figure (3-2) circuit design

18
Circuit working

The working of the project is explained here:


In a digital voltmeter, the voltages to be measured, which are in analog form, are converted to
digital form with the help of Analog to Digital Converters (ADC). Hence, the ADC feature of
the Arduino UNO is utilized in this project.
In the circuit, which is used to measure a maximum voltage of
50V, the input voltage is given to the analog input pin of the Arduino. The reference voltage of
the ADC is 5V. The ADC in Arduino UNO is of 10-bit resolution. Hence, the input voltage is
calculated by multiplying the analog value at the analog pin with 5 and dividing the value with
1024.
The range of voltages for Arduino UNOs analog input is 0V to
5V. Hence, in order to increase this range, a voltage divider circuit must be used.
The range of the analog input of Arduino UNO is increased up to 50V by using a voltage
divider consisting of 100KΩ resistor and 10KΩ resistor. With the help of the voltage divider
circuit, the input voltage being measured is brought down to the range
of Arduino UNOs analog input.
The rest of the calculations are made in the programming part of the Arduino UNO.[10]

19
Probleme

In this project we encountered many problems building the project of most of these problems.

1-The difficulty of using caustic welding for the first time.

2-The difficulty of the work and write the code compiler because of us doesn't have knowingly
about processing of program.

3-We encountered some difficulty in programming the LCD display.

4-There is a small difference in measured volvulity and this is due to the use of voltage divider.

5- The battery connected to arduino is low on power and not discharge.

20
Programming
Programming code LCD with arduino:

#Include<Liquidcrystal . h>

Liquidcrystal lcd (7,8,9,10,11,12) ;

Void setup()

Lcd. Begin(16,2) ;

Lcd. Print ("Hello world") ;

Void loop()

Lcd. Setcursor(0,1) ;

Lcd. Print(millisc)/1000) ;

21
Programming code main circuit with arduino:

//include the library code:

#include <LiquidCrystal.h>

initialize the library by associating any needed LCD interface

//pin

//with the arduino pin number it is connected to

const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7; LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int analogInput = 2;

loat Vout = 0.00;

loat Vin = 0.00;

loat R1 = 100000.00;

loat R2 = 10000.00;

int val = 0;

void setup()

pinMode(analogInput, INPUT);

Serial.begin(9600); //BaudRate

lcd.begin(16, 2);

lcd.print("DIGITAL VOLTMETER");

22
void loop() {

val = analogRead(analogInput);//reads the analog input

Vout = (val * 4.99) / 1024.00; // formula for calculating voltage out i.e. V+, here 5.00

Vin = Vout / (R2 / (R1 + R2)); // formula for calculating voltage in i.e. GND

if (Vin < 0.1) //condition

Vin = 0.00; //statement to quash undesired reading!

Serial.print("\t Voltage of the given source =" );

Serial.println(Vi );

lcd.setCursor(0, 1);

lcd.print("Voltage = " );

lcd.print(Vin ) ;

delay(100);

delay(1000); //for maintaining the speed of the output in serial

moniter

23
Flow chart for project

24
Examples of voltages

Figure (3-3) example of voltage

25
Figure (3-4) example of voltage

26
CONCLUSION And future Work

The versatility, accuracy, precision, robustness of digital electronic devices. Can not be
matched with that of analog devices as the former ones are far more superior. Digital
voltmeter is a very simple example of a digital electronic device. The disadvantage o f
using voltage divider based voltmeter is the error of measurement hence, we need multiple
ranges of voltmeter. In order to reduce the error , the ratio of R1 and R2 in the voltage
divider must be minimum. We choose R1 as 100kohm and R2 10kohm then it is possible to
measure the voltages up to 50v .
The circuit can be extended to measure even Ac voltages with slight modification circuit
and code. Now a days digital voltmeter are also replaced by digital miltimeters due to its
multitasking feature i.e. It can be used for measuring current, voltage and resistance. But
still there are some fields where separated digital voltmeters are being used .

27
References

[1] https:// www.codrey.com/arduino - projects / nano - digital - voltmeter.

[2] https://store. Arduino.cc/usa/ arduino – uno – rev3.

[3] https://www. Arduino. cc/en/products/compare.

[4] https://www. Arduino .cc/en/main/arduinoboarduno 328p.

[5] https://www. Arduino .cc/en/reference/board.

[6] https://www. Arduino .cc/en/tutorial/hello world.

[7] www.resistorguide.com/potentiometer/.

[8] https://www. Electronics hub.org/digital – arduino – voltmeter/.

[9 ] http:\\WWW.Keysight.Com Voltage Measurements

[10] http:\\WWW.engnetbase.Com

28
29
30
31
32

You might also like