0% found this document useful (0 votes)
3 views28 pages

Mod5 LCD DAC ADC

The document provides instructions for interfacing various LCDs and DACs with an 8051 microcontroller, detailing initialization commands and data transmission methods. It includes assembly code examples for sending commands and data to the LCD, as well as generating staircase and triangular waveforms using a DAC. Additionally, it discusses the resolution of ADCs and includes a program for monitoring analog inputs and converting them to ASCII format.

Uploaded by

Nishitha Girish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views28 pages

Mod5 LCD DAC ADC

The document provides instructions for interfacing various LCDs and DACs with an 8051 microcontroller, detailing initialization commands and data transmission methods. It includes assembly code examples for sending commands and data to the LCD, as well as generating staircase and triangular waveforms using a DAC. Additionally, it discusses the resolution of ADCs and includes a program for monitoring analog inputs and converting them to ASCII format.

Uploaded by

Nishitha Girish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Pin Positions for Various LCDs from Optrex

To send data and commands to LCDs you should do the


following steps. Notice that steps 2 and 3 can be
repeated many times:
1. Initialize the LCD:
Command Sequences: 0x38, 0x0E, and 0x01
2. Send any of the commands from Table 2 to the LCD.
Make Pins RS and R/W=0,
Put command number on the data pins (D0-D7)
Then send a high-to-low pulse to E pin
3. Send the character/Data to be shown on the LCD.
Make pins RS = 1 and R/W = 0
Then put the data on the data pins (D0–D7) and
send a high-to-low pulse to the E pin to enable the
internal latch of the LCD.
LCD Connections for 8-bit Data
ORG 0H
MOV A,#38H ;INIT. LCD 2 LINES, 5X7 MATRIX
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#0EH ;display on, cursor on
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#01 ;clear LCD
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#06H ;shift cursor right
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#84H ;cursor at line 1, pos. 4
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#’N’ ;display letter N
ACALL DATAWRT ;call display subroutine
ACALL DELAY ;give LCD some time
MOV A,#’O’ ;display letter O
ACALL DATAWRT ;call display subroutine
AGAIN: SJMP AGAIN ;stay here
COMNWRT: ;send command to LCD
MOV P1,A ;copy reg A to port 1
CLR P2.0 ;RS=0 for command
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
CLR P2.2 ;E=0 for H-to-L pulse
RET
DATAWRT: ;write data to LCD
MOV P1,A ;copy reg A to port 1
SETB P2.0 ;RS=1 for DATA
CLR P2.1 ;R/W=0 for write
SETB P2.2 ;E=1 for high pulse
CLR P2.2 ;E=0 for H-to-L pulse
RET
DELAY: MOV R3,#50 ;50 or higher for fast CPUs
HERE2: MOV R4,#255 ;R4 = 255
HERE: DJNZ R4,HERE ;stay until R4 becomes 0
DJNZ R3,HERE2
RET
#include <reg51.h> void lcdcmd (unsigned char value)
sfr Idata = 0x90; //P1 = LCD data pins {
sbit rs=P2^0; Idata = value;
sbit rw=P2^1; rs = 0;
sbit en=P2^2; rw = 0;
void main() en = 1;
{ MSDelay(1);
lcdcmd (0x38); en = 0;
MSDelay(250); return
lcdcmd (0x0E); }
MSDelay(250); void lcddata (unsigned char value)
lcdcmd (0x01); {
MSDelay(250); Idata = value;
lcdcmd (0x06); rs = 1;
MSDelay(250); rw = 0;
lcdcmd (0x86); en = 1;
MSDelay(250); MSDelay(1);
lcddata (‘M’); en = 0;
MSDelay(250); return
lcddata (‘D’); }
MSDelay(250); void MSDelay (unsigned int itime)
lcddata (‘E’); {
MSDelay(250); unsigned int I, j ;
} for (i=0; i<itime; i++)
for (j=0; j<1275; j++) }
8051 Interfacing with DAC0808
(a) MOV A, #00H
MOV P1,A ; SEND DATA TO DAC
BACK: INC A ; COUNT FROM 0 TO FFH
SJMP BACK

Here max value of digital number is FFH=11111111B


So Iout = 2mA x 255/256 = 1.99 mA
So Vout = 1.99 mA x 5K = 9.96 V

(b) MOV R0, #64H


RPT: MOV A, #00H
BACK: MOV P1,A ; SEND DATA TO DAC
INC A ; COUNT FROM 0
CJNE A, R0, BACK ; Compare
SJMP RPT
Here max value of number is 64H = 01100100B; Voot=3.9 V
Problem:

Connect a switch SW to P0.0. Write a program to


(a) When SW = 0, the DAC Output gives a staircase
waveform
(b) When SW = 1, the DAC Output gives a triangular
waveform

Solution:
Let us design a staircase waveform for 5 steps, 255/5=51
So increment of each step is 51. After the maximum
value is reached, O/P drops to zero and next cycle starts
Analog-to-Digital Converter:
An ADC has n-bit resolution where n can be 8, 10,
12, 16 or even 24 bits. The higher-resolution ADC
provides a smaller step size, where step size is
the smallest change that can be discerned by an
ADC
The following program monitors the INTR pin and brings
an analog input into register A. It then calls hex-to-ASCII
conversion and data display subroutines.
ADC ALP
ADC C Program

You might also like