Sunteți pe pagina 1din 6

Faculty of Electrical & Automation Engineering Technology

TATi University College


Embedded System (BMT 4033) Lab Report

Name

ZUL IMAN BIN JOHARI

Name

Student ID

13B09109

Student
ID

Title of
Experiment

INTRODUCTION TO 8051 COMPILER AND SIMULATOR

Lecturer

MR. TARMIZI

Date of Experiment Performed

Marks Distribution

Marks

Title (2 marks)
Abstract (10 marks)
Objective and introduction (15 marks)
Experimental methods (20 marks)
Results and discussion (30 marks)
Conclusions (10 marks)
References (3 marks)
Related Appendices (5 marks)
Report format (5 marks)
Late Submission (1 marks deduction per minutes)
Total Mark (100%)
Comments:

I declare that this assessment item is my own work, except where acknowledged, and has not been submitted for academic credit elsewhere,
and acknowledge that the assessor of this item may, for the purpose of assessing this item:

Signature of student: ____________________

Date:___________________

INTRODUCTION TO 8051 COMPILER AND


SIMULATOR
ZUL IMAN BIN JOHARI, (13B09109),
Abstract this laboratory activity, there are 3 task of basic introduction of 8051 compiler and simulator. Task 1 a
student will learn how to build a hex file based of given attachment. Task 2, a student will be given a circuit to be
able build a circuit using simulator program. Finally, students must know how to load the .hex file into simulator then
verify the result of the assembly program.
I.
A.

OBJECTIVE AND INTRODUCTION

Objective
To familiar with 8051 compiler
To familiar with 8051 simulator program.
To test the 8051 system and its output using circuit simulator.

B. Introduction
A micro-controller can be compared to a small stand alone computer, it is a very powerful device, which is
capable of executing a series of pre-programmed tasks and interacting with other hardware devices. Being packed in
a tiny integrated circuit (IC) whose size and weight is usually negligible, it is becoming the perfect controller for
robots or any machines requiring some kind of intelligent automation. A single microcontroller can be sufficient to
control a small mobile robot, an automatic washer machine or a security system. Any microcontroller contains a
memory to store the program to be executed, and a number of input/output lines that can be used to interact with
other devices, like reading the state of a sensor or controlling a motor.
Nowadays, microcontrollers are so cheap and easily available that it is common to use them instead of simple
logic circuits like counters for the sole purpose of gaining some design flexibility and saving some space. Some
machines and robots will even rely on a multitude of microcontrollers, each one dedicated to a certain task. Most
recent microcontrollers are In System Programmable, meaning that you can modify the program being executed,
without removing the microcontroller from its place.
Today, microcontrollers are an indispensable tool for the robotics hobbyist as well as for the engineer. Starting in
this field can be a little difficult, because you usually cant understand how everything works inside that integrated
circuit, so you have to study the system gradually, a small part at a time, until you can figure out the whole image and
understand how the system works.

II. EXPERIMENTAL METHODS


A. Review Stage
1. Open 8051 compiler Keil uVision3.
2.

On toolbar window, click Project select New uVision Project.

3. Create a new folder to place a project file in there.


4. After that, there a small window to create a new project, the student must give a title of project followed by C
language example LAB1.CAfterhat, click save button.
5. Now in database section, students must choose ATMEL then select AT89C51 click OK. This section
require a type of IC we select to program.
6. On the right side, there are project workspace where can be found a project file that we save before. Extract
that file to folder Source Group 1.
7. Now , on the command window, build a C-Language as given:
#include<reg51.h>
#define keypad P1 //define keypad port
sbit DA=P1^7; //define DA port
unsigned char keyread();
void lcdwrite(unsigned char out);
void delay(unsigned int dly);
void cmdwrt(unsigned char cmd);
void datawrt(unsigned char dat);
void lcdstart(void);
void strwrt(unsigned char *str,unsigned char size);
sbit rs=P2^0; //declare lcd port
sbit rw=P2^1; //declare lcd port
sbit e=P2^2; //declare lcd port
#define lcddata P3 //declare lcd port
code unsigned char word1[]="selamat";
code unsigned char word2[]="datang";
void main()
{ unsigned char key;
lcdstart();
while(1)
{ key=keyread(); //datawrt(key);
if(key=='/')
{ cmdwrt(0x01); // clr lcd
cmdwrt(0x82); // set pos
strwrt(word1,sizeof(word1)); //write word
}
else if(key=='O')
{ cmdwrt(0x01);//clr lcd
}
else
{ cmdwrt(0xc5); // set pos

datawrt(key);
}
}
}
unsigned char keyread() //keypad read subprogram
{ code unsigned char pattern[]={"789/456*123-O0=+"};
unsigned char key; //declare variable
while(DA==0); // wait DA high,,, key pressed
key=keypad&0x0f;
while(DA==1); //wait key depressed
return pattern[key];
}
void lcdwrite(unsigned char out)
{ rw=0;
e=1;
delay(200);
lcddata=out;
delay(200);
e=0;
}
void delay(unsigned int dly)
{ unsigned int i;
for (i=0;i<dly;i++);
}
void cmdwrt(unsigned char cmd)
{ rs=0;
lcdwrite(cmd);
}
void datawrt(unsigned char dat)
{ rs=1;
lcdwrite(dat);
}
void lcdstart(void)
{ cmdwrt(0x38);
cmdwrt(0x0c);
cmdwrt(0x01);
cmdwrt(0x06);
}
void strwrt(unsigned char *str,unsigned char size)
{ unsigned char i;
for (i=0;i<(size-1);i++)
{ datawrt(str[i]);
}
}

8. Run a program compile to determine whether any error or warning on this program.
9. Build a hex. File for this program by select Flash from toolbar window and chose Configure Flash Tools..

10. On option click on Output and tick on Create HEX File column.
11. After that, open a program simulator PROTEUS , Build a circuit as given in attachment 2.
12. When a circuit done, double-clicking on IC AT89C51 and extract a project hex. File by filling on Program
File column.
13. Simulate a circuit and observe a output on LCD display.
III. RESULTS AND DISCUSSION

Figure 1: Circuits display a program results.


As a result, we can see a relationship between 8051 compiler and circuit simulator program .From this lab we can
understand the 8051 program can be apply to circuit simulator program directly. Its easily to troubleshoot or see
some program results without applying on hardware. This may be the first step to create some project before applying
on real hardware.
IV. CONCLUSION

In conclusion, this activity shows a student how easily build a project by using 8051 compiler and
PROTEUS circuit simulator. Students are able to familiar with 8051 compiler and circuit simulator
program by complete 3 activities.

S-ar putea să vă placă și