Sunteți pe pagina 1din 18

EMBEDDED SYSTEM

An

electronic device with a programmable component which is not easily accessible to user is called Embedded System. Today, Embedded Systems are a part of human lives. We are surrounded and being helped by this embedded systems in our day to day activities. Fields where embedded systems are being used are Mobile communication, mobile computing devices, home appliances, music Systems, automobiles etc. Often the terms microcontroller and microprocessor are confusing. A microcontroller is actually has more features than microprocessors. Besides the processor it also has I/O ports, internal timers/counters, internal RAM and ROM. Microcontrollers are programmed using assembly and high level languages. Assembly languages are controller specific and machine friendly but the program written in assembly languages are quite lengthy. At the same time, high level languages such as C and Java are also being used to program microcontrollers. High level languages are user friendly and eliminate redundancy

from the programs written in assembly languages. Despite its relatively old age, the 8051 is one of the most popular microcontrollers in use today. Many derivative microcontrollers have since been developed that are based on--and compatible with--the 8051. Thus, the ability to program an 8051 is an important skill for anyone who plans to develop products that will take advantage of microcontrollers. The 8051 has three very general types of memory. To effectively program the 8051 it is necessary to have a basic understanding of these memory types.

Properties of the embedded system:


Event driven system Microcontroller/ microprocessor based Application specific Closed system Battery operated Portable

Types of Embedded System:

SMALL SCALE: 8 to 16 bit micro processor


or micro controllers are used in this category. Programming languages used are Assembly and C.

LARGE

32 to 64 bit micro processor or micro controllers are used in this category. Programming languages used are Assembly, C, J2ME and VC++.

SCALE:

SOPHISTICATED:

32 to 64 bit micro processor or micro controllers are used in this category. It is supported by RTOS (Real Time Operating System).

MICROCONTROLLER 8051

It is a device in which CPU, input-output ports,


memory, timer, counter all are mounted on a single chip. We are using 8051 family of microcontroller. The memory types are illustrated in the following graphic. They are: On-Chip Memory, External Code Memory, and External RAM.

ALU CU

RAM 128 bytes.

ROM 4KB

I/O ports: 4 parallel 1 serial.

Timers /Counters 2-16 bit

8051 Architecture:

INPUT/OUTPUT PORTS: There are four I/O


ports in 8051 micro controller named as P0, P1, P2, P3.

P0: Also used as address data multiplexed


lines.

P1: It is used as I/O ports and termed as


single purpose port.

P2: Also used as higher order byte address


lines.

P3: The pins of this port are used as Timer


pins, interrupt pins, read write pins etc.

Program Counter (PC): It points the location


of the program for the CPU. It instructs CPU from where to fetch instruction and decode it, CPU will generate necessary signal due to which it connected at ROMs 1H address.

Stack Pointer: It holds the address of the

memory location where stack is located. Stack is automatically used in microcontroller whenever a subroutine is called. The location at which controller has to return after execution of subroutine is stored in stack. The total range of the RAM is from 00H to 7FH. Within this bit addressable RAM is there which ranges from 20H to 2FH.

Addressing Modes

It

is a method of accessing data from a location. There are five addressing modes supported by 8051. Immediate Addressing Mode Register Addressing Mode Direct Addressing Mode Register indirect Addressing Mode Indexed Addressing Mode

Pin Diagram of 8051 It


is a 40 pin IC. There are four parallel ports, 32 Bi-directional I/O pins. Except port 1 all other three ports have dual role. Either they can be used as I/O ports or can be used for some other special functions.

Timer/Counter

Whenever

you need to control any event timer is required. As the timer expires, flag are set/reset. Thus in microcontroller flags are used to indicate that any event is over. There two timers T0, T1. Both are 16 bit timers and there maximum values are FFFFH.

Stop bit

TH0

TL0

Flag bit
TF0 TR0

T0:

T1:

TH1

TL1

TF1

TR1

Where TH0 and TH1 are the higher byte of T0 and T1 Where TL0 and TL1 are the lower byte of T0 and T1.

TMOD Register:

LCD Interfacing
LCD Backgorund
Frequently, an 8051 program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively. Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the 8051) and communicates directly with the LCD.

44780 BACKGROUND
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 (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus). The three control lines are referred to as EN, RS, and RW. The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter "T" on the screen you would set RS high. The RW line is the "Read/Write" control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are write commands--so RW will almost always be low. Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.

ADC Interfacing
ADC0804 Pinout and Typical Connections

As shown in the typica circuit, ADC0804 can be interfaced with any microcontroller. You need a minimum of 11 pins to interface ADC0804, eight for data pins and 3 for control pins. As shown in the typical circuit the chip select pin can be made low if you are not using the microcontroller port for any other peripheral (multiplexing). There is a universal rule to find out how to use an IC. All you need is the datasheet of the IC you are working with and take a look at the timing diagram of the IC which shows how to send the data, which signal to assert and at what time the signal should be made high or low etc. Note: Keep this in mind that whenever you are working with an IC and you want to know how to communicate with that IC, then simply look into the timing diagram of that IC from its datasheet. It gives you complete information that you need regarding the communication of IC.

The above timing diagrams are from ADC0804 datasheet. The first diagram (FIGURE 10A) shows how to start a conversion. Also you can see which signals are to be asserted and at what time to start a conversion. So looking into the timing diagram FIGURE 10A. We note down the steps or say the order in which signals are to be asserted to start a conversion of ADC. As we have decided to make Chip select pin as low so we need not to bother about the CS signal in the timing diagram. Below steps are for starting an ADC conversion. I am also including CS signal to give you a clear picture. While programming we will not use this signal. 1. 2. 3. 4. Make chip select (CS) signal low. Make write (WR) signal low. Make chip select (CS) high. Wait for INTR pin to go low (means conversion ends).

Once the conversion in ADC is done, the data is available in the output latch of the ADC. Looking at the FIGURE 10B which shows the timing diagram of how to read the converted value from the output latch of the ADC. Data of the new conversion is only available for reading after ADC0804 made INTR pin low or say when the conversion is over. Below are the steps to read output from the ADC0804. 1. 2. 3. 4. 5. Make chip select (CS) pin low. Make read (RD) signal low. Read the data from port where ADC is connected. Make read (RD) signal high. Make chip select (CS) high.

PROGRAMMS:

Delay of 1 sec.:

ORG 00H MOVR2, #8 H3: MOVR1, #250 H2: MOVR0, #250 H1: DJNZR0, H1 DJNZR1, H2

DJNZR2, H3 END

To switch ON & OFF all leds:


ORG 00H BACK: MOV P0, #0FFH ACALL DELAY MOV P0, #00H ACALL DELAY SJMP BACK END

To generate pulse at P2 port for 1 sec. when switch at P1 port is ON.


ORG 00H CLR P2.0 MOV P1, #0FFH MOV TMOD, #02H C0: JB P1.0, C1 SJMP T50 C1: JB P1.1, C2 SJMP T100 C2: JB P1.2, C3 SJMP T150 C3: JB P1.3, C0 SJMP T200 T50: MOV TH0, #000H B1: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY

SJMP B1

T100: MOV TH0, #9BH B2: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY SJMP B2 T150: MOV TH0, #69H B3: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY SJMP B3 T200: MOV TH0, #37H B4: SETB P2.0 ACALL DELAY CLR P2.0 ACALL DELAY SJMP B4 DELAY: SETB TR0 WAIT: JNB TF0, WAIT CLR TR0 CLR TF0 RET END

Counting program:
ORG 00H MOV TMOD, #50H RESTART: MOV TH1, #00H MOV TL1, #00H

SETB TR1

KG: MOV P1, TH1 MOV P0, TL1 JNB TF1, KG CLR TR1 CLR TF1 SJMP RESTART END

When interrupt is there in between the flow of data then Led must glow for 1 sec.:

ORG 00H LJMP MAIN ORG 003H SETB P0.0 ACALL DELAY CLR P0.0 RETI ORG 0030H MAIN: MOV IE, #81H MOV P1, #0FFH BACK: MOV A, P1 MOV P2, A SJMP BACK DELAY: MOVR2, #8 H3: MOVR1, #250 H2: MOVR0, #250 H1: DJNZR0, H1

DJNZR1, H2 DJNZR2, H3 END


THE ULTIMATE GAINS OF THE TRAINING: This training had been some what unforgettable for all of us. Beyond expectation were the words on the mind of each of the trainees, as far as the benefits of this training are concerned. If every one of us starts writing about the gains of the training the list would be somewhat too long for the comfort of anyone who wants to go through them. However, the main gains are as listed below: 1) COMPONENT IDENTIFICATION: The first step of the training started with our introduction to the family of electronic components. This introduction had the motto of making us understand the components in a better way. The difference in the working, build and connections of different diodes, resistors, capacitors, bridges, regulators, etc as well as finding of their respective values from the codes written over them, is one of the most basic step of entering the world of electronics. Thats why it was great to start from the baseline aiming at the top. 2) PCB DESIGNING AND FABRICATION: Next in the training scheme came the very new experience of PCB designing and fabrication on our own. Firstly, we started with the simple task of making a power supply on a PCB, drawing the tracks of circuit by hand in order to better understand the proper positioning of components on the PCB, track width, and distance between the pins of a single component. Then, we moved to the more advanced portion of PCB designing using the software. Software like Express PCB and Eagle were quite handy in designing the PCB. The software Multisim was also introduced to us, which was quite interesting as it helped to check and realize an electronic circuit without actually making it. The trainees were taught the very basic steps of using these software to design ones PCB and it really became a fun experience to use them. 3) MINOR PROJECT SELECTION AND GUIDANCE The selection of a unique, realizable and comprehensive project was one of the most tedious job for us. Techoz helped us through this problem. We were furnished with concepts of hundreds of such projects giving us enough alternatives to choose from. As the choosing of project was over, its implementation was made more comfortable with the incredible guidance from our Guides. From PCB Designing and its fabrication to the shielding and packing of our projects Techoz was enough helpful to be grateful. 4) INTRODUCTION TO MICROCONTROLLER AND PROGRAMMING:

Today the simplest of the equipments have microcontroller inside them. From mobiles to computers, the microcontrollers have reached everywhere. Thats why the Microcontroller class was one of the most precious of the gains we had. Here we studied the microcontrollers, particularly AT89C51 from the Atmel family. In addition to this, we were taught the assembly language programming of this microcontroller, which we practically tested on the computer using the software Keil. Also we learnt to program the microcontroller by interfacing it to the computer. Thus, looking at the shortness of the training period we had a comprehensive know-how of the AT89C51.

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