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

Unit IV - Microcontroller Based System Design

Uploaded by

Geethakshaya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Unit IV - Microcontroller Based System Design

Uploaded by

Geethakshaya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

EC5551: MICROPROCESSORS AND

MICROCONTROLLERS
Presentation Slides:
www.sathieshkumar.com/tutorials
Unit IV: MICROCONTROLLER BASED SYSTEM DESIGN
1. Interfacing matrix display
2. (16x2) LCD Presented By,
3. High power devices
4. Optical motor shaft encoder Dr. V. Sathiesh Kumar
5. Stepper Motor Department of Electronics Engg.,
6. DC Motor speed Control using PWM MIT-Anna University
7. ADC, DAC and Relay Interfacing
8. RTC and EEPROM interface using I2C protocol
TEXT BOOK
Muhammad Ali Mazidi, Janice Gillispie Mazidi and Rolin D. McKinley, "The 8051
Microcontroller and Embedded Systems", Second Edition, Pearson Education 2008. Fifth
impression 2011 1
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:
To interface a single color 8×8 LED matrix with a 8051 microcontroller and display
a few characters in it.
It has long life almost 50,000 hours if properly installed.
Available in different sizes and colors.
Its brightness and colors can be easily controlled.
It is capable of outputting 135 lumens/watt.
With low-voltage scanning, 8×8 LED Matrix LED display have advantages such as
power saving, long service life, low cost, high brightness, a wide angle of view, long
visual range, waterproofs and so on.
E.g. 5x7, 8x8, common anode, and common cathode types are available.

2
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:
An LED dot matrix display consists of a matrix of LED’s arranged in a rectangular
configuration.
An 8×8 matrix consists of 64 dots or pixels.
There is a LED for each pixel and these LEDs are connected to total of 16 pins.
The dot matrix display has 64 LEDs and evenly grouped into 8 columns and 8 rows.
 Any individual LED or a group of LEDs in the matrix can be activated by switching the
required number of rows and columns.
For example, if Row1 is made high and Column1 is made low, the top left LED
(address R1C1) will glow.

3
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:

4
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:

5
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:
ROW EQU P3
COL EQU P2
ORG 00H
MOV COL,#00000000B ; initializes port 2 as output port
MOV ROW,#00000000B ; initializes port 3 as output port
MAIN: LCALL LET_A
SJMP MAIN ; jumps back to the main loop

6
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:
LET_A: MOV P3,#01111110B
MOV COL,#11111110B
ACALL DELAY
MOV P3,#00010001B
MOV COL,#11111101B
ACALL DELAY
MOV P3,#00010001B
MOV COL,#11111011B
ACALL DELAY
MOV P3,#00010001B
MOV COL,#11110111B
ACALL DELAY
MOV P3,#01111110B
MOV COL,#11101111B A
CALL DELAY
RET 7
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Dotmatrix Displays:
DELAY: MOV R6,#20D ; 20ms delay subroutine
HERE1: MOV R5,#255D
HERE: DJNZ R5,HERE
DJNZ R6,HERE1
RET
END

8
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


LCD replacing LEDs (Seven-segment LEDs or other multi-segment LEDs) due to
following reasons:
1. Declining prices of LCDs
2. The ability to display numbers, characters and graphics. This is in contrast to LEDs,
which are limited to numbers and few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the
task of refreshing the LCD. IN contrast, the LED must be refreshed by the CPU (or in
some other way) to keep displaying the data.
4. Ease of programming for characters and graphics.

9
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:

10
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


 Vcc and Vss provide +5V and ground respectively.
 VEE is used for controlling the LCD contrast.
 Register Select (RS) is used to select the command code register or data register
(RS=0: command code register, RS=1: data register).
 Read/Write (R/W) input allows the user to write information to the LCD or read
information from it (R/W=0: Write, R/W=1: Read).
 Enable (E) pin is used by the LCD to latch information presented to its data pin.
When data is supplied to data pins, a high-to-low pulse must be applied to the E pin
in order for the LCD to latch in the data present at the data pins. This pulse must be a
minimum of 450 ns wide.
 D0-D7 is 8-bit data pins are used to send information to the LCD or read the contents
of the LCD’s internal registers.

11
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


 To display letters and numbers, we send ASCII codes for the letters A-Z, a-z and
numbers 0-9 to these pins while making RS=1.
 There are two ways to send characters (command/data):
1. use a delay before sending the next one
2. use the busy flag (D7 bit of command register, R/W=1, E=L to H pulse) to see if
the LCD is ready for the next one.

Code(Hex) Function Code(Hex) Function

1 Clear display screen C Display on, Cursor off


LCD command codes
4 Decrement Cursor E (or) F Display on, Cursor Blinking

6 Increment Cursor 80 Beginning of 1st line

5 Shift Display Right C0 Beginning of 2nd line

7 Shift Display Left 90 Beginning of 3rd line

8 Display off, Cursor off D0 Beginning of 4th line

A Display off, Cursor on 2 Return Home


12
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:

13
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

40X2 LCD Displays: Addressing

14
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:

15
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


; P3.0 – P3.7 are connected to LCD data pins D0 – D7
; P2.0 is connected to RS pin of LCD
; P2.1 is connected to R/W* pin of LCD
; P2.2 is connected to E pin of LCD
ORG 0000H
MOV A, #38H ; initialize LCD 16 X 2
ACALL COMD ; call command subroutine
ACALL DELAY ; give LCD some time
MOV A, #0EH ; display on, cursor on
ACALL COMD ; call command subroutine
ACALL DELAY ; give LCD some time
MOV A, #01H ; clear LCD
ACALL COMD ; call command subroutine
ACALL DELAY ; give LCD some time
16
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


MOV A, #06H ; shift cursor right
ACALL COMD ; call command subroutine
ACALL DELAY ; give LCD some time
MOV A, #84H ; cursor at line 1, position 4
ACALL COMD ; call command subroutine
ACALL DELAY ; give LCD some time
MOV A, #’8’ ; display letter 8
ACALL DTA ; call display subroutine
ACALL DELAY ; give LCD some time
MOV A, #’0’ ; display letter 0
ACALL DTA ; call display subroutine
MOV A, #’5’ ; display letter 5
ACALL DTA ; call display subroutine

17
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


MOV A, #’1’ ; display letter 1
ACALL DTA ; call display subroutine
MOV A, #’-’ ; display letter -
ACALL DTA ; call display subroutine
MOV A, #’L’ ; display letter L
ACALL DTA ; call display subroutine
MOV A, #’C’ ; display letter C
ACALL DTA ; call display subroutine
MOV A, #’D’ ; display letter D
ACALL DTA ; call display subroutine
AGAIN: SJMP AGAIN ; stay here

18
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


COMD: MOV P3, A ; copy reg A to port 3
CLR P2.0 ; RS=0 for command
CLR P2.1 ; R/W*=0 for write
SETB P2.2 ; E=1 for high pulse
ACALL DELAY ; give LCD some time
CLR P2.2 ; E=0 for High to Low pulse
RET
DTA: MOV P3, A ; copy reg A to port 3
SETB P2.0 ; RS=1 for data
CLR P2.1 ; R/W*=0 for write
SETB P2.2 ; E=1 for high pulse
ACALL DELAY ; give LCD some time
CLR P2.2 ; E=0 for High to Low pulse
RET
19
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

16X2 LCD Displays:


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
END

20
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing


Translates electrical pulses into mechanical movement.
 Applications: Disk drives, Dot matrix printers, robotics
 Shaft is a permanent magnet rotor, surrounded by a four stator windings that are
paired with a centre-tapped common. This type of motors are termed as four phase or
unipolar stepper motors.
 The center tap allows a change of current direction in each of two coils when a
winding is grounded, thereby resulting in a polarity change of the stator.

21
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing

Control Word
A B A B (Clockwise)
0 1 1 1 0x07
1 0 1 1 0x0B
1 1 0 1 0x0D
1 1 1 0 0x0E

22
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing

Control Word
A B A B (Clockwise)
0 0 1 1 0x03
1 0 0 1 0x09
1 1 0 0 0x0C
0 1 1 0 0x06

23
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing

24
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing


 Step angle is determined by the internal construction of the motor, in particular the
number of teeth on the stator and the rotor.
 The step angle is the minimum degree of rotation associated with a single step.
 Steps per revolution is the total number of steps needed to rotate one complete
rotation or 360 degrees.

rpm  Steps per revolution


Steps per second=
60
25
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing


 In a 4-step switching sequence, after four steps the same two windings will be “ON”.
 How much movement is associated with these four steps?
 After completing every four steps, the rotor moves only one tooth pitch.
 Therefore, in a stepper motor with 200 steps per revolution, the rotor has 50
teeth because 4x50=200 steps are needed to complete one revolution.
 Minimum step angle is always a function of the number of teeth on the rotor.
 In other words, the smaller the step angle, the more teeth the rotor passes.
 Motor Speed: Measured in steps per second (steps/s), is a function of switching rate
(By changing the length of the time delay loop, we can achieve various rotation speeds).
 Holding torque: With the motor shaft at standstill or zero rpm condition, the amount
of torque, from an external source, required to break away the shaft from its holding
position. This is measured with rated voltage and current applied to the motor. The unit
of torque is ounce-inch or kg-cm.

26
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing


 Three common types of stepper motor interfacing: universal, unipolar and bipolar.
 They can be identified by the number of connections to the motor.
 A universal stepper motor has eight, while the unipolar has six and the bipolar
has four.
 The universal stepper motor can be configured for all three modes, while the
unipolar can be either unipolar or bipolar. Obviously the bipolar cannot be
configured for universal nor unipolar mode.

27
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing

28
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing

29
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing – 4 Step Sequence/Biphase


ORG 0000H
MOV A, #66H ; load step sequence
BACK: MOV P1, A ; issue sequence to motor
RR A ; rotate right clockwise
ACALL DELAY ; wait
SJMP BACK ; continue loop

DELAY: MOV R2, #255


H1: MOV R3, #255
H2: DJNZ R3, H2
DJNZ R2, H1
RET

30
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

8051 Microcontroller: Stepper Motor Interfacing – 8 Step Sequence


ORG 0000H
START: MOV R0, #08H ; initialize count for data
MOV DPTR, #0200H ; Load DPTR with 0200H
RPT: CLR A ; clear A
MOVC A, @A+DPTR ; load data to A
MOV P1, A ; send value to port 1
CALL DELAY ; wait
INC DPTR ; increment DPTR to next data
DJNZ R0, RPT ; decrement count
SJMP START ; continue loop

31
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design
8051 Microcontroller: Stepper Motor Interfacing – 8 Step Sequence
DELAY: MOV R2, #255
H1: MOV R3, #255
H2: DJNZ R3, H2
DJNZ R2, H1
RET

ORG 0200H
DB 09H, 08H, 0CH, 04H, 06H, 02H, 03H, 01H

END

32
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 A direct current (DC) motor is another widely used device that translates
electrical pulses into mechanical movement.
 Polarity on the leads of DC motor determines the direction of rotation. Eg:
CPU Fan.
 DC motor moves continuously.
 Speed of the motor depends on three factors: a) load, b) voltage rating and c)
current rating.
 DC motor has two rpm: no load and loaded. Manufacturer datasheet gives
the no-load rpm (few thousands to tens of thousands).
 The current rating is the current consumption when the nominal voltage is
applied with no load, and can be from 25 mA to few amps.
 Increase in voltage (1 to 150 V) will result in increase in rpm.
 Pulse width Modulation (PWM): Wider the pulse, higher the speed. 33
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 As the load increases, the rpm is decreased, unless the current or voltage
provided to the motor is increased, which in turn increases the torque.
 With a fixed voltage, as the load increases, the current (power) consumption
of a DC motor is increased.
 If we overload the motor it will stall, and that can damage the motor due to
the heat generated by high current consumption.

34
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 With the help of relays or some specially designed chips we can change the
direction of the DC motor rotation.
 H-Bridge control of DC motors.

35
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 When switches 1 and 4 are closed, current is allowed to pass through the
motor.

36
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 When switches 2 and 3 are closed, current is allowed to pass through the
motor in opposite direction.

37
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 Invalid configuration: When switches 1, 2,3 and 4 are closed.

38
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 H-Bridge logic configurations:

39
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 Quadruple high-current half-H drivers.


 It provides a bidirectional drive currents of up to 600 mA at voltages from 4.5
V to 36 V.
 Peak output current of 1.2 A.
 All inputs are TTL compatible
 Each output is a complete totem-pole drive circuit, with a Darlington transistor
sink and a pseudo-Darlington source.

40
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 A switch is connected to pin P2.7. If switch =0, the DC motor rotates in


clockwise direction else it rotates in anticlockwise direction.

41
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 A switch is connected to pin P2.7. If switch =0, the DC motor rotates in


clockwise direction else it rotates in anticlockwise direction.
ORG 00H
MAIN: CLR P1.0 ; set P1.0 as output pin (Enable line of L293D)
CLR P1.1 ; set P1.1 as output pin (Motor line 1)
CLR P1.2 ; set P1.2 as output pin (Motor line 2)
SETB P2.7 ; set P2.7 as input pin (Switch)
HERE: SETB P1.0 ; enable the L293D chip
JNB P2.7, CLK ; check whether switch is pressed
CLR P1.1 ; rotate motor counterclockwise
SETB P1.2 ;
SJMP HERE
42
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 A switch is connected to pin P2.7. If switch =0, the DC motor rotates in


clockwise direction else it rotates in anticlockwise direction.

CLK: SETB P1.1


CLR P1.2 ; rotate motor clockwise
SJMP HERE
END

43
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

The speed of the motor depends on three factors: (a) Load, (b) Voltage and
(c) Current.
 For a given load, steady speed can be maintained by pulse width modulation
(PWM).
 By changing the width of the pulse applied to the DC motor we can increase
or decrease the amount of power provided to the motor, thereby increasing or
decreasing the motor speed.

44
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
VE7104: INTRODUCTION
MICROPROCESSOR TO EMBEDDED CONTROLLERS
AND MICROCONTROLLER UNIT
UNIT IV – Microcontroller Based II & IV
System
Design

Wider the pulse, higher the speed.


 The ability to control the speed of the DC motor using PWM is one reason
that DC motors are preferable over AC motors.
 AC motor speed is dictated by the AC frequency of the voltage applied to the
motor and the frequency is generally fixed. Hence we cannot control the speed
of the AC motor.

45
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

 A switch is connected to pin P3.2, which is the INT0 pin. Normally, the DC
motor rotates with 33% duty cycle. When INT0 is activated, the motor runs with
10% duty cycle for a short duration.
; upon wake-up, avoid using the space allocated to interrupt vector table
ORG 0000H
LJMP MAIN
; ISR for interrupt INT0
ORG 0003H
SJMP ISR
; main program
ORG 0030H
MAIN: SETB IT0 ; negative edge interrupt interrupt
MOV IE, #81H ;enable INT0 46
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

HERE: SETB P1.0 ; set P1.0 – ON PULSE


MOV R0, #90 ; P1.0 is set with 33% time period
ACALL DELAY
CLR P1.0
MOV R0, #10 ; P1.0 is cleared with 67% time period
ACALL DELAY
SJMP HERE

; ISR for INT0


ISR: MOV R5, #0FH ; create a 16 pulses in ISR
THERE: SETB P1.0
MOV R0, #10 ; P1.0 is set with 10% time period
ACALL DELAY 47
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

CLR P1.0
MOV R0, #90 ; P1.0 is cleared with 90% time period
ACALL DELAY
DJNZ R5, THERE ; exit from ISR when R5=0
RETI
DELAY: ; Delay subroutine
RPT1: MOV R1, #20 ; create a delay
RPT2: MOV R2, #100
RPT3: DJNZ R2, RPT3
DJNZ R1, RPT2
DJNZ R0, RPT1
RET
END 48
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

49
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System
Design

50
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051


•It is a monolithic CMOS device with an 8-bit analog to digital convertor.
•It has 8 channel multiplexer to interface with the microprocessor.
• The 8-bit A/D convertor uses successive approximation as the conversion technique.
•The ADC0808, ADC0809 offers high speed, high accuracy, minimal temperature
dependence, excellent long-term accuracy, repeatability, and consumes minimal
power.
•One of the main advantage of this chip is that it does not require any external zero
and full scale adjustment, only +5V DC supply is sufficient.

51
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051: Architecture

52
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051: Pin Details

53
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051:


• The device contains an 8-channel single-ended analog signal multiplexer.
•A particular input channel is selected by using the address decoder.
•The address is latched into the decoder on the low-to-high transition of the address
latch enable (ALE) signal.

54
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051: Typical Application

Potentiometer connected to IN1

01001101 = 77

V = 77 *(5000 mV/255)
V = 1.50 V
+5V

55
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051:


ALE BIT P2.4
OE BIT P2.5
SC BIT P2.6
EOC BIT P2.7
ADDR_A BIT P2.0
ADDR_B BIT P2.1
ADDR_C BIT P2.2
MYDATA EQU P1
ORG 0000H
MOV MYDATA, #0FFH ; make P1 an input
MOV P3, #00H ; make P3 an output
SETB EOC ; make EOC an input
CLR ALE ; clear ALE - output

56
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051:


CLR SOC ; clear WR - output
CLR OE ; clear OE - output
BACK: CLR ADDR_C ; C=0
CLR ADDR_B ; B=0
SETB ADDR_A ; A=1 (Select Channel 1)
ACALL DELAY ; Wait till address becomes stable
SETB ALE ; latch address
ACALL DELAY ;
SETB SOC ; Start the Conversion
ACALL DELAY ;
CLR ALE ;
CLR SOC ;
HERE1: JNB EOC, HERE1 ; wait until conversion complete
SETB OE ; enable RD
57
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

ADC0808 Interface with 8051:


ACALL DELAY ; wait
MOV A, MYDATA ; read data
MOV P3, A ; send A data to LEDs – P3
CLR OE ; clear RD for next acquisition
ACALL DELAY ; wait
SJMP BACK

DELAY: MOV R1, #0FFH //Delay Subroutine


LOOP1: NOP
NOP
NOP
DJNZ R1,LOOP1
RET
END
58
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051:


DAC 0808 is a 8-bit Digital to Analog Convertor.
 Binary weighted DAC and R/2R ladder type
 DAC0808 (8-bit) provides 256 discrete voltage or current levels of output
D7 D6 D5 D4 D3 D2 D1 D0
I out  I ref (        )
2 4 8 16 32 64 128 256
 I ref  2mA

59
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051:

60
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051:

61
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051: Square waveform generation


ORG 0000H
MOV P2, #00H ; set P2 as output port
START: MOV A, #00H ; Low logic level
MOV P2, A
ACALL DELAY
MOV A, #0FFH ; High logic level
MOV P2, A
ACALL DELAY
SJMP START

62
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051: Square waveform generation


DELAY: MOV R1, #20 //Delay Subroutine
LOOP1: MOV R2, #200
LOOP2: DJNZ R2, LOOP2
DJNZ R1, LOOP1
RET
END

63
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051: Square waveform generation

64
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051: Sawtooth waveform generation


; Intel 8051 microcontroller
; IDE: Keil version5
; Sawtooth wave generation using DAC0808 IC with 8051

ORG 0000H
MOV P2, #00H ; set P2 as output port
BACK1: MOV A, #00H ; Low logic level
BACK: MOV P2, A
INC A ; increase the voltage in steps till maximum
CJNE A, #0FFH, BACK
SJMP BACK1
END

65
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

DAC0808 Interface with 8051: Sawtooth waveform generation

66
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Electrically controllable switch


 Applications: Industrial controls, automobiles and appliances
 Types: SPST (Single pole, single throw), SPDT (Single pole, double throw),
DPST (Double pole, single throw) and DPDT (Double pole, double throw)

67
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Relay Interfacing with 8051:


; Intel 8051 microcontroller
; IDE: Keil version5
; Relay interfacing with 8051

ORG 0000H
MOV A, #00H
LABEL: MOV P2, A ; set P2 as output - Relay
ACALL DELAY
INC A
CJNE A, #10H, LABEL
MOV A, #00H
SJMP LABEL

68
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Relay Interfacing with 8051:


; Intel 8051 microcontroller
; IDE: Keil version5
; Relay interfacing with 8051

DELAY: MOV R1, #0FFH //Delay Subroutine


LOOP2: MOV R2, #0FFH
LOOP1: NOP
NOP
NOP
DJNZ R2, LOOP1
DJNZ R1, LOOP2
RET
END

69
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Relay Interfacing with 8051:


Binary count up to 0FH

70
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT
MICROPROCESSOR AND MICROCONTROLLER UNIT IV – Microcontroller Based System Design

Summary
1. Dot matrix displays
2. 16 x 2 LCD
3.Stepper Motor Interfacing
4. DC motor Interfacing
5.ADC and DAC interfacing
6.Relay Interfacing

71
Dr. V. SATHIESH KUMAR Department of Electronics Engg., MIT

You might also like