Teacher Manual: Erts Lab IIT-Bombay
Teacher Manual: Erts Lab IIT-Bombay
Components Required: Firebird V robot with 8051 adaptor board, USB-Serial Converter, Serial
Cable and USB Cable
Lecture Notes:
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.
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.
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.
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
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.
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:
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.
(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:
Page | 5
ERTS LAB
IIT-Bombay www.e-yantra.org
Teacher Manual
Pune University:
Mumbai University:
Tamil Nadu:
Page | 6
ERTS LAB
IIT-Bombay www.e-yantra.org