Embedded System
Embedded System
Keil was founded in 1982 by Gnter and Reinhard Keil, initially as a German
GbR. In April 1985 the company was converted to Keil Elektronik GmbH to
market add-on products for the development tools provided by many of the
silicon vendors. Keil implemented the first C compiler designed from the
ground-up specifically for the 8051 microcontroller.
Keil Micro-Vision is a free software which solves many of the pain points for
an embedded program developer. This software is an integrated
development environment (IDE), which integrated a text editor to write
programs, a compiler and it will convert your source code to hex files too.
Integrated make facility for assembling, compiling, and linking your embedded
Applications.
simulator,
Advanced GDI interface for software debugging in the target hardware and for
Flash programming utility for downloading the application program into Flash
ROM,
The Micro-Vision IDE offers numerous features and advantages that help you
quickly and successfully develop embedded applications. They are easy to
use and are guaranteed to help you achieve your design goals.
Concept of compiler:
A cross compiler is similar to the compilers but we write a program for the
target processor (like 8051 and its derivatives) on the host processors (like
computer of x86). It
means being in one environment you are writing a code for another
environment is called cross development. And the compiler used for cross
development is called cross compiler.
Project Manager
Simulator
Debugger
Keil Software provides you with software development tools for the 8051
family of microcontrollers. With these tools, you can generate embedded
applications for the multitude of 8051 derivatives. Keil provides following
tools for 8051 development.
Source-Level Debugger/Simulator,
The keil 8051 tool kit includes three main tools, assembler, compiler and
linker.
A linker is used to create an absolute object module suitable for your circuit
emulator.
To open keil software click on start menu then program and then select keil4. Or select it
from desktop the following icon.
Project work space window / tree manue: is for showing all the related
files connected with your project.
Editing window: Is the place where you will edit the code
Output window/ Build window: Will show the output when you compile or
build or run your project.
1- Click on project menu and select new project. You will be asked to create
new project in specific directory
3- In that window we name the project Project1 and save it on our desired
location (
) from the save Button.
4- Again a new window will open named with Select device for target
Target1.
5- Select the part you will be using to test. As we will use the Atmel
Semiconductor part 89S51 or 89C51.
6- Double Click on the Atmel Semiconductor.
8- Click OK.
The new window will open and change file type to Asm Source
File (*.c).
Select project1.c.
Click add button.
Click close Button.
Expand the Source Group 1 in the Tree menu to ensure that the file was
added to the project.
Change Xtal (MHz) from 33.0 to11.0592 or 12MHz. Change the code ROM
size small: program 2K or less
Click OK Button.
Debugging of program:-
Click OK
The Keil Debugger will start running.
A small window will appear and this will show the port and its pins like ,
Now select the Step option from the above Tab OR changes the step
one line with the help of key F11.
Introduction to Proteus.
Proteus PCB design combines the ISIS schematic capture and ARES PCB
layout programs to provide a powerful, integrated and easy to use suite of
tools for professional PCB Design. All Proteus PCB design products include an
integrated shape based autorouter and a basic SPICE simulation capability
as standard. More advanced routing modes are included in Proteus PCB
Design Level 2 and higher whilst simulation capabilities can be enhanced by
purchasing the Advanced Simulation option and/or micro-controller
simulation capabilities.
How to make project in proteous software:1. Click on the following icon from start manue or desktop.
Place cursor on microcontroller 89S51 and double click it. A window will open, on program file
option click on folder icon
and add directory of your hex
file(Keil\C51\Examples\HELLO\project1.hex) where you create it on Keil.
EXPERIMENT NO:02
Up And Down Counters.
Objective:What are counters
Types of counters.
Components:-
Vern board.
89S51 microcontroller
8 LEDs
8 resistors (330)
Connecting wires
Theory:Counters.
Counters can be defined in two ways.
1-In digital logic and computing: A counter is a digital sequential logic device that will go
through a certain predefined states (for example counting up or down) based on the application
of the input pulses. They are utilized in almost all computers and digital electronics systems
Types of counters.
Asynchronous (ripple) counter changing state bits are used as clocks to subsequent state flipflops.
Synchronous counter all state bits change under control of a single clock.
Incoming and outgoing cars are counted to switch the FULL and VACANT signs.
Extra leader sheet that is now wound is counted by a rotary encoder and a color
detecting sensor.
Procedure:Write the c codes of up and down counters in keil software , save it and creat hex files of both.
Make the circuit involving microcontroller and leds in proteus to show the results.
Now link the up and down counters hex files with proteus and verify the results.
for(;;)
P2=0x03;
for(z=0;z<=45000;z++);
P2=0x04;
for(z=0;z<=45000;z++);
P2=0x05;
for(z=0;z<=45000;z++);
P2=0x06;
for(z=0;z<=45000;z++);
P2=0x07;
for(z=0;z<=45000;z++);
P2=0x08;
for(z=0;z<=45000;z++);
P2=0x09;
for(z=0;z<=45000;z++);
Down counter.
# include <reg51.h> void main (void)
for(z=0;z<=45000;z++)
P2=0xFF;
for(z=0;z<=45000;z++)
P2=0xFE;
for(z=0;z<=45000;z++)
P2=0xFD;
for(z=0;z<=45000;z++)
P2=0xFC;
for(z=0;z<=45000;z++)
P2=0xFB;
for(z=0;z<=45000;z++)
P2=0xFA;
for(z=0;z<=45000;z++)
P2=0xF9;
for(z=0;z<=45000;z++)
P2=0xF8;
for(z=0;z<=45000;z++)
P2=0xF7;
for(z=0;z<=45000;z++)
P2=0xF6;
EXPERIMENT NO:03
Introduction to test bench:
Objective.
What is test bench?
Test bench in our case is of vero board and many components are soldered
on it. A test bench on which microcontroller is installed as a heart of test
bench and other components are also installed which are derived by the
controller. The controller is programmed and through this we see the results
on specific circuitry of test bench. The test bench in our case is given as.
Fig.Test bench.
Servo motor.
Stepper motor.
Description of a test bench:A test bench have different portions on it and given as.
0-On/Off switch.
Through this switch we can turn supply ON and OFF in the mentioned position.
Moreover there are also points of positive supply and ground through which we
can take supply and ground at our desired point with the help of jumper wires.
Power socket has two wires one is positive while the other one is of negative.
1.LEDs Panel.
It is of 8 LEDs panel. These are used for counters and checking the results. In this
panel each LED contain a resistor in series so that it can be protected. These LEDs
are operated in the low logic. These are shown as.
2-H Bridge:
Past a circuit here from register The test bench circuits points configurations are:
3-Reed switch.
When magnetic came near reed switch it becomes on. It will act like a switch.
4-Microcontroller.
5-L293:
6-heat sensor
(thermistors)
Through the given table we make the setting of 7447 pins and observed the
counting from 0 to 9. Connections of 7447 with 7segment is already build in the
circuit.
Here we can connect our servo and according to pin configuration of servo supply
, ground and signal can be given through female headers.
9-Humidity sensor.
Humidity sensor is placed in the female headers and other same number of
female header is connected with it by which we can give supply and ground to it
and gets output from it.
10-LM35
When light level increases from fixed intensity level logic from LDR changes and
we can indicate it by relay.
12-Relay.
13-Smoke
sensor:
EXPERIMENT NO:04
Introduction to C programming in 8051:
Objectives.
What is programming. (Assembly language and C language).
Data types.
8051 extensions.
Time delays.
I/O programming.
Logical operators.
Interrupts.
Serial communication.
Programming:
Assembly language:
C language:
Data Types:
Following data types are used in C language. Their ranges are also given in
this table 1-1.
It is 8-bit bi-directional I/O port. It is bit/ byte addressable. When logic '1' is
written into port latch then it works as input mode. It functions as simply I/O
port and it does not have any alternative function.
P3.0-RxD:
P3.1-TxD:
It is O/P signal of serial port. Through this signal data is transmitted.
P3.2- (INT0):
P3.3-(INT1):
P3.4-T0:
P3.5-T1:
P3.6-[WR(bar)]:
It is active low write O/P control signal. During External RAM (Data
memory) access it is generated by microcontroller. when [WR(bar)]=0,
then performs write operation.
P3.7-[RD(bar)]:
It is active low read O/P control signal. During External RAM (Data
memory) access it is generated by microcontroller. when [RD(bar)]=0,
then performs read operation from external RAM.
(Figure 1.1)
These are two I/P line for on-chip oscillator and clock generator circuit. A
resonant network as quartz crystal is connected between these two pin.
8051 microcontroller also drives from external clock, then XTAL2 is used to
drive 8051 from external clock and XTAL1 should be grounded.
[EA(bar)]/VPP:
It is and active low I/P to 8051 microcontroller. when (EA)= 0, then 8051
microcontroller access from external program memory (ROM) only. When
(EA) = 1, then it access internal and external program memories (ROMS).
[PSEN(bar)]:
ALE:
Address latch enable: It is active high O/P signal. When it goes high, external
address latch becomes enabling and lower address of external memory (RAM
or ROM) latched into it. Thus it separates A0-A7 address from AD0-AD7. It
provides properly timed signal to latch lower byte address. The ALE is
activated twice in every machine cycle. If external RAM & ROM is not
accessed, then ALE is activated at constant rate of 1/6 oscillator frequency,
which can be used as a clock pulses for driving external devices.
RESET:
It is active high I/P signal. It should be maintained high for at least two
machine cycle while oscillator is running then 8051 microcontroller resets.
Sbit:
The sbit keyword is a widely used 8051 C data type designed specifically to
access single bit addressable registers. It allows access to the single bit of
the SFR register.
The bit data type allows access to single bits of a bit addressable memory
spaces 20-2FH. The sbit data type is used for bit addressable SFRs and the
bit data type is used for the bit addressable section of RAM space 20-2FH.
Time Delay:
We see in fig 1.1 that ports P0-P3 byte are accessible. We use the P0-P3
labels as defined in the 8051/52 header file.
Bit-addressable I/O programming:
The I/O ports of P0-P3 are bit-addressable. We can access a single bit without
disturbing the rest of the port. We use the sbit data type to access a single
bit of P0-P3. P1^7 indicates P1.7. When using this method, we need to
include the reg51.h file.
One of the most important and powerful features of the C language is the
ability to perform bit manipulation. They are listed in table 1-2.
Bitwise operation in C:
(Table 1-2)
There are two bit-wise shift operations in C: (1) shift right (>>), and (2) shift
left(<<) Their format in C is as follow:
Data >> number of bits to be shifted right
Data << number of bits to be shifted left
C Compilers are available for almost all embedded devices in use today, and there
is a large pool of experienced C programmers.
It is fairly efficient
Interrupts.
the normal flow of instruction execution usually generated by hardware devices external to the
CPU
serial communication:
EXPERIMENT NO:05
Verum board.
89S51 microcontroller.
Panel of 8 LEDs
jumper wires
Theory:Procedure:Write the c codes of port toggle and bit toggle in keil software ,
Now link the hex files with proteus and verify the results.
EXPERIMENT NO:06
Procedure.
Verum board.
89S51 microcontroller..
jumper wires
Theory:-
Procedure:Write the c codes of left shift and right shift in keil software ,
Now link the left and right shift hex files with proteus and verify the results.
EXPERIMENT NO:07
Types of 7 segments.
Verum board.
89S51 microcontroller.
7 segment display.
74LS47 IC
jumper wires
7 segment:
Types of 7 segments:
In the common cathode display, all the cathode connections of the LED
segments are joined together to logic 0 or ground. The individual segments
are illuminated by application of a HIGH, or logic 1 signal via a current
limiting resistor to forward bias the individual Anode terminals (a-g).
In the common anode display, all the anode connections of the LED
segments are joined together to logic 1. The individual segments are
illuminated by applying a ground, logic 0 or LOW signal via a suitable
current limiting resistor to the Cathode of the particular segment (a-g).
Make the circuit involving microcontroller and 7 segments in proteus to show the
results.
Now link the 7 segment hex files with proteus and verify the results.
EXPERIMENT NO:08
Interfacing of dc motor with microcontroller 8051:
Objective:What is dc motor?
Verum board.
89S51 microcontroller.
Opto-isolator ILD74
Diode 1N4004
Capacitor (0.1Uf)
jumper wires
Theory:DC Motor:
The DC Motor is the most commonly used actuator for producing continuous
movement and whose speed of rotation can easily be controlled, making
them ideal for use in applications were speed control, servo type control,
and/or positioning is required. A DC motor consists of two parts, a Stator
which is the stationary part and a Rotor which is the rotating part. The
result is that there are basically three types of DC Motor available.
Brushed Motor:
This type of motor produces a magnetic field in a wound rotor (the part that
rotates) by passing an electrical current through a commutator and carbon
brush assembly, hence the term
Brushless Motor:
This type of motor produce a magnetic field in the rotor by using permanent
magnets attached to it and commutation is achieved electronically. They are
generally smaller but more expensive than conventional brushed type DC
motors because they use Hall effect switches in the stator to produce the
required stator field rotational sequence but they have better torque/speed
characteristics, are more efficient and have a longer operating life than
equivalent brushed types.
Servo Motor:
Optoisolator ILD74:
Figure 1
While controlling the speed of a DC motor with a single transistor has many
advantages it also has one main disadvantage, the direction of rotation is
always the same, its a Unidirectional circuit. In many applications we need
to operate the motor in both directions forward and back.
Make the circuit involving microcontroller and dc motor in proteus to show the results.
Connect pin1 of Optoisolator ILD74 to 5V through 330 resistor and its pin 2 to P2^0 of
Microcontroller.
Connect pin 4 of Optoisolator ILD74 to base of Darlington transistor TIP120 while its pin
5 is connected to 12V.
Now link dc motor hex files with proteus and verify the results.
EXPERIMENT NO:09
Vern board.
89S51 microcontroller
ADC0804 IC
Potentiometer (10k)
Capacitor (150pF)
Connecting wires
ADC0804:
ADC0804 is one of the most commonly used analog to digital converter IC. In
many applications it is required to convert the output of the sensor, which is
analogue in nature to a digital form. The data in digital format can then be
utilized for further processing by the digital processors. Typical applications
include sound processing, temperature processing etc. This circuit
The time taken by the ADC to convert analog data into digital form is
dependent on the frequency of clock source. ADC0804 can be given clock
from external source. It also has an internal clock. However the conversion
time cannot be more than110us. To use the internal clock a capacitor and
resistor is connected to pin 19 and 4 as shown in the circuit diagram. The
frequency is given by the relation f= 1/ (1.1RC). The circuit uses a resistance
of 10k and a capacitor of 150pF to generate clock for ADC0804. Vin, which is
the input pin, is connected to a preset to provide analog input.
generates a code for each voltage range. Direct conversion is very fast,
capable of gigahertz sampling rates, but usually has only 8 bits of resolution
N
Equip Microcontroller 89S51 with the external clock and reset circuitry.
Connect P2^3, P2^4 and P2^5 of 89S51 to RD pin (to enable read operation),
WR pin (to enable write operation) and INTR pin of ADC respectively. Ground
pins 1, 7, 8 and 10 of ADC0804.
Now make CS=0 and send a low to high pulse to WR pin to start the conversion.
Keep checking the INTR pin. INTR will be 1 if conversion is not finished and INTR will be
0 if conversion is finished
Make CS=0 and send a high to low pulse to RD pin to read the data from the ADC.
EXPERIMENT NO:10
Modes of LCD.
Vern board.
89S51 microcontroller
LCD
Connecting wires
Theory:Short for liquid crystal display, a type of display used in digital watches and
many portable computers. LCD displays utilize two sheets of polarizing
material with a liquid crystal solution between them. An electric current
passed through the liquid causes the crystals to align so that light cannot
pass through them. Each crystal, therefore, is like a shutter, either allowing
light to pass through or blocking the light.
Monochrome LCD images usually appear as blue or dark gray images on top
of a grayish-white background. Color LCD displays use two basic techniques
for producing color: Passive matrix is the less expensive of the two
technologies.
Modes of LCDS:
There are many different LCD modes. These include:
FSTN - Film-compensated Super Twisted Nematic - High-contrast, duochromatic, low power use, mid cost
DSTN - Double-layer Super Twisted Nematic - Super High-contrast, fullcolor, mid power use, high cost
TFT - Thin Film Transistor - Highest contrast, best color, mid power use,
highest cost
Backlighting:
There are three types of backlighting for LCD displays: LED (Light Emitting
Diode), CCFL (Cold Cathode Fluorescent Lamp), and EL (Electro-Luminescent).
LED backlighting offers both monochromatic and color displays and is not
very expensive, but it uses the most power and has only a middling quality as
far as contrast and color rendering.
CCFL backlighting uses less power, lasts longer and has higher contrast and
color rendering, but it is extremely expensive.
EL backlighting uses even less power, is very cheap, but doesn't last that long
and is poor to middling in color and contrast quality.
Make the circuit involving microcontroller and LCD in proteus to show the results.
Now link the LCD interfacing hex files with proteus and verify the results.
EXPERIMENT NO:11
Verum board.
89S51 microcontroller.
2 Resistors (330)
Buzzer
LED
jumper wires
Theory:-
They are often connected with a buzzer or siren. They have a capability of
causing a fight or flight response in humans. In this condition a person will
panic and either flee the perceived danger or attempt to eliminate it. This
buzzer makes sound when the force is applied to the force sensitive resistor.
This acts as an alarm system and it is connected through the RF module so it
can be called as wireless alarm system. When some force is applied to the
force sensitive resistor the signal is transmitted to the receiver and the
buzzer makes sound which serves as an alarm. The alarm blows for 2 sec
and then it is off.
Make the circuit involving microcontroller and buzzer in proteus to show the results.
Now link the 7 segment hex files with proteus and verify the results.
When the input is connected to low logic, led will be ON giving the indication of
correct alarm.
When the input is connected to high logic, buzzer will be ON giving the indication of
wrong alarm.
EXPERIMENT NO:12
Verum board.
89S51 microcontroller.
LDR
Thermistor
LEDs (2)
10uF capacitor
DC voltmeter
Torch
Heating Element
jumper wires
Theory:-
LDR:
The light dependent resistor, LDR, is known by many names including the
photo resistor, photoconductor, photoconductive cell, or simply the photocell.
It is probably the term photocell that is most widely used in data and
instruction sheets for domestic equipment.
Photo-resistor mechanism:
Although there are many ways in which light dependent resistors, or photo
resistors can be manufactured, there are naturally a few more common
methods that are seen. Essentially the photoresisitor or photocell consists of
a resistive material sensitive to light that is exposed to light. The photo
resistive element comprises section of the material with contacts at either
end. A typical structure for a light dependent or photo resistor uses an active
semiconductor layer that is deposited on an insulating substrate. The
semiconductor is normally lightly doped to enable it to have the required
level of conductivity. Contacts are then placed either side of the exposed
area. Within the basic photo resistor or photocell structure, the resistance of
the material itself is a key issue. To ensure the resistance changes resulting
from the light dominate, contact resistance is minimized. To achieve this, the
area around the contacts is normally heavily doped to reduce the resistance
in this region. In many instances the area between the contacts is in the form
of a zig zag, or inter digital pattern. This maximizes the exposed area and by
keeping the distance between the contacts small it reduces the spurious
resistance levels and enhances the gain.
Thermistor:
of fixed linear resistors, is the fact that for a temperature variation with one
degree the value of the thermistors resistance changes by tens of percent. In
other words, it is possible that within a narrow temperature range the
thermistor would halve or double its resistance value.
Thermistor sysmbol:
Types:
Decrease or increase in resistance is closely correlated with the type of the
thermistor, which can be:
Negative temperature coefficient, NTC
Positive temperature coefficient, PTC.
R = Ro ek
K = (1/T 1/To)
The thermistor acts as the temperature sensor and it is placed on the body
whose temperature is to be measured. It is also connected in the electric
circuit. When the temperature of the body changes, the resistance of the
thermistor also changes, which is indicated by the circuit directly as the
temperature since resistance is calibrated against the temperature. The
thermistor can also be used for some control which is dependent on the
temperature.
Make the circuit involving microcontroller and 7 segments in proteus to show the
results.
There are the following steps involved for test bench experiment
Place a 330 resistor in series with LDR and connect an LED in parallel.
Connect a DC voltmeter in parallel to the LED for measuring voltages for the ON
state and OFF state of LED.
Obtain required levels of light for which LED glows and for which it stays OFF by
inserting a variable resistor in series with the LDR. Increasing the resistance will
reduce the intensity level of light for which LED glows.
Place a 330 resistor in series with parallel combination of 10uF capacitor and
thermistor.
Also connect an LED and DC voltmeter in parallel for measuring voltages for the
ON state and OFF state of LED.
Obtain required levels of heat/temperature for which LED glows and for which it
stays OFF by inserting a variable resistor in series with the LDR instead of 330
resistor. Increasing the resistance will reduce the intensity level of heat for
which LED glows.
EXPERIMENT NO:13
Interfacing of Stepper Motor with 89S51:
Objective:What is stepper motor?
Verum board.
AT89S51 Microcontroller
Resistors (4.7k)
jumper wires
Theory:Stepper Motor:
A stepper motor is a widely used device that translates electrical pulses into
mechanical movement. In applications such as disk drives, dot matrix
printers, and robotics, the stepper motor is used for position control. Stepper
motors commonly have a permanent magnet rotor (also called the shaft)
surrounded by a stator. There are also steppers called variable reluctance
stepper motors that do not have a PM rotor. The most common stepper
motors have four stator windings that are paired with a center-tapped
common. This type of stepper motor is commonly referred to as a four-phase
unipolar stepper motor. The center tap allows a change of current direction in
each of two coils when a winding is grounded, thereby resulting in a polarity
change of the stator.
The bipolar stepper motor usually has four wires coming out of it. Unlike
unipolar steppers, bipolar steppers have no common center connection. They
have two independent sets of coils instead. They can be distinguished from
unipolar steppers by measuring the resistance between the wires. One
should find two pairs of wires with equal resistance. If youve got the leads of
your meter connected to two wires that are not connected (i.e. not attached
to the same coil), you should see infinite resistance (or no continuity).Bipolar
stepper motors have no center tap and having equal coil resistances.
A unipolar stepper motor has one winding with center tap per phase. Since in
this arrangement a magnetic pole can be reversed without switching the
direction of current, the commutation circuit can be made very simple (e.g.,
a single transistor) for each winding. Typically, given a phase, the center tap
of each winding is made common: giving three leads per phase and six leads
for a typical two phase motor. Often, these two phase commons are
internally joined, so the motor has only five leads. Windings of this motor can
be identified by touching the terminal wires together in PM motors. If the
terminals of a coil are connected, the shaft becomes harder to turn. One way
to distinguish the center tap (common wire) from a coil-end wire is by
measuring the resistance. Resistance between common wire and coil-end
wire is always half of what it is between coil-end and coil-end wires. Due to
the ease of operation unipolar stepper motor is commonly used. We are
using it in this experiment too.
Wave Drive:
Full Drive:
commonly used than others. Power consumption will be higher than other
modes.
Half Drive:
ULN2003 Driver:
Make the circuit involving microcontroller and stepper motor in proteus to show
the results.
Connect input pins 1 to 4 of ULN2003 driver IC P2^0 to P2^3 respectively and also to
5V supply through 4.7k resistors.
Short center tap (common wire) of both windings of unipolar stepper motor and connect
to 5V supply.
Connect remaining two ends of each winding one by one to collectors of photo
Darlington pairs in ULN2003A i.e. pins 13 to 16 of ULN2003.
EXPERIMENT NO:14
Verum board.
89S51 microcontroller.
jumper wires
Make the circuit involving microcontroller and traffic light system in proteus to show
the results.
Select three LEDs 1 red, 1 green and 1 yellow and make 8 such groups of
LEDS.
There are four ways on which we have to control the traffic so make use 2
groups of three LEDs for each way one is controlling the traffic flow from the
front and other from side.
Connect the cathode of LEDs with port 0,2 and 3(through female header)
and their anodes with 5V through 330 resistors.
Make the arrangement of LEDs on varum board just like four way traffic
lights.
Program the microcontroller for operating the LED in active Low mode.
EXPERIMENT NO:15
Procedure.
Verum board.
89S51 microcontroller.
12 volt bulb.
jumper wires
Theory:-
Make the circuit involving microcontroller and in proteus to show the results.
Now link the hex files with proteus and verify the results.