$30
Basic use of ADC and an LCD display with ATmega32.
Fig. 1: Potentiometer, LCD display, Atmega32
Experimental Tools And Materials:
ATmega32, Potentiometers (POT-HG), 16x2 LCD display (LM016L), DC voltmeter.
Experiment:
In this experiment you will have to generate a variable voltage from 0 Volt to X Volt (X is provided in the individual specification) using a potentiometer. You will measure this voltage using ADC and display the voltage in the LCD segment. You will also continuously monitor the voltage using a voltmeter. You should use the DC voltmeter of Proteus. We will change the voltage using the pot and the reading of ADC from the LCD segment should be within ± 0. 02𝑉to the value shown in the DC voltmeter.
Individual Specification: MC Experiment 3 - Individual Spec
LCD Display Basics:
You should check out this tutorial: Interfacing 16x2 LCD with Atmega32 Microcontroller using Atmel Studio. You will be using the 4 bit mode. Essentially, you will use their library file lcd.h and connect your LCD display according to the given diagram. You do not need to use crystal. The connection summary is given in the following table.
LCD Display Pin
Connection
VSS
GND
VDD
5V
VEE (Contrast, see below)
Can vary within 0V-5V
RS
PC6
RW
GND
E
PC7
D0-D3
Ground
D4-D7
PD4-PD7
Contrast: VEE is used for contrast. In the real world, you can vary this from 0V to 5V depending on how clearly you can see the characters. VEE is varied with a potentiometer. This video clip will show a demo of how varying VEE changes the contrast of the LCD display. Although, in Proteus, we will not be able to experience that. https://www.youtubetrimmer.com/view/?v=Pq6-PGPdl_c&start=41&end=54
ADC Basics:
The basics were covered in the theory class.
1. Do necessary calculations according to your clock speed and configuration.
2. Use the internal 5V as the ADC source. You will have to connect AVCC to 5V.
3. Just to test your understanding, you are not allowed to use the ADC register for this experiment. Instead, you must use both ADCH and ADCL registers. We encourage you to use the ADC register to calculate the analogue voltage in your spare time.
Procedure:
1.First create an X Volt source. You can use the voltage division rule to extract X Volt from a 5V source. Then create a variable voltage source VS in range 0V-XV using the potentiometer. Ensure the potentiometer is working by checking its output in the DC voltmeter.
2.Connect the LCD display to your microcontroller. Write the necessary code to display a simple string, e.g., “Patience!!” to check the LCD display is working.
3. Complete the necessary ADC connections. Write necessary code to calculate the voltage VS.
4.Display the voltage in LCD display in the format “Voltage: #.##” i.e. one digit before the decimal point and two digits after the decimal point. In other words, you have to show the text “Voltage: ” and the value of the voltage VS.
Demo Video:
This is a demonstration of what we expect. Here, max voltage X = 4V. MC Experiment 3 - ADC Demo.mkv
Miscellaneous:
1. You may not be able to create exactly X Volt source. A source of X 0.05V is acceptable too. ±
2. Be careful while reading ADCL and ADCH. You must read ADCL first. We encourage you to try reading ADCH first and see what happens. Try to find out the reason.