You are on page 1of 92

UNIT 5

SYSTEM DESIGN AND APPLICATION


CONTENTS
• LCD interfacing
• Keyboard interface
• SPI protocol
• Ds1306 RTC interfacing and programming
• Relay and opto isolator
• Stepper motor interfacing
• DC motor interfacing
• PWM motor control with CCP

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 2


r
LCD

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 3


r
LCD operation

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 4


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 5
r
LCD pin Description

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 6


r
LCD pin Description

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 7


r
LCD command instruction

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 8


r
LCD address

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 9


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 10
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 11
r
KEYBOARD INTERFACTNG

(a) key press detection,


(b) key identification.
There are two ways by which the PIC 18 can
perform key press detection:
(1) the interrupt method.
(2) the scanning method.

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 12


r
interrupt method of key press detection

• The rows are connected to PORTB Low (RB3-RB0)


and
• the columns are connected to PORTB High (RB7-
RB4), which is the PORTB-Change interrupt.
• any changes on the RB7-RB4 pins will cause an
interrupt indicating a key press.

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 13


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 14
r
STEP1
• To make sure that the preceeding key has been
released, 0s are output to all rows at once, and
the columns are read and checked repeatedly
until all the columns are HIGH.
• When all columns are found to be HIGH, the
program waits for a short amount of time before
it goes to the next stage of waiting for a key to be
pressed.

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 15


r
STEP2
• To see if any key is pressed, the columns are
connected to the PORTB-Change interrupt.
• Therefore, any key press will cause an interrupt
and the microcontroller will execute the ISR.
• The ISR must do two things:
– (a) ensure that the first key press detection was not
erroneous due to spike noise,
– (b) wait 20 ms to prevent the same key press from
being interpreted as multiple key presses

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 16


r
STEP3
• To detect which row the key press belongs to, the
microcontroller grounds one row at a time, reading the
columns each time.
• If it finds that all columns are HIGH, this means that the
key press cannot belong to that row; therefore, it
grounds the next row and continues until it finds the
row the key press belongs to.
• Upon finding the row that the key press belongs to, it
sets up the starting address for the look-up table
holding the scan codes (or the ASCII value) for that row
and goes to the next stage to identify the key.
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 17
r
STEP4
• To identify/ the key press, the microcontroller
rotates the column bits, one bit at a time, into
the carry flag and checks to see if it is LOW.
• Upon finding the zero, it pulls out the ASCII code
for that key from the look-up table; otherwise, it
increments the pointer to point to the next
element of the look-up table.

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 18


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 19
r
Scanning method for key press detection
• Another method for key press detection is by scanning.
• In this method, to detect a pressed key, the microcontroller grounds
all rows by providing 0 to the output latch, then it reads the
columns.
• If the data read from the columns are equal to 1111, no key has
been pressed and the process continues until a key press is
detected.
• If one of the column bits has a zero, however, this means that a key
press has occurred.
• After a key press is detected, the microcontroller will go through
the process of identifying the key.
• Starting with the top row, the microcontroller grounds it by
providing a LOW to the first row only; then it reads the columns.
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 20
r
Scanning method for key press detection

• If the data read is all 1s, no key in that row is activated


and the process is moved to the next row.
• It grounds the next row, reads the columns, and checks
for any zero.
• This process continues until the row is identified.
• After identification of the row in which the key has
been pressed, the next task is to find out which
column the pressed key belongs to.
• This should be easy since the microcontroller knows at
any time which row and column are being accessed.
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 21
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 22
r
SPI protocol

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 23


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 24
r
SPI read and write protocol

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 25


r
Step to write data to an SPI device

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 26


r
Step to read data to an SPI device

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 27


r
Ds1306 RTC interfacing and programming

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 28


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 29
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 30
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 31
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 32
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 33
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 34
r
Register of Ds 1306

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 35


r
Address map of ds1306

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 36


r
Time and date address location and
modes

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 37


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 38
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 39
r
SSPCON1-SSP CONTROL REGISTER 1

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 40


r
SSPSTAT-SSP STATUS REGISTER

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 41


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 42
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 43
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 44
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 45
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 46
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 47
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 48
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 49
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 50
r
RELAYS

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 51


r
Optoisolator

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 52


r
Optoisolator
LED – Transmitter Photosensor receiver

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 53


r
Interfacing a Optoisolator

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 54


r
Optoisolator

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 55


r
STEPPER MOTOR

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 56


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 57
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 58
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 59
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 60
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 61
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 62
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 63
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 64
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 65
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 66
r
Unipolar

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 67


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 68
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 69
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 70
r
Controlling stepper motor via
optoisolator

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 71


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 72
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 73
r
Dc Motor Interfacing AND PWM

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 74


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 75
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 76
r
DC Motor Interfacing and PWM

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 77


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 78
r
Bidirectional control

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 79


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 80
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 81
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 82
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 83
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 84
r
DC motor control with CCP

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 85


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 86
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 87
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 88
r
DC Motor control with CCP

11/16/2023 19EECN2601-Microprocesor and Microcontrolle 89


r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 90
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 91
r
11/16/2023 19EECN2601-Microprocesor and Microcontrolle 92
r

You might also like