Lab Task 06 (Software Based Delay)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Course Code and Name: Introduction to

Mechatronics Lab (ME-332L) Date:

Lab No: 06 Course Instructor: Engr. Zia Ur Rahman

Name of Student: Semester: 6th

Registration No: Department: Mechanical Engineering

Lab Task To generate a software based exact delay of 1 msec (10-3s) using 8051 C code

1. To learn how to generate a software based delay.


Objectives 2. To familiar with 8051 C language

 STC AT89C51 Microcontroller


 Development Board
 Keil µ vision IDE
Hardware
 Prog-ISP
and Software  Wires
Requirements  LEDs
 Oscilloscope
 Proteus

Theory Microcontroller:
A microcontroller is a compact integrated circuit designed to govern a specific operation in
an embedded system. A typical microcontroller includes a processor, memory and input/output
(I/O) peripherals on a single chip.

Microcontroller 8051:
8051 microcontrollers are designed by Intel in 1981. It is an 8-bit microcontroller. It is built with
40 pins DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM storage, 2 16-bit
timers. It consists of are four parallel 8-bit ports, which are programmable as well as addressable
as per the requirement. An on-chip crystal oscillator is integrated in the microcontroller having
crystal frequency of 12 MHz.

Toggling:
Toggle refers to the act of switching from one view, setting, or function to another. It implies
that there are only two possible options and that a user is switching between them, and usually
these options are on or off for a specific preference.

Prepared by Tanveer Uz Zaman


Diagram:

Fig. Development Board with AT89C51 Microcontroller

Switch input Delay (in seconds)


000 1 second
001 2 second
010 4 second
011 6 second
100 8 second
101 10 second
110 12 second
111 14 second

Fig. Description of Functionality

Prepared by Tanveer Uz Zaman


Procedure  First we have to write a code in C language in keil Software.
 That code will work such a way that when code is uploaded the LED connected to port
P1.4 will toggle after exact delay of 1 msec (10-6).
 That delay will be generated through loops (software base delay).
 After that we have to create a hex file of that code.
 On the basis of that code we have to make a connection of STC AT89C51 Microcontroller
with LED as shown in the figure below.
 The hex file will be uploaded into STC AT89C51 Microcontroller through Prog-ISP.
 During uploading the power of the board should be turn ON.
 When code is successfully uploaded we will see that LED will toggle after exact delay of
1 msec.
 We can verify that delay by connecting any pin of port 1 with Oscilloscope.
 Oscilloscope will show the timing diagram of the signal in which we can clearly see or
analyze the signal that for how much time that signal is in logic or vice versa.

Connection Diagram:

Fig. Connection Diagram

Prepared by Tanveer Uz Zaman


Programming Write an 8051 C Code to generate a software based exact delay of 1 msec (10-3s).
Code

Results and
Conclusions

Prepared by Tanveer Uz Zaman

You might also like