Download Embedded System - 123SeminarsOnly.com

Document related concepts

Variable-frequency drive wikipedia , lookup

Electronic engineering wikipedia , lookup

Power inverter wikipedia , lookup

Transistor wikipedia , lookup

Coilgun wikipedia , lookup

Memristor wikipedia , lookup

Mercury-arc valve wikipedia , lookup

Ground (electricity) wikipedia , lookup

Islanding wikipedia , lookup

Power engineering wikipedia , lookup

Capacitor wikipedia , lookup

Electrical substation wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Resistor wikipedia , lookup

History of electric power transmission wikipedia , lookup

Voltage regulator wikipedia , lookup

Earthing system wikipedia , lookup

Triode wikipedia , lookup

Voltage optimisation wikipedia , lookup

P–n diode wikipedia , lookup

Electrical ballast wikipedia , lookup

TRIAC wikipedia , lookup

Power MOSFET wikipedia , lookup

Power electronics wikipedia , lookup

Stray voltage wikipedia , lookup

Current source wikipedia , lookup

Rectifier wikipedia , lookup

Surge protector wikipedia , lookup

Multimeter wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Ohm's law wikipedia , lookup

Buck converter wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Mains electricity wikipedia , lookup

Current mirror wikipedia , lookup

Network analysis (electrical circuits) wikipedia , lookup

Alternating current wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
BHAI GURDAS INSTITUTE OF
ENGG. AND TECH.
SANGRUR
REPORT OF
6-MONTHS INDUSTRIAL TRAINNING
ON
EMBEDDED SYSTEMS
Submitted By :
Ramandeep Singh
40204020
Submitted To :
Mr. Harsimran Singh
HOD
DEPARTMENT OF ELECTRONICS AND
COMMUNICATION ENGINEERING
BGIET
SANGRUR
ACKNOWLEDGEMENT
Training is an agglomeration of the theoretical and practical and
technical concepts, which enhances our skills in the filed of technology.
Training plays a strong role in the building up of strong personality.
Training at SILICON TECHNICAL INSTITUTE is a learning experience.
I would like to thank SILICON for providing us the opportunity to carry
out my industrial training. It is a wonderful experience working with
learned people of the institute.
I am extremely thankful to Mr. Sanjay Arora (Head of training
department) for allowing us to carry on my training at this prestigious
organization. I am extremely indebted to him for allowing us to train
myself in various processes carried out in institute and helping me to do
my job properly.
I feel duty bound to express my sincere token of gratitude to Mr. Daljit
Singh and Mr.Harjeet Singh for their excellent expert guidance,
motivation and all the help, which has powered me to here today. They
explained the technicalities to me, which will remain of great help to me
in times to come.
I express my gratitude to all the employees for their immense support
and cooperation.
I am also thankful to those to whom I have forgotten to mention.
Ramandeep Singh
40204020
PREFACE
Training is an agglomeration of the theoretical and practical and
technical concepts, which enhances our skills in the field of technology.
Training plays a strong role in the building up of strong personality.
Training at Silicon technical institute is a learning experience.
The training report has been developed as a part of the industrial
training that Punjab technical university (Punjab) requires its students to
undergo after the sixth semester of the curriculum the purpose of the
industrial training is to familiarize the students of the Bachelor or
engineering course with the present working environment in the country.
To provide them to study with the latest trends those have been
established and edged a well as the one’s that are being developed in
the country. Moreover to make students feel sure that whatever they are
learning in this training period would certainly help them for the future
courses of action and help them to develop their potential and technical
skills.
To allow them to explore various fields and to better equip them as a
professional in the time to time.
The training is being carried out at Silicon Technical Institute is an
education centre for course of Embedded System situated at
Chandigarh, Sector -35C. It’s a perfect institute for the persons want to
shape their career.
TABLE OF CONTENTS
1)
Company Profile ……………………………………………1 - 4
2)
Introduction to Electronic Devices ………………………5 - 45
3)
Introduction to Logic Gates ……………………………46 - 52
4)
Introduction to Embedded Systems ………………….52 – 117
 Micro-controller 8051
 Interfacing of Various Devices
5)
Software Description …………………………………..118 - 126
 Introduction to Kiel.
 Commands used.
 Introduction to ISP.
6)
Some Basic programs using assembly
127-130
SILICON TECHNICAL INSTITUTE
SILICON is a well established institute in Chandigarh with an experience of
fifteen years and has gained recognition as training organization of high repute
offering international quality education in the field of Electronics &
Communication technology. The centre boasts of a professional faculty which
satisfies the needs & expectancy of today's knowledge hungry students.
Our Institute provides training to the engineering students which generally
colleges recommend after completion of 4th, 6th & last semester. The training
programs are of two months, three months, & six months duration and 100%
practical oriented in Electronics, Telecommunication & Computers,
UNIQUE FEATURES
•
100% practical oriented approach.
•
Instill creativity in students.
•
Latest hardware & software technology.
•
•
High quality education with latest curriculum & strong fundamentals.
Optimum utilization of hardware/software, manpower and office space,
hence maximum turnover. Extensive preparation & innovative techniques.
•
Extensive preparation & innovative techniques.
ELECTRONIC DEVICES
An electronic component is any indivisible electronic building block packaged
in a discrete form with two or more connecting leads or metallic pads.
Components are intended to be connected together, usually by soldering to a
printed circuit board, to create an electronic circuit with a particular function
(for example an amplifier, radio receiver, or oscillator). Components may be
packaged singly (resistor, capacitor, transistor, diode etc.) or in more or less
complex groups as integrated circuits (operational amplifier, resistor array,
logic gate etc). Active components are sometimes called devices rather than
components.
ELECTRICAL RESISTANCE:
Electrical resistance is a measure of the degree to which an object opposes the
passage of an electric current. The Sl unit of electrical resistance is the ohm,
The quantity of resistance in an electric circuit determines the amount of
current flowing in the circuit for any given voltage applied to the circuit.
R=V / I
where
R is the resistance of the object, usually measured in ohms, equivalent to
J.s/C2
V is the potential difference across the object, usually measured in volts
/ is the current passing through the object, usually measured in amperes
Resistors are two-terminal devices that restrict, or resist, the flow of current.
The larger the resistor, the less current can flow through it for a given voltage
(an equation known as Ohm's law, V=113, relates current, resistance, and
voltage). Electrical resistance within the resistor body is caused by the
collisions of electrons in motion through the resistor. Such collisions cause
energy to be dissipated in the form of heat or light (as in a toaster or light bulb).
Resistance is measured in Ohms - a 1 Ohm resistor is relatively small, and a
100KOhm resistor is relatively large. Resistors find many uses in electronic
systems, On the Digilab board, resistors are used to limit the current that flows
into an output LED (so they don't burn too bright and destroy themselves) and
to limit the current that flows in response to a button or switch input being
activated. The Digilab board uses several different resistor values. Of course,
the correct resistor must be loaded in the correct place on the PCB.
Resistors come in many shapes and sizes, and depending on their size and
construction technology, they can dissipate differing amounts of power (the
amount of power dissipated in a resistor can be calculated using the equation
P=I 2 R, where I is the current flowing through the resistor and R is the
resistance). Typically, resistors used in digital systems encounter relatively low
voltages and currents, and therefore, they can be relatively small. The Digilab
resistors are rated to dissipate 250mW of power, or 1/4 Watt. Resistors that can
dissipate more than 1/4 Watt are physically larger. For example, power
resistors that can dissipate several Watts or more can be cigar-sized or even
larger. For small resistors, resistor values are "encoded" as a series of coloured
bands on the resistor body.
To determine the value of a small resistor (i.e., 1/8 Watt or 1/4 Watt), first
locate the tolerance band on one end of the resistor - it will typically be either
gold (59% tolerance) or silver (10% tolerance). The colour band at the other
end of the resistor is band1. Use the table below to find the two-digit number
associated with the colors of bands 1 and 2. The band nearest the tolerance
band is the multiplier (or exponent) band - the digits associated with the first
two colour bands are multiplied by 10 raised to the power indicated by the
colour of the multiplier band. The following table associates band colors to
digits and multiplier factors. Simply multiply the two-digit value by the
multiplier, and you’ve got the resistor value.
BAND
1st and 2nd band Multiplier Tolerance
COLOR
digits
Black
0
100
1%
Brown
1
101
2%
Red
2
102
3%
Orange
3
103
4%
Yellow
4
104
N/A
Green
5
105
N/A
Blue
6
106
N/A
Violet
7
107
N/A
Grey
8
108
N/A
White
9
109
N/A
Resistor schematic
Gold
N/A
.1
5%
symbol
Silver
N/A
.01
10%
No color
N/A
N/A
20%
Resistors are manufactured with many body colors, with tan or light brown
being the most typical. The only significant resistor body colors are white and
blue; these colors signify a non-flammable or fusible resistor. Such resistors are
used in circuits where overheating might pose a safety risk. In circuit
schematics and in parts lists, resistor reference designators always begin with
an "R". You can see several rectangular white boxes with "R-" on the Digilab
board silk-screen. The schematic symbol for a resistor is shown above.
Resistors are non-polarised, so they can be placed in a PCB in any orientation.
For a wide variety of materials and conditions, the electrical resistance does not
depend on the amount of current flowing or the amount of applied voltage. V
can either be measured directly across the object or calculated from a
subtraction of voltages relative to a reference point. The former method is
simpler for a single object and is likely to be more accurate. There may also be
problems with the latter method if the voltage supply is AC and the two
measurements from the reference point are not in phase with each other.
RESISTANCE IN SERIES AND PARALLEL CIRCUITS
Series circuits
A series circuit is a circuit in which resistors are arranged in a chain, so
the current has only one path to take. The current is the same through
each resistor. The total resistance of the circuit is found by simply
adding up the resistance values of the individual resistors:
equivalent resistance of resistors in series : R = R1 + R2 + R3 + ...
A series circuit is shown in the diagram above.
With a 10 V battery, by V = I R the total current in the circuit is:
I = V / R = 10 / 20 = 0.5 A. The current through each resistor would be
0.5 A.
PARALLEL CIRCUITS
A parallel circuit is a circuit in which the resistors are arranged with their
heads connected together, and their tails connected together. The
current in a parallel circuit breaks up, with some flowing along each
parallel branch and re-combining when the branches meet again. The
voltage across each resistor in parallel is the same.
The total resistance of a set of resistors in parallel is found by adding up
the reciprocals of the resistance values, and then taking the reciprocal
of the total:
Equivalent resistance of resistors in parallel: 1 / R = 1 / R 1 + 1 / R2 + 1 /
R3 +...
A parallel circuit is shown in the diagram above. In this case the current
supplied by the battery splits up, and the amount going through each
resistor depends on the resistance. If the values of the three resistors
are:
With a 10 V battery, by V = I R the total current in the circuit is: I = V / R
= 10 / 2 = 5 A.
The individual currents can also be found using I = V / R. The voltage
across each resistor is 10 V, so:
I1
=
10
/
8
=
1.25
A
I2
=
10
/
8
=
1.25
A
I3=10 / 4 = 2.5 A
Note that the currents add together to 5A, the total current.
A parallel resistor short-cut
If the resistors in parallel are identical, it can be very easy to work out
the equivalent resistance. In this case the equivalent resistance of N
identical resistors is the resistance of one resistor divided by N, the
number of resistors. So, two 40-ohm resistors in parallel are equivalent
to one 20-ohm resistor; five 50-ohm resistors in parallel are equivalent
to one 10-ohm resistor, etc.
When calculating the equivalent resistance of a set of parallel resistors,
people often forget to flip the 1/R upside down, putting 1/5 of an ohm
instead of 5 ohms, for instance. Here's a way to check your answer. If
you have two or more resistors in parallel, look for the one with the
smallest resistance. The equivalent resistance will always be between
the smallest resistance divided by the number of resistors, and the
smallest resistance. Here's an example.
You have three resistors in parallel, with values 6 ohms, 9 ohms, and 18
ohms. The smallest resistance is 6 ohms, so the equivalent resistance
must be between 2 ohms and 6 ohms (2 = 6 /3, where 3 is the number
of resistors).
Doing the calculation gives 1/6 + 1/12 + 1/18 = 6/18. Flipping this upside
down gives 18/6 = 3 ohms, which is certainly between 2 and 6.
CAPACITORS
A capacitor is an electrical device that can store energy in the electric field
between a pair of closely-spaced conductors (called 'plates). When voltage is
applied to the capacitor, electric charges of equal magnitude, but opposite
polarity, build up on each plate.
A capacitor is a two-terminal device that can store electric energy in the form
of charged particles. You can think of a capacitor as a reservoir of charge that
takes time to fill or empty. The voltage across a capacitor is proportional to the
amount of charge it is storing - since it is not possible to instantaneously move
charge to or from a capacitor, it is not possible to instantaneously change the
voltage across a capacitor. It is this property that makes capacitors useful on the
Digilab board.
Capacitance is measured in Farads - a one Farad capacitor can store one
Coloumb of charge at one volt. For engineering on a small scale (i.e.,
hand-held or desk-top devices), a one Farad capacitor stores far too much
charge to be of general use (it would be like a car having a 1000 gallon gas
tank). More useful capacitors are measured in micro-farads (uF) or pico-farads
(pF). The terms "milli-farad" and "nano-farad" are rarely used. Large
capacitors often have their value printed plainly on them, such as "10 uF (for
10 microfards). Smaller capacitors, appearing as small disks or wafers, often
have their values printed on them in an encoded manner (similar to the resistor
packs discussed above). For these capacitors, a three digit number indicates the
capacitor value in Pico farads. The first two digits provides the "base" number,
and the third digit provides an exponent of 10 (so, for example, "104" printed
on a capacitor indicates a capacitance value of 10 x 10 4 or 100000 pF).
Occasionally, a capacitor will only show a two digit number, in which case that
number is simply the capacitor value in pF. (To be complete, if a capacitor
shows a three digit number and the third digit is 8 or 9, then the first two digits
are multiplied by .01 and .1 respectively). Often, a single letter is appended to
the capacitance value -this letter indicates the quality of the capacitor.
Capacitors are used on the Digilab board to keep the voltage supplies and some
signals stable regardless of circuit activity, and to store charge when inputs are
activated in order to slow their assertion times. Twenty-seven capacitors of
three different types and values are used on the Digilab board. The majority of
the capacitors (24 out of 27) are used to decouple Digilab's integrated circuits
from the power supply. These 24 bypass capacitors are placed on the board
very close to the Vdd pins of all chips, where they can supply the short-term
electrical current needs of the chips. Without such bypass capacitors, individual
chips could cause the Vdd supply across the entire Digilab board to dip below
5V during times of heavy current demand. Nearly every chip in every digital
system uses bypass capacitors. Bypass capacitor value can be determined if the
worst-case current requirements are known (by using the formula I = C dv/dt),
but more typically, capacitors in the range 0.01uF to 0.1uF are used without
regard to the actual current requirements. The Digilab board uses 0.047uF
bypass capacitors. The board also uses a bulk bypass capacitor (C27) to
provide charge storage for the entire circuit board - this large 47uF capacitor
can supply the individual bypass capacitors during times of exceptional need.
ENERGY STORAGE
A capacitor can store electric energy when disconnected from its charging
circuit, so it can be used like a temporary battery. Capacitors are common used
in electronic devices to maintain power supply while batteries are being
changed. (This prevents loss of information in volatile memory.)
Capacitors are used in power supplies where they smooth the output of a full or
half wave rectifier. They can also be used in charge pump circuits as the energy
storage element in the generation of higher voltages than the input voltage,
Capacitors are connected in parallel with the power circuits of most electronic
devices and larger systems (such as factories) to shunt away and conceal
current fluctuations from the primary power source to provide a "clean" power
supply for signal or control circuits. Audio equipment, for example, uses
several capacitors in this way, to shunt away power line hum before it gets into
the signal circuitry. The capacitors act as a local reserve for the DC power
source, and bypass AC currents from the power supply. This is used in car
audio applications, when a stiffening capacitor compensates for the inductance
and resistance of the leads to the lead-acid car battery.
CAPACITORS IN SERIES
The total capacitance of the above circuit is:
1
1
1
1


 ...... 
Ceq C1 C2
Cn
CAPACITORS IN PARALLEL
The total capacitance of this circuit will be:
Ceq = C1 + C2 + ….. + Cn
CAPACITOR TYPES
 Metal film:
Made from high quality polymer foil (usually
polycarbonate, polystyrene, polypropylene, polyester (Mylar), and for
high quality capacitors polysulfone), with a layer of metal deposited on
surface. They have good quality and stability, and are suitable for timer
circuits. Suitable for high frequencies.
 Mica: Similar to metal film. Often high voltage. Suitable for high
frequencies. Expensive.
 Paper: Used for high voltages
 Glass: Used for high voltages. Expensive. Stable temperature
coefficient in a wide range of temperatures.
 Ceramic: Chips of altering layers of metal and ceramic. Depending on
their dielectric, whether Class 1 or Class 2, their degree of
temperature/capacity dependence varies. They often have (especially the
class 2) high dissipation factor, high frequency coefficient of
dissipation, their capacity depends on applied voltage, and their capacity
changes with aging. However they find massive use in common
low-precision coupling and filtering applications. Suitable for high
frequencies.
 Electrolytic: Polarized. Construction ally similar to metal film, but the
electrodes are made of aluminum etched to acquire much higher
surfaces, and the dielectric is soaked with liquid electrolyte. They suffer
from high tolerances, high instability, gradual loss of capacity especially
when subjected to heat, and high leakage. Special types with low
equivalent series resistance are available. Tend to lose capacity in low
temperatures. Can achieve high capacities.
 Tantalum: Like electrolytic. Polarized. Better performance with higher
frequencies. High dielectric absorption. High leakage. Have much better
performance in low temperatures.
 Supercapacitrs: Made from carbon aerogel, carbon nanotubes, or
highly porous electrode materials. Extremely high capacity. Can be used
in some applications instead of rechargeable batteries.
USES OF CAPACITORS
Capacitors are used for several purposes:
 Timing - for example with a 555 timer IC controlling the charging and
discharging.
 Smoothing - for example in a power supply.
 Coupling - for example between stages of an audio system and to
connect aloudspeaker.
 Filtering - for example in the tone control of an audio system.
 Tuning - for example in a radio system.
 Storing energy - for example in a camera flash circuit
CURRENT
Electric current Is by definition the flow of electric charge. The Sl unit of
blectric current Is the ampere (A), which Is equal to a flow of one coulomb of
charge per second.
VOLTAGE
Voltage is the difference of electrical potential between two points of an
electronic circuit, expressed in volts [1]. It measures the capacity (not the
technical meaning) of an electric field to cause an electric current in an
electrical conductor. Depending on the difference of electrical potential it is
called extra low voltage, low voltage, high voltage or extra high voltage
RESISTANCE
Electrical resistance is a measure of the degree to which an object opposes the
passage of an electric current. The SI unit of electrical resistance is the ohm.
OHM'S LAW
Ohm's law predicts the current in an (ideal) resistor (or other ohmic device) to
be applied voltage divided by resistance:
I=V/R
Where
/is the current, measured in amperes
V is the potential difference measured in volts
R is the resistance measured in ohms
MEASURING INSTRUMENTS
VOLTMETER
A voltmeter is an instrument used for measuring the potential difference
between two points in an electric circuit.
The voltage can be measured by allowing it to pass a current through a
resistance; therefore, a voltmeter can be seen as a very high resistance
ammeter. One of the design objectives of the instrument is to disturb the circuit
as little as possible and hence the instrument should draw a minimum of
electric current to operate. This is achieved by using a sensitive ammeter or
micrometer in series with a high resistance.
The moving coil galvanometer is one example of this type of voltmeter. It
employs a small coil of fine wire suspended in a strong magnetic field. When
an electrical current is applied, the galvanometer's indicator rotates and
compresses a small spring. The angular rotation is proportional to the current
that is flowing through the coil- For use as a voltmeter, a series resistance is
added so that the angular rotation becomes proportional to the applied voltage
AMMETER
An ammeter is a measuring instrument used to measure the flow of electric
current in a circuit. Electric currents are measured in amperes, hence the name.
The word "ammeter" is commonly misspelled or mispronounced as
"ampmeter" by some.
The earliest design is the D'Arsonval galvanometer or moving coil ammeter. It
uses magnetic deflection, where current passing through a coil causes the coil
to move in a magnetic field. The voltage drop across the coil is kept to a
minimum to minimize resistance across the ammeter in any circuit into which
the it is inserted.
Moving iron ammeters use a piece or pieces of iron which move when acted
upon by the electromagnetic force of a fixed coil of (usually heavy gauge) wire.
This type of meter responds to both direct and alternating currents (as opposed
to the moving coil ammeter, which works on direct current only).
To measure larger currents, a resistor called a shunt is placed in parallel with
the meter. Most of the current flows through the shunt, and only a small
fraction flow through the meter. With this solution, arbitrarily large currents
can be measured with a single meter. Traditionally, the meter used with a shunt
reaches full-scale deflection when a voltage of 50mV is placed across its coil,
so shunts are typically designed to produce a voltage drop of 50mV when
carrying their full rated current.
More modern ammeter designs are non-mechanical, or digital, and use an
analog to digital converter to measure the voltage across the shunt resistor. The
ADC is read by a microcomputer that performs the calculations to display the
current through the resistor.
One problem with the use of an ammeter is the need for the meter to be inserted
into the circuit and become part of it. Mistakenly placing the ammeter in
parallel with a circuit will blow the fuse, possibly damaging the meter and
causing injury. In AC circuits, an inductive coupling adapter converts the
magnetic field around a conductor into a small AC current that can be easily
read by a meter. See clamp meter. In a similar way, accurate DC non-contact
arnmeters have been constructed using Hall effect magnetic field sensors
OHMMETER
An Ohmmeter is an electrical measuring instrument that measures electrical
resistance, the opposition to the flow of an electric current.
The original design of an ohmmeter provided a small battery to apply a voltage
to a resistance. It used a galvanometer to measure the electric current through
the resistance. The scale of the galvanometer was marked in ohms, because the
fixed voltage from the battery assured that as resistance decreased, the current
through the meter would increase.
A more accurate type of ohmmeter has an electronic circuit that passes a
constant current I through the resistance, and another circuit that measures the
voltage V across the resistance. According to the following equation, derived
from Ohm's Law, the value of the resistance R is given by:
R= V/1
For high-precision measurements the above types of meter are inadequate, This
is because the meter's reading is the sum of the resistance of the measuring
leads, the contact resistances and the resistance being measured. To reduce this
effect, a precision ohmmeter has four terminals, called Kelvin contacts. Two
terminals carry the current from the meter, while the other two allow the meter
to measure the voltage across the resistor. With this type of meter, any current
drop due to the resistance of the first pair of leads and their contact resistances
is ignored by the meter. This four terminal measurement technique is called
Kelvin sensing, after William Thomson, Lord Kelvin, who invented the Kelvin
bridge in 1861 to measure very low resistances.
DIODES
Diodes are constructed from the same type of silicon as transistors, but they are
simpler devices that have only two terminals. Called the anode and cathode, the
two ends of the diode are constructed of positively doped silicon (the anode)
joined directly to negatively doped silicon (the cathode). This pn-junction
exhibits the unique characteristic of allowing current to flow in only one
direction (from the anode to the cathode). Diodes have a minimum threshold
voltage (or Vth, usually around 0.7V) that must be present between the anode
and cathode in order for current to flow. If the anode voltage is not at least Vth
greater than the cathode voltage, no current will flow. Likewise, if the cathode
voltage is greater than the anode voltage, the diode is said to be reverse-biased
and no current will flow. In an ideal diode, if the diode voltage equals the
threshold voltage (plus a small amount), then unlimited current can flow
without causing the voltage across the diode to increase. And, if the diode is
reversed-biased, no current will flow regardless of reverse-voltage magnitude.
Diodes
Diodes have many uses in electronic circuits. As examples, they are frequently
employed in power supply circuits to turn alternating current (AC) into direct
current (DC), they are used to limit the amount of over-voltage that can be
applied to a given circuit node, and they are used to force given circuit nodes to
remain at or below a certain voltage. On the Digilab board, three individual
diodes are used to limit the voltages applied to the Red, Blue, and Green pins
of the VGA connector (M) to 0.7VDC or less.
Note the identification methods used to mark a diode's cathode -terminal: the
schematic symbol has a line at the point of the triangle; the physical diode has a
dark line on the plastic component housing; and the silk-screen pattern has both
a line at the cathode end and a square pad for the cathode lead. When loading a
diode into a circuit board, make sure that the dark line on the diode matches the
line in the silk-screen pattern. Remember that since diodes allow current to
flow in only one direction, a backwards diode will cause the circuit to
malfunction.
LED SCHEMATIC SYMBOL
Diodes locations on the circuit board are typically denoted with a "D-"
reference designator
A light-emitting diode (LED) is a semiconductor device that emits incoherent
narrow-spectrum light when electrically biased in the forward direction. This
effect is a form of electro luminescence. The color of the emitted light depends
on the composition and condition of the semi conducting material used, and
can be infrared, visible or near-ultraviolet. Rubin Braunstein of the Radio
Corporation of America first reported on infrared emission from gallium
arsenide (GaAs) and other semiconductor alloys in 1955. Experimenters at
Texas Instruments, Bob Biard [1] and Gary Pittman, found in 1961 that gallium
arsenide gave off infrared (invisible) light when electric, current was applied.
Biard and Pittman were able to establish the priority of their work and received
the patent for the infrared lightemitting diode. Nick Holonyak Jr. of the General
Electric Company developed the first practical visible-spectrum LED in 1962.
LEDs are available in a wide variety of sizes and shapes. The 'standard' LED
has a round cross-section of 5mm diameter and this is probably the best type
for general use, but 3mm round LEDs are also popular.
Round cross-section LEDs are frequently used and they are very easy to install
on boxes by drilling a hole of the LED diameter, adding a spot of glue will help
to hold the LED if necessary. LED clips are also available to secure LEDs in
holes. Other cross-section shapes include square, rectangular and triangular.
As well as a variety of colours, sizes and shapes, LEDs also vary in their
viewing angle. This tells you how much the beam of light spreads out. Standard
LEDs have a viewing angle of 600 but others have a narrow beam of 300 or
less.
Rapid Electronics stock a wide selection of LEDs and their catalogue is a good
guide to the range available.
ADVANTAGES OF USING LEDS
 LEDs produce more light per Watt than do incandescent bulbs; this is
useful in battery powered devices.
 LEDs can emit light of an intended color without the use of color filters
that traditional lighting methods require. This is more efficient and can
lower initial costs.
 The solid package of an LED can be designed to focus its light.
Incandescent and fluorescent sources often require an external reflector
to collect light and direct it in a usable manner.
 When used in applications where dimming is required, LEDs do not
change their colour tint as the current passing through them is lowered,
unlike incandescent lamps, which yellow.
 LEDs are built i1nside solid cases that protect them, unlike incandescent
and discharge sources, making them extremely durable.
 LEDs have an extremely long life span: upwards of 100,000 hours,
twice as long as the best fluorescent bulbs and twenty times longer than
the best incandescent bulbs. (Incandescent bulbs can also be made to last
an extremely long time by running at lower than normal voltage, but
only at a huge cost in efficiency; LEDs have a long life when operated at
their rated power.)
 Further, LEDs mostly fail by dimming over time, rather than the abrupt
burn-out of incandescent bulbs,
 LEDs light up very quickly. A typical red indicator LED will achieve
full brightness in microseconds; LEDs used in communications devices
can have even faster response times.
 LEDs can be very small and are easily populated onto printed circuit
boards.
Connecting LEDs in series
If you wish to have several LEDs on at the same time it may be possible to
connect them in series. This prolongs battery life by lighting several LEDs with
the same current as just one LED.
All the LEDs connected in series pass the same current so it is best if they
are all the same type. The power supply must have sufficient voltage to
provide about 2V for each LED (4V for blue and white) plus at least another
2V for the resistor. To work out a value for the resistor you must add up all the
LED voltages
SIZE AND SHAPES
LEDs are produced in a staggering array of shapes and sizes, The 5 mm
cylindrical package (red, fifth from the left) is the most common, estimated at
80% of world production. The color of the plastic lens is often the same as the
actual color of light emitted, but not always. For instance, purple plastic is
often used for infrared LEDs, and most blue devices have clear housings. There
are also LEDs in extremely tiny packages, such as those found on blinkies.
Colours of LEDs
LEDs are available in red, orange, amber, yellow, green, blue and white. Blue
and white LEDs are much more expensive than the other colors.
The color of an LED is determined by the semiconductor material, not by the
coloring of the 'package' (the plastic body). LEDs of all colors are available in
uncolored packages which may be diffused (milky) or clear (often described as
I water clear'). The colored packages are also available as diffused (the
standard type) or transparent
LIST OF LED APPLICATIONS
Some of these applications are further elaborated upon in the following text.
 Architectural lighting.
 Status indicators on all sorts of equipment.
 Traffic lights and signals.
 Exit signs.
 Motorcycle and Bicycle lights.
 Toys and recreational sporting goods.
 Railroad crossing signals.
 Light bars on emergency vehicles.
 Elevator Push Button Lighting.
 Thin, lightweight message displays at airports and railway stations and
as destination displays for trains, buses, trams and ferries.
 Red or yellow LEDs are used in indicator and alphanumeric displays in
environments where night vision must be retained: aircraft cockpits,
submarine and ship bridges, astronomy observatories, and in the field,
e.g. night time animal watching and military field use.
 Red, yellow, green, and blue LEDs can be used for model railroading
applications.
 Remote controls, such as for TVs and VCRs, often use infrared LEDs.
 In dot matrix arrangements for displaying messages.
 Glow lights, as a more expensive but longer lasting and reusable
alternative to Glow sticks.
 Movement sensors, for example in optical computer mice.
 Because of their long life and fast switching times, LEDs have been
used for automotive high-mounted brake lights and truck and bus brake
lights and turn signals for some time, but many high-end vehicles are
now starting to use LEDs for their entire rear light clusters. Besides the
gain in reliability, this has styling advantages because LEDs are capable
of forming much thinner lights than incandescent lamps with parabolic
reflectors. The significant improvement in the time taken to light up
(perhaps 0.5s faster than an incandescent bulb) improves safety by
giving drivers more time to react.
 Backlighting for LCD televisions and displays. The availability of LEDs
in specific colors (RGB) enables a full-spectrum light source which
expands the color gamut by as much as 45%.
 New stage lighting equipment is being developed with LED sources in
primary red-green-blue arrangements.
 LED phototherapy for acne using blue or red LEDs has been proven to
significantly reduce acne over a 3 month period.
 As Voltage Reference in electronic circuits. The constant voltage drop
(e.g. 1.7 V for a normal red LED) can be used instead of a Zener diode
in low-voltage regulators. Zener diodes are not available below voltages
of about 3 V.
RELAY
A relay is an electrical switch that opens and closes under control of another
electrical circuit. In the original form, the switch is operated by an
electromagnet to open or close one or many sets of contacts. It was invented by
Joseph Henry in 1835. Because a relay is able to control an output circuit of
higher power than the input circuit, it can be considered, in a broad sense, to be
a form of electrical amplifier
OPERATION
When a current flows through the coil, the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either
makes or breaks a connection with a fixed contact. When the current to the coil
is switched off, the armature is returned by a force approximately half as strong
as the magnetic force to its relaxed position. Usually this is a spring, but gravity
is also used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low voltage application, this is to reduce
noise. In a high voltage or high current application, this is to reduce arcing.
If the coil is energized with DC, a diode is frequently installed across the coil,
to dissipate the energy from the collapsing magnetic field at deactivation,
which would otherwise generate a spike of voltage and might cause damage to
circuit components. If the coil is designed to be energized with AC, a small
copper ring can be crimped to the end of the solenoid. This "shading ring"
creates a small out-of-phase current, which increases the minimum pull on the
armature during the AC cycle. [1]
By analogy with the functions of the original electromagnetic device, a
solid-state relay is made with a thyristor or other solid-state switching device.
To achieve electrical isolation, a light emitting diode (LED) is used with a
photo transistor.
APPLICATIONS
Relays are used:
 to control a high-voltage circuit with a low-voltage signal, as in some
types of modems,
 to control a high-current circuit with a low-current signal, as in the
starter solenoid of an automobile,
 to detect and isolate faults on transmission and distribution lines by
opening and closing circuit breakers (protection relays),
 to isolate the controlling circuit from the controlled circuit when the two
are
at
different
potentials,
for
example
when
controlling
a
mains-powered device from a low-voltage switch. The latter is often
applied to co~trol office lighting as the low voltage wires are easily
installed in partitions, which may be often moved as needs change. They
may also be controlled by room occupancy detectors in an effort to
conserve energy,
 to perform logic functions. For example, the boolean AND function is
realised by connecting NO relay contacts in series, the OR function by
connecting NO contacts in parallel. The change-over or Form C contacts
perform the XOR (exclusive or) function. Similar functions; for NAND
and NOR are accomplished using NC contacts. Due to the failure modes
of a relay compared with a semiconductor, they are widely used in
safety critical logic, such as the control panels of radioactive waste
handling machinery. -
ALTERNATING CURRENT
An alternating current (AC) is an electrical current whose magnitude and
direction vary cyclically, as opposed to direct current, whose direction remains
constant. The usual waveform of an AC power circuit is a sine wave, as this
result in the most efficient transmission of energy. However in certain
applications different waveforms are used, such as triangular or square waves.
Used generically, AC refers to the form in which electricity is delivered to
businesses and residences. However, audio and radio signals carried on
electrical wire are also examples of alternating current. In these applications, an
important goal is often the recovery of information encoded (or modulated)
onto the AC signal.
DIRECT CURRENT
Direct current (DC or "continuous current") is considered as the constant
flow of electrons in the single direction from low to high potential. This is
typically in a conductor such as a wire, but can also be through
semiconductors, insulators, or even through a vacuum as in electron or ion
beams. In direct current, the electric charges flow in the same direction,
distinguishing it from alternating current (AC). A term formerly used for direct
current was Galvanic current.
ALTERNATING VS. DIRECT CURRENT
So far we have been talking about a constant supply of voltage - one that
doesn't change over time, such as a battery before it starts to run down. This is
what is commonly know of as direct current or DC which is to say that there is
no change in voltage over a period of time. This is not the kind of electricity
found coming out of the sockets in your wall at home. The electricity supplied
by the hydro company changes over short periods of time (it changes over long
periods of time as well, but that's an entirely different story...) Every second,
the voltage difference between the two terminals in your wall socket fluctuates
between about -170 V and 170 V sixty times a second (if you live in North
America, at least ...). This brings up two important points to discuss.
Firstly, the negative voltage... All a negative voltage means is that the electrons
are flowing in a direction opposite to that being measured. There are more
electrons in the tested point in the circuit than there are in the reference point,
therefore more negative charge. If you think of this in terms of the two tanks of
water - if we're sitting at the bottom of the empty tank, and we measure the
relative pressure of the full one, its pressure will be more, and therefore
positive relative to your reference. If you're at the bottom of the full tank and
you measure the pressure at the bottom of the empty one, you'll find that it's
less than your reference and therefore negative. (Two other analogies to
completely confuse you.., it's like describing someone by their height. It doesn't
matter how tall or short someone is - if you say they're tall, it probably means
that they're taller than you.
Secondly, the idea that the voltage is fluctuating. When you plug your coffee
maker into the wall, you'll notice that the plug has two terminals. One is a
reference voltage which stays constant (normally called a "cold" wire in this
case ...) and one is the "hot" wire which changes in voltage realtive to the cold
wire. The device in the coffee maker which is doing the work is connected with
each of these two wires. When the voltage in the hot wire is positive in
comparison to the cold wire, the current flows from hot through the coffee
maker to cold. One one-hundred and twentieth of a second later the hot wire is
negative compared to the cold, the current flows from cold to hot. This is
commonly known as alternating current or AC.
So remember, alternating current means that both the voltage and the current
are changing in time.
DIGITAL ELECTRONICS
Digital electronics are those electronics systems that use a digital signal instead
of an analog signal. Digital electronics are the most common representation of
Boolean algebra and are the basis of all digital circuits for computers, mobile
phones, and numerous other consumer products.
The most common "fundamental unit" of digital electronics is the logic gate.
By combining numerous logic gates (from tens to hundreds of thousands) more
complex systems can be created. The complex system of digital electronics is
collectively referred to as a digital circuit.
To most electronic engineers, the terms "digital circuit", "digital system" and
"logic" are interchangeable in the context of digital circuits
ADVANTAGES
The usual advantages of digital circuits when compared to analog circuits
are,
 Digital systems interface well with computers and are easy to control
with software. It is often possible to add new features to a digital system
without changing hardware, and to do this remotely, just by uploading
new software. Design errors or bugs can be worked-around with a
software upgrade, after the product is in customer hands.
 Information storage can be much easier in digital systems than in analog
ones. In particular, the great noise-immunity of digital systems makes it
possible to store data and retrieve it later without degradation. In an
analog system, aging and wear and tear will degrade the information in
storage, but in a digital system, as long as the wear and tear is below a
certain level, the information can be recovered perfectly.
LOGIC LEVELS
A Boolean logical input or output always takes one of two logic levels, These
logic levels can go by many names Including: on / off, high (H) / low (L), one
(1) / zero (0), true (T) / false (F), positive / negative, positive / ground, open
circuit / close circuit, potential difference I no difference, yes / no. For
consistency, the names 1 and 0 will be used below
LOGIC GATE
A logic gate performs a logical operation on one or more logic inputs and
produces a single logic output. The logic normally performed is Boolean logic
and is most commonly found in digital circuits. Logic gates are primarily
implemented electronically using diodes or transistors, but can also be
constructed using electromagnetic relays, fluidics, optical or even mechanical
elements.
A logic gate is an elementary building block of a digital circuit. Most logic
gates have two inputs and one output. At any given moment, every terminal is
in one of the two binary conditions low (0) or high (1), represented by different
voltage levels. The logic state of a terminal can, and generally does, change
often, as the circuit processes data. In most logic gates, the low state is
approximately zero volts (0 V), while the high state is approximately five volts
positive (+5 V).There are seven basic logic gates: AND, OR, XDR, NOT,
NAND, NOR, and XNOR.
AND GATE
The AND gate is so named because, if 0 is called "false" and 1 is called "true,"
the gate acts in the same way as the logical "and" operator. The following
illustration and table show the circuit symbol and logic combinations for an
AND gate. (In the symbol, the input terminals are at left and the output
terminal is at right.) The output is "true" when both inputs are "true."
Otherwise, the output is "false."
Symbol
Input 1
Input 2
Output
0
0
0
0
1
0
1
0
0
1
1
1
OR GATE
The OR gate gets its name from the fact that it behaves after the fashion of the
logical inclusive "or." The output is "true" if either or both of the inputs are
"true." If both inputs are "false," then the output is "false."
Symbol
Input 1
Input 2
Output
0
0
0
0
1
1
1
0
1
1
1
1
NOT GATE
The NOT gate or inverter is a digital logic gate that implements logical
negation. It behaves according to the truth table to the right. A HIGH output (1)
results if the inputs is LOW (0). If the input is HIGH (1), a LOW output (0)
results.
Input
Input
1
0
0
1
Symbol
NAND GATE
The NAND gate operates as an AND gate followed by a NOT gate. It acts in
the manner of the logical operation "and" followed by negation. The outputis
"false" if both inputs are "true." Otherwise, the output is "true."
Symbol
Input 1
Input 2
Output
0
0
1
0
1
1
1
0
1
1
1
0
NOR GATE
The NOR gate is a combination OR gate followed by an inverter, its output is
“true” if both inputs are “false”. Otherwise, the output is “false.”
NOR gate
XNOR GATE
Input 1
Input 2
Output
0
0
1
0
1
0
1
0
0
1
1
0
The XNOR (exclusive-NOR) gate is a combination XOR gate following by an
inverter. Its output is “true” if inputs are the same, and “false” if the inputs are
different.
Input 1
Input 2
Output
0
0
1
0
1
0
1
0
0
1
1
1
Using combinations of logic gates, complex operations can be performed. In
theory, there is no limit to the number of gates that can be arrayed together in a
single device. But in practice, there is a limit to the number of gates that can be,
packed into a given physical space. Arrays of logic gates are found in digital
integrated circuits (ICs). As IC technology advances, the required physical
volume for each individual logic gate decreases and digital devices of the same
or smaller size become capable of performing ever-more-complicated
operations at ever-increasing speeds.
INTRODUCTION TO EMBEDDED SYSTEM
A specialized computer system. that is part of a larger
system or machine. Typically, an embedded system is housed on a single
microprocessor board with the programs stored in ROM. Virtually all
appliances that have a digital Interface -- watches, microwaves, VCRs, cars -utilize embedded systems. Some embedded systems include an operating
system, but many are so specialized that the entire logic can be implemented as
a single program. Embedded systems programming is the development of
programs intended to be part of a larger operating system or, in a somewhat
different usage, to be incorporated on a microprocessor that can then be
included as part of a variety of hardware devices. Several other definitions are:
 A combination of computer hardware and software, and perhaps
additional mechanical or other parts, designed to perform a dedicated
function. In some cases, embedded systems are part of a larger system or
product, as in the case of an antilock braking system in a car. Contrast
with general-purpose computer.
 A specialized computer system which is dedicated to a specific task.
Embedded systems range in size from a single processing board to
systems with operating systems (ex, Linux, Windows® NT Embedded).
Examples
of
embedded
systems
are
medical
equipment
and
manufacturing equipment.
 A computer system that is a component of a larger machine or system.
Embedded systems can respond to events in real time. Most digital
appliances, such as watches or cars, utilize an embedded system.
 Hardware and software that forms a component of some larger system
and is expected to function without human intervention. Typically an
embedded system consists of a single-board microcomputer with
software in ROM, which starts running a dedicated application as soon
as power is turned on and does not stop until power is turned off.
 An embedded system is some combination of computer hardware and
software, either fixed in capability or programmable, that is specifically
designed for a particular kind of application device. Industrial machines,
automobiles, medical equipment, cameras, household appliances,
airplanes, vending machines, and toys (as well as the more obvious
cellular phone and PDA) are among the myriad possible hosts of an
embedded system.
 A phrase that refers to a device that contains computer logic on a chip
Inside it. Such equipment is electrical or battery powered. The chip
controls one or more functions of the equipment, such as remembering
how long it has been since the device last received maintenance,
 An embedded system is a special-purpose computer system, which is
completely encapsulated by the device it controls. An embedded system
has specific requirements and performs pre-defined tasks, unlike a
general-purpose personal computer.
KIEL
Keil Software makes C compilers, macro assemblers, real-time
kernels, debuggers, simulators, integrated environments, and
evaluation
boards
for
the
8051,
251,
ARM,
and
XC16x/Cl6x/ST10 microcontroller families
Keil don’t make a compiler for every different microcontroller
architecture. They concentrate on just a few chip families that
they can support very well. That's why most of Keil's customers
will agree that they have the best development tools for ARM,
XC1 6x/C1 6x/ST1 0, 251 and 8051 microcontroller families.
Since they have fewer product lines to support, Keil can dedicate
more time to better supporting each tool chain. That allows them
to improve their tools and product support faster than other
vendors.
pVision3 IDE
pVision3, the new IDE from Keil Software, combines project
management, make facilities, source code editing, program
debugging,
and
complete
simulation
in
one
powerful
environment, pVision3 helps you get programs working faster
than ever while providing an easy-to-use development platform.
The editor and debugger are integrated into a single application
and
provide
environment.
a
seamless
embedded
project
development
pVision3 provides unique features like
 The
Device
Database
which
automatically
sets
the
assembler, compiler, and linker options for the chip you
select.
This
prevents
you
from
wasting
your
time
configuring the tools and helps you get started writing code
faster.
 A robust Project Manager which lets you create several
different configurations of your target from a single project
file. Only the Keil pVision3 IDE allows you to create an
output file for simulating, an output file for debugging with
an emulator, and an output file for programming an
EPROM--all from the same Project file.
 An integrated Make facility with automatic dependency
generation. You don't have to figure out which header files
and include files are used by which source files. The Keil
compilers and assemblers do that automatically.
 Interactive error correction. As your project compiles,
errors and warnings appear in an output window. You may
make corrections to the files in your project while pVision3
continues to compile in the background. Line numbers
associated with each error or warning are automatically
resynchronized when you make changes to the source.
Keil Software
pVision Debugger
The pVision Debugger from Keil supports simulation using only
your PC or laptop, and debugging using your target system and
a debugger interface. pVision includes traditional features like
simple and complex breakpoints, watch windows, and execution
control as well as sophisticated features like trace capture,
execution profiler, code coverage, and logic analyzer. Viewing
Code & Data
The pVision Debugger provides a number of ways to display
variables and program objects.
 Source Code Windows display your high-level language and
assembly program source code.
 The Disassembly Window shows mixed high-level language
and assembly code.
 The Registers Tab of the Project Workspace shows system
registers.
 The Symbol Window heir archly displays program symbols
in your application.
 The Output Window displays the output of various
debugger commands.
 The Memory Window displays up to four regions of code or
data memory.
 The Watch Window displays local variables, user-defined
watch expression lists, and the call stack.
Executing
pVision offers several ways you can control and manipulate
program execution.
 Reset - It is possible to debug reset conditions using the
pVision Simulator.
 Run/Stop - Buttons and Commands make starting and
stopping program execution is easy.
 Single-Stepping - pVision supports various methods of
single-stepping through your target program.
 Execution Trace - Execution trace information for each
executed instruction is stored by pVision.
 Breakpoints - Both simple and complex breakpoints are
supported by the pVision Debugger.
Advanced Analysis
Tools
Advanced analysis' tools are available to help you test and debug
your embedded applications.
 Code Coverage helps you determine how much of your
program has been tested.
 The Performance Analyser shows how functions and code
blocks in your program perform.
 The Execution Profiler shows execution counts and time
for each line of code or instruction.
 The Logic Analyser shows how various signals and
variables in your program change over time.
Simulation
Simulation capabilities make it possible to test your target
system without target hardware.
 Instruction Simulation simulates the exact effects and
timing of each IVICU instruction.
 Interrupt Simulation simulates the cause and effect of a
system or peripheral interrupt.
 Peripheral Simulation simulates the effects of on-chip
peripherals including special function registers.
 Debugger Functions allow you to expand the command
scope of the debugger and create and respond to stimuli.
 Toolbox Buttons are a convenient way for you to connect
debugger functions buttons on the user-interface.
Target Debugging
Target debug drivers allow you to test programs running on
target hardware.
 JTAG Debugging uses external hardware to interface your
PC to your target system.
 A Target Monitor interfaces your PC to your target system
using RS-232 and software.
 Flash Programming uses a target interface to download
your target program to Flash memory.
 AGDl Drivers interface the
 Vision Debugger to third-
party hardware or provide additional debugger features.
ABOUT C
As a programming language, C is rather like Pascal or Fortran.
Values are stored in variables. Programs are structured by
defining and calling functions. Program flow is controlled using
loops, if statements and function calls. Input and output can be
directed to the terminal or to files. Related data can be stored
together in arrays or structures.
Of the three languages, C allows the most precise control of
input and output. C is also rather more terse than Fortran or
Pascal. This can result in short efficient programs, where the
programmer has made wise use of C's range of powerful'
operators. It also allows the programmer to produce programs,
which are impossible to understand.
Programmers who are familiar with the use of pointers (or
indirect addressing, to use the correct term) will welcome the
ease of use compared with some other languages. Undisciplined
use of pointers can lead to errors, which are very hard to trace.
This course only deals with the simplest applications of pointers.
It is hoped that newcomers will find C a useful and friendly
language. Care must be taken in using C. Many of the extra
facilities, which it offers, can lead to extra types of programming
error. You will have to learn to deal with these to successfully
make the transition to being a C programmer.
C is a programming language developed at AT& T's Bell
Laboratories of USA in 1972.
It was designed and written by a man named Dennis Ritche. In
late seventies C begin to replace the more familiar languages of
that time like ALGOL etc. Ritche seems to have been rather
surprised that so many programmers preferred C to older
languages like FORTRAN or PL/I or the newer like Pascal and
APL. But, that's what happened.
STEPS IN LEARNING C
Alphabets,
Constants,
digits, special
variables,
symbols
keywords
Instructions
Program
USAGE
C's
primary
implementing
use
is
for
operating
"system
systems
programming",
and
embedded
including
system
applications, due to a combination of desirable characteristics
such as code portability and efficiency, ability to access specific
hardware addresses, ability to "pun" types to , match externally
imposed data access, requirements, and low runtime demand on
system resources.
C has also been widely used to implement end-user applications,
although
as
applications
became
larger
much
development shifted to other, higher level languages.
of
that
One consequence of C's wide acceptance and efficiency is that
the compilers, libraries, and interpreters of other higher-level
languages are often implemented in C.
C is used as an intermediate language by some higher-level
languages.
"hello, world" example
The following simple application appeared in the first edition of
K&R, and has become the model for an introductory program in
most
programming
textbooks,
regardless
of
programming
language. The program prints out "hello, world" to the standard
output, which is usually a terminal or screen display. Standard
output might also be a file or some other- hardware device,
depending on how standard output is mapped at the time the
program is executed.
Main()
{
printf(“hello, world\n”);
}
The above program will compile on most modern compilers that
are not in compliance mode, but does not meet the requirements
of either C89 or C99. Compiling this program in C99 compliance
mode will result in warning or error messages. 151 A compliant
version of the above program follows:
#include <stdio.h>
int main(void)
{
printf(“hello, world\n”);
return 0;
}
A Very Simple Program
This program which will print out the message This is a C
program
#include <stdio.h>
main()
{
printf(“This is a C program\n”);
}
Though the program is very simple, a few points are worthy of
note.
Every C program contains a function called main. This is the
start point of the program.
#include <stdio.h> allows the program to interact with the
screen, keyboard and file system of your computer. You will find
it at the beginning of almost every C program.
Main() declares the start of the function, while the two curly
brackets show the start and finish of the function. Curly
brackets in C are used to group statements together as in a
function, or in the body of a loop. Such a grouping is known as a
compound statement or a block.
printf("This is a C program\n");
prints the words on the screen. The text to be printed is enclosed
in double quotes. The \n at the end of the text tells the program
to print a newline as part of the output.
Expressions and Operators
One reason for the power of C is its wide range of useful
operators. An operator is a function which is applied to values to
give a result. You should be familiar with operators such as+,-,/.
Arithmetic operators are the most common. Other operators are
used for comparison of values, combination of logical states, and
manipulation of individual binary digits. The binary operators
are rather low level for so are not covered here,
Operators and values are combined to form expressions. The
values produced by these expressions can be stored in variables,
or used as a part of even larger expressions.
_______________________________________________________________
Assignment Statement
The easiest example of an expression is in the assignment
statement. An expression is evaluated, and the result is saved in
a variable. A simple example might look like
y = (m* X) + C
This assignment will save the value of the expression in variable
y.
Arithmetic operators
Here are the most common arithmetic operators
+
Addition
-
Subtraction
*
Multiplication
/
Division
%
Modulo Reduction (Remainder from integer division)
*,/and % will be performed before + or - in any expression.
Brackets can be used to force a different order of evaluation to
this. Where division is performed between two integers, the
result will be an integer, with remainder discarded. Modulo
reduction is only meaningful between integers. If a program is
ever required to divide a number by zero, this will cause an
error, usually causing the program to crash.
Here is some arithmetic expressions used within assignment
statements.
velocity = distance / time;
force = mass acceleration;
count = count + 1;
C has some operators which allow abbreviation of certain types
of arithmetic assignment statements.
Shorthand
Equivalent
i++; or
++i;
i = i + 1;
i--;
--i;
I = I – 1;
or
These operations are usually very efficient. They can be
combined with another expression.
X = a * b++; is equivalent to x = a * b;
x = b+ 1;
Versions where the operator occurs before the variable name
change
the
value
of
the
variable
before
evaluating
the
expression, so
x = --i * (a + b) ; is equivalent to i = i – 1;
x = I * (a + b);
These can cause confusion if you try to do too many things on
one command line. You are recommended to restrict your use of
++ and - to ensure that your programs stay readable.
Another shorthand notation is listed below
Shorthand
Equivalent
i+ = 10;
i = i + 10;
i -= 10;
i = i - 10;
i *= 10;
i = i * 10;
i /= 10;
i = i / 10;
These are simple to read and use.
Logical Connectors
These are the usual And, Or and Not operators.
Symbol
Meaning
&&
And
II
Or
!
Not
They are frequently used to combine relational operators, for
example
x < 20 && x >= 10
In C these logical connectives employ a technique known as lazy
evaluation. They evaluate their left hand operand, and then only
evaluate the right hand one if this is required. Clearly false &&
anything is always false, true 11 anything is always true. In such
cases the second test is not evaluated.
Not operates on a single logical value, its effect is to reverse its
state. Here is an example of its use.
if ( ! acceptable)
printf(“Not Acceptable !!\n”);
Special Characters
The following special patterns are used to represent a single
character in C programs. The leading backslash in the single
quotes indicates that more information is to follow.
C code
Meaning
’\014’
Bit pattern for Form Feed
’\n’
New line
’\t’
Tab
’\\’
Backslash
’\”
Single Quote
’\” ‘
Double Quote
’\b’
Backspace
’\r’
Carriage Return
’\f’
Form Feed
’\0’
NULL (String Terminator)
COMMANDS USED
1.
SWITCH-CASE STATEMANT:
The control statement that allows us to make a decision from the
number of choices is called a switch, or switch case - default.
Since these three keywords go together to make up the control
statement.
2.
FOR LOOP:
For is the most popular looping instruction. It allows us to
specify three things in a single line.
a)
Setting loop counter to initial value
b)
Testing the loop counter to determine whether its value has
reached the no. of repetitions desired
c)
Increasing the value of loop counter each time the program
segment within the loop has been executed.
3.
WHILE:
A while loop is ideally suited for cases where we want to do
something a fixed no. of times.
4.
BREAK:
We often come across situations where we want to jump out of a
loop instantly, without waiting to get back to conditional test.
The keyword break allows us to do this. When break is
encountered inside any loop, control automatically passes to the
first statement after the loop,
5.
INPORT:
Inport reads a word from a hardware port
Inportb reads a byte from a hardware port
6.
OUTPORT:
Outport outputs a word to a hardware port
Outportb outputs a byte to a hardware port
INTRODUCTION TO ISP – FLASH
PROGRAMMER
This ISP programmer can be used either for in system
programming or as a stand – alone spi programmer for ATMEL
programmable devices. The ISP 30a.zip file contains the main
program and the o/p port driver. Place all files in same folder.
The main screen view of the program is shown in figure
Following are the main features of this software,
Read and write the intel hex file read signature, lock and fuse
bits clear and file memory buffer verify with memory buffer
reload current hex file display buffer checksum program selected
lock bits and fuses auto detection of hardware.
The software does not provide the erase command because this
function is performed automatically during device programming.
If you are required to erase the controller, first use the clear
buffer command then program the controller, this will erase the
controller and also set the AVR device fuses to default seting.
Internal architecture of the ISP is shown below: