0% found this document useful (0 votes)
12 views5 pages

Microlab 9

Uploaded by

Muhammad Hamza
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)
12 views5 pages

Microlab 9

Uploaded by

Muhammad Hamza
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/ 5

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING

EXPERIMENT NO 9

Lab Title:
____________________________________________________________________
Student Name: ______________________________________ Reg. No:
_________________
Objective: ___________________________________________________________________
____________________________________________________________________________

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: __________________________ Obtained Marks: _________________________

LAB REPORT ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: _____________________ Obtained Marks: ______________________

Date: __________________________ Signature: _________________________


EXPERIMENT 09

Interfacing Keypad and LCD with PIC18F452

Objective:

 Familiarizing students to interface keypad with PIC18F452 and display results on SSD
 Familiarizing students to interface LCD with PIC18F452 and display data on the LCD
 Familiarizing students to interface a 4x3 keypad with PIC18F452 and display results on LCD

Equipment:

 Hardware:
1. PIC18F452 microcontroller
2. 4x3 Keypad
3. 16x2 LCD
4. RIMS Trainer
5. SSD
 Software:
1. mikroC Pro
2. SmartPRO 5000U
3. Proteus

Introduction:

Interfacing PIC microcontroller with keypad helps in the design of various applications which control
different processes and actions by just a key press. One can design a password protected application using
keypad digits or provide users with different options represented by different digits by using keypad
interfacing.

Keypad:

A keypad is a block of buttons set with an arrangement of digits, symbols, or alphabetical letters. A
keypad is a specially designed circuitry which works on row and column selection operation. When a key
is pressed, a row is internally shorted with a column corresponding to that digit.

A 4x3 keypad has12 individual push buttons and the configuration requires 13 input pins in order to make
them work. However, with matrix arrangement, one only needs 7 microcontroller pins to scan through the
keypad.

Scanning a Keypress:

A microcontroller can scan a keypress by following the given steps:

1. A microcontroller sets all the row lines to HIGH.


2. Then, it picks a row and sets it LOW and checks the column lines one at a time.
3. If the column connection stays HIGH, the button on the row has not been pressed.
4. If it goes LOW, the microcontroller figures which button was pressed corresponding to the
detected row and column.

LCD:

An LCD screen is an electronic display module that uses liquid crystal to produce a visible image. The
16×2 LCD display is a very basic module which displays 16 characters per line and has 2 such lines. Each
character in this LCD is displayed in a 5×8 pixel matrix. The main benefits of using this module are that
LCDs are inexpensive and easily programmable. There are no limitations in displaying custom characters,
and even animations, etc.

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user
may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is
used, the LCD will require a total of 7 data lines. If an 8-bit data bus is used, the LCD will require a total
of 11 data lines. The three control lines are EN, RS, and RW.

Interfacing PIC18F452 with LCD Using MikroC:

We define global variables before using LCD library, such that:

 LCD_D7: Data bit 7


 LCD_D6: Data bit 6
 LCD_D5: Data bit 5
 LCD_D4: Data bit 4
 LCD_RS: Register Select (data/instruction) signal pin
 LCD_EN: Enable signal pin
 LCD_D7_Direction: Direction of the Data 7 pin
 LCD_D6_Direction: Direction of the Data 6 pin
 LCD_D5_Direction: Direction of the Data 5 pin
 LCD_D4_Direction: Direction of the Data 4 pin
 LCD_RS_Direction: Direction of the Register Select pin
 LCD_EN_Direction: Direction of the Enable signal pin

The mikroC PRO for PIC provides a library for communication with Lcds (with HD44780 compliant
controllers) through the 4-bit interface. The LCD library for PIC has following important functions:

Function Syntax Description


Lcd_Init Lcd_Init(); To Initializes LCD module
Lcd_Out
Lcd_Out(1,3,"Hello!"); Prints text on LCD starting from specified position
Lcd_Out_Cp Lcd_Out_Cp("Here!"); Prints text on LCD at current cursor position
Lcd_Chr Lcd_Chr(2, 3, 'i'); Prints character on LCD at specified position
Lcd_Chr_Cp
Lcd_Chr_Cp('e'); Prints character on LCD at current cursor position
Lcd_Cmd Lcd_Cmd(_LCD_CLEAR); Sends command to LCD
Some important LCD commands along with their functions are listed below:

Command Description
_LCD_FIRST_ROW Move cursor to the 1st row
_LCD_SECOND_ROW Move cursor to the 2nd row
_LCD_CLEAR Clear display
_LCD_CURSOR_OFF Turn off cursor
_LCD_UNDERLINE_ON Underline cursor on
_LCD_BLINK_CURSOR_ON Blink cursor on
_LCD_MOVE_CURSOR_LEFT Move cursor left without changing display data RAM
_LCD_MOVE_CURSOR_RIGHT Move cursor right without changing display data RAM
_LCD_TURN_ON Turn LCD display on
_LCD_TURN_OFF Turn LCD display off
_LCD_SHIFT_LEFT Shift display left without changing display data RAM
_LCD_SHIFT_RIGHT Shift display right without changing display data RAM
Return cursor to home position, returns a shifted display to its
_LCD_RETURN_HOME
original position. Display data RAM is unaffected.

Lab Task 1:
Write a code in mikroC to display your name on a 16x2 LCD, surround it with Custom characters created
using MikroC tools and rotate it out of the screen. Use PIC18F452 and verify the results on Proteus and
hardware
Lab Task 2:
Write a code in MikroC to interface a 4x3 Keypad with PIC18F452 such that the number pressed on
keypad is displayed on LCD. Verify the results on Proteus and hardware.

Conclusion:

You might also like