0% found this document useful (0 votes)
205 views6 pages

Teacher Manual: Erts Lab IIT-Bombay

This document provides a teacher manual for a lesson on input/output interfacing with a microcontroller. It discusses why input/output is required for microcontrollers to interact with the environment. It describes input and output devices and the input/output pins and ports on the 8051 microcontroller. It covers topics like pull-up resistors, configuring pins as inputs and outputs, and provides examples of interfacing switches, reading from and writing to ports. It also provides a problem statement and solution to blink a buzzer on and off and discusses curriculum relevance.
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)
205 views6 pages

Teacher Manual: Erts Lab IIT-Bombay

This document provides a teacher manual for a lesson on input/output interfacing with a microcontroller. It discusses why input/output is required for microcontrollers to interact with the environment. It describes input and output devices and the input/output pins and ports on the 8051 microcontroller. It covers topics like pull-up resistors, configuring pins as inputs and outputs, and provides examples of interfacing switches, reading from and writing to ports. It also provides a problem statement and solution to blink a buzzer on and off and discusses curriculum relevance.
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/ 6

Teacher Manual

Topic: Input/Output Interfacing (IO Interfacing)

Prerequisites: C Programming, Basics of Embedded C, Concept of masking, Binary to


Hexadecimal and Hexadecimal to Binary conversions, Basics of microcontroller

Components Required: Firebird V robot with 8051 adaptor board, USB-Serial Converter, Serial
Cable and USB Cable

Lecture Notes:

Why Input/Output is required?

Microcontroller is just a processing device, to run any real time application it has to interact with
the environment and it can be done by connecting external hardware. The external hardware can
be any input or output device.

What does input or output device mean?


Input device provides input to the microcontroller, while output device provides a way for a
microcontroller to output data for communication with users or other devices.

For example:
Input devices: Keyboard, Switch, Sensor
Output devices: LCD, Motor, LED, Buzzer

Input/Output Pins:
 Input/Output pins are the connections available in microcontroller to connect input or
output devices.
 There are a total of 40 pins in 8051 microcontroller, where 32 pins are used as input or
output pins.
(Pin configuration is given in Teacher Manual of Introduction to Firebird V lesson)

Ports:
 Pins are divided into groups so that they can be easily accessed. There are 32 I/O pins
available in 8051; they are divided in four groups of 8 pins. Each group is termed as port.
 The four ports are named as P0, P1, P2 and P3.
 Ports are junctions to connect the input or output devices. The ports can be used as
general purpose input output (GPIO) or can be used for other purposes. For more details
you can refer to the link:
http://techknowlearn.blogspot.in/2013/06/function-of-microcontroller-8051-ports.html

Page | 1

ERTS LAB
IIT-Bombay www.e-yantra.org
Teacher Manual
Pull up Resistors:
Pull up resistors are used to ensure that inputs to the microcontroller settle at expected logic
levels if external devices are disconnected.
Logic 0 indicates pin is connected to ground and logic 1 indicates pin is connected to VCC
(Power supply).
Figure 2.1 shows the switch interfacing without pull up resistor. In this case when switch is
closed, the pin is connected to ground and hence microcontroller will read logic 0. But when
switch is open, pin is in floating state i.e., neither connected to ground nor to VCC, and hence
that microcontroller pin will go in undefined state.

Figure 2.1: Switch Interfacing without Pull up Resistor

To overcome this problem, pull up resistor is attached. As you can see in Figure 2.2, when the
switch is closed, pin is directly connected to ground and when the switch is open, pin is
connected to VCC through pull up resistor R.

Figure 2.2: Switch Interfacing with Pull up Resistor

In 8051 microcontroller, out of 4 ports, 3 ports (P1, P2 and P3) have internal pull up resistors. P0
does not have internal pull up register. As there is no internal pull up resistor in Port 0, to use P0
as general purpose input output (GPIO), external pull up resistor of 10k Ohms should be attached
on each pin as shown in Figure 2.3.

Note: For more details about internal structure of ports you can refer to IO_Port_Structure
document given in Related Resources in Resources section of IO Interfacing on Firebird V
lesson.

Page | 2

ERTS LAB
IIT-Bombay www.e-yantra.org
Teacher Manual

Figure 2.3: Port 0 with External Pull up Resistors

Input/Output Device:

 From a single port, either individual pin can be accessed or entire port (i.e. 8 pins) can
be accessed.
 We can assign only binary values to the port pins (i.e. either logic 0 or logic 1).
 First we have to configure the pin as input or output. To configure the pin as output,
logic 0 should be applied and to configure it as input, logic 1 should be applied.
 All the port pins upon RESET are configured as inputs, ready to be used as input port
pins. When the first 0 is written to a port pin, it becomes an output. To configure it as an
input, a 1 must be sent to the pin. To use any of these port pins as an input, it must be
programmed.

Examples based on the accessing ports:


Example 2.1: Configure the 7th pin of Port 0 (i.e. P0^7) as input.
Solution:

//By accessing individual pin-


P0^7 = 1; Or

//By accessing port-(using masking method)


P0 | = 0x80
[NOTE: here | (OR) operator is used for setting the 7th pin to logic 1
and status of other pins will remain unchanged.]

Example 2.2: Set Port 0 as an Input port.


Solution:
P0 = 0xFF;

Page | 3

ERTS LAB
IIT-Bombay www.e-yantra.org
Teacher Manual
Example 2.3: Configure the Port 0 as input port. Read data from Port 0 and send it to Port 1.
Solution:

int A; //define a variable A


P0 = 0xFF; //configure Port 0 as input port
A = P0; //read data from Port 0
P1 = A; //send the received data to Port 1.

Problem Statement: Program the robot to do the following:


In a continuous loop, turn on the buzzer for 500 milliseconds and turn it off for 500
milliseconds.

Interfacing buzzer in 8051:

In Firebird V, buzzer is situated on the main board and connected to the 7th pin of Port 2.
To turn off the buzzer apply logic 1 to P2^7 and to turn on apply logic 0.

Figure 2.4.: Interfacing Buzzer with Microcontroller

(Note: As port 2 has internal pull up resistor hence not gate is connected to pin so that initially
buzzer will remain in off state.)

Algorithm:

1. Start
2. Assign the port value to buzzer
3. Make buzzer on for 500 milliseconds
4. Stop buzzer for 500 milliseconds
5. End

Page | 4

ERTS LAB
IIT-Bombay www.e-yantra.org
Teacher Manual

Program Snippet:

Write program in Keil Software:


Before writing a program in keil, basic configuration is to be done. For this, watch the video on
“How to program in keil software” given on the side pane of IO interfacing on Firebird V
lesson.

Loading program in robot:


To load the program in robot, watch the video on “How to burn hex file” given on the side pane
of IO Interfacing on Firebird V lesson.

Page | 5

ERTS LAB
IIT-Bombay www.e-yantra.org
Teacher Manual

Section 4: Curriculum relevance:

Curriculum Course & Year:

Pune University:

Information Technology, SE, Processor Architecture and Interfacing

Electronics, TE, Microcontrollers

Computer, TE, Microprocessors and Microcontrollers

Instrumentation, TE, Embedded System Design

Mumbai University:

Electronics and telecommunication, TE, Microcontroller & Applications

Electronics, TE, Microcontroller & Applications

Information Technology, TE, Microcontroller and Embedded Systems

Tamil Nadu:

Computer Science, BE, Microprocessors and Microcontrollers

Electronics and Communication, BE, Microprocessors and Microcontrollers

Electronics, BE, Microprocessors and Microcontrollers

Information Technology, BE, Microprocessors and Microcontrollers

Page | 6

ERTS LAB
IIT-Bombay www.e-yantra.org

You might also like