Professional Documents
Culture Documents
Anil Final
Anil Final
INTRODUCTION
1
INTRODUCTION
Embedded systems are finding increasing application not only in domestic applications
but also in areas of industrial automation, automobiles, power electronics, and defense and space
equipments. Microcontrollers are the modern building blocks for many embedded systems.
In this Project, we use the Keyboard to Interface directly with the LCD through the
Microcontroller to display the Scrolling message on LCD.
The Message typed through the Keyboard is displayed on the LCD through the Microcontroller.
The PC’s Keyboard can implement protocol so that the Keyboard sends data to the
microcontroller when both the KBD Data and KBD Clock Lines are high (Idle).
2
Block Diagram:
3
CHAPTER II
4
2. INTRODUCTION TO EMBEDDED SYSTEM
Since the embedded system is dedicated to specific tasks, design engineers can optimize
it, reducing the size and cost of the product, or increasing the reliability and performance. Some
embedded systems are mass-produced, benefiting from economies of scale.
Physically, embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems
controlling nuclear power plants. Complexity varies from low, with a single microcontroller
chip, to very high with multiple units, peripherals and networks mounted inside a large chassis or
enclosure.
In general, "embedded system" is not an exactly defined term, as many systems have
some element of programmability. For example, Handheld computers share some elements with
embedded systems — such as the operating systems and microprocessors which power them —
but are not truly embedded systems, because they allow different applications to be loaded and
peripherals to be connected.
5
Certain operating systems or language platforms are tailored for the embedded market,
such as Embedded Java and Windows XP Embedded. However, some low-end consumer
products use very inexpensive microprocessors and limited storage, with the application and
operating system both part of a single program. The program is written permanently into the
system's memory in this case, rather than being loaded into RAM (random access memory), as
programs on a personal computer are.
We are living in the Embedded World. You are surrounded with many embedded
products and your daily life largely depends on the proper functioning of these gadgets.
Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in
your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you to
do many of your tasks very effectively. Apart from all these, many controllers embedded in your
car take care of car operations between the bumpers and most of the times you tend to ignore all
these controllers.
In recent days, you are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out details about
latest technologies, new devices; fast applications which make you believe that your basic
survival is controlled by these embedded products. Now you can agree to the fact that these
embedded products have successfully invaded into our world. You must be wondering about
these embedded controllers or systems. What is this Embedded System?
The computer you use to compose your mails, or create a document or analyze the
database is known as the standard desktop computer. These desktop computers are manufactured
to serve many purposes and applications.
You need to install the relevant software to get the required processing facility. So, these
desktop computers can do many things. In contrast, embedded controllers carryout a specific
work for which they are designed. Most of the time, engineers design these embedded controllers
with a specific goal in mind. So these controllers cannot be used in any other place.
6
Theoretically, an embedded controller is a combination of a piece of microprocessor based
hardware and the suitable software to undertake a specific task.
In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market
acceptance of this particular family has driven many semiconductor manufacturers to develop
something new based on this particular architecture. Even after 25 years of existence,
semiconductor manufacturers still come out with some kind of device using this 8031 core.
From in-orbit embedded systems to jumbo jets to vital battlefield networks, designers of
mission-critical aerospace and defense systems requiring real-time performance, scalability, and
high-availability facilities consistently turn to the LynxOS® RTOS and the LynxOS-178 RTOS
for software certification to DO-178B.
Communications applications
"Five-nines" availability, CompactPCI hot swap support, and hard real-time response—
LynxOS delivers on these key requirements and more for today's carrier-class systems. Scalable
kernel configurations, distributed computing capabilities, integrated communications stacks, and
fault-management facilities make LynxOS the ideal choice for companies looking for a single
7
operating system for all embedded telecommunications applications—from complex central
controllers to simple line/trunk cards.
The Lynx Certifiable Stack (LCS) is a secure TCP/IP protocol stack designed especially for
applications where standards certification is required.
As the number of powerful embedded processors in consumer devices continues to rise, the
Blue Cat® Linux® operating system provides a highly reliable and royalty-free option for
systems designers.
And as the wireless appliance revolution rolls on, web-enabled navigation systems, radios,
personal communication devices, phones and PDAs all benefit from the cost-effective
dependability, proven stability and full product life-cycle support opportunities associated with
Blue Cat embedded Linux. Blue Cat has teamed up with industry leaders to make it easier to
build Linux mobile phones with Java integration.
For makers of low-cost consumer electronic devices who wish to integrate the LynxOS real-
time operating system into their products, we offer special MSRP-based pricing to reduce royalty
fees to a negligible portion of the device's MSRP.
Designers of industrial and process control systems know from experience that LynuxWorks
operating systems provide the security and reliability that their industrial applications
require.From ISO 9001 certification to fault-tolerance, POSIX conformance, secure partitioning
and high availability, we've got it all. Take advantage of our 20 years of experience.
8
CHAPTER-III
MICRO CONTROLLERS
9
MICROCONTROLLER VERSUS MICROPROCESSOR:
10
3.1 MICROCONTROLLERS FOR EMBEDDED SYSTEMS
In the Literature discussing microprocessors, we often see the term Embedded System.
Microprocessors and Microcontrollers are widely used in embedded system products. An
embedded system product uses a microprocessor (or Microcontroller) to do one task only. A
printer is an example of embedded system since the processor inside it performs one task only;
namely getting the data and printing it. Contrast this with a Pentium based PC. A PC can be used
for any number of applications such as word processor, print-server, bank teller terminal, Video
game, network server, or Internet terminal. Software for a variety of applications can be loaded
and run. Of course the reason a pc can perform myriad tasks is that it has RAM memory and an
operating system that loads the application software into RAM memory and lets the CPU run it.
In an Embedded system, there is only one application software that is typically burned
into ROM. An x86 PC contains or is connected to various embedded products such as keyboard,
printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on. Each one of
these peripherals has a Microcontroller inside it that performs only one task. For example, inside
every mouse there is a Microcontroller to perform the task of finding the mouse position and
sending it to the PC. Table 1-1 lists some embedded products.
11
Fig 3.2.1: Basic Layout of Microcontroller
The following list contains the modules typically found in a microcontroller. You can
find a more detailed description of these components in later sections.
Processor Core: The CPU of the controller. It contains the arithmetic logic unit, the control unit,
and the registers (stack pointer, program counter, accumulator register, register file . . .).
Memory: The memory is sometimes split into program memory and data memory. In larger
controllers, a DMA controller handles data transfers between peripheral components and the
memory.
Interrupt Controller: Interrupts are useful for interrupting the normal program flow in case of
(important) external or internal events. In conjunction with sleep modes, they help to conserve
power.
Timer/Counter: Most controllers have at least one and more likely 2-3 Timer/Counters, which
can be used to timestamp events, measure intervals, or count events. Many controllers also
contain PWM (pulse width modulation) outputs, which can be used to drive motors or for safe
breaking (antilock brake system, ABS). Furthermore the PWM output can, in conjunction with
an external filter, be used to realize a cheap digital/analog converter.
12
Digital I/O: Parallel digital I/O ports are one of the main features of microcontrollers. The
number of I/O pins varies from 3-4 to over 90, depending on the controller family and the
controller type.
Analog I/O: Apart from a few small controllers, most microcontrollers have integrated
analog/digital converters, which differ in the number of channels (2-16) and their resolution (8-
12 bits). The analog module also generally features an analog comparator. In some cases, the
microcontroller includes digital/analog converters.
Serial transmission is commonly used with modems and for non-networked communication
between computers, terminals and other devices. There are two primary forms of serial
transmission: Synchronous and Asynchronous. Depending on the modes that are supported by
the hardware, the name of the communication sub-system will usually include a A if it supports
Asynchronous communications, and a S if it supports Synchronous communications. Both forms
are described below.
Synchronous serial transmission requires that the sender and receiver share a clock with
one another, or that the sender provide a strobe or other timing signal so that the receiver knows
when to “read” the next bit of the data. In most forms of serial Synchronous communication, if
there is no data available at a given instant to transmit, a fill character must be sent instead so
that data is always being transmitted. Synchronous communication is usually more efficient
because only data bits are transmitted between sender and receiver, and synchronous
communication can be more costly if extra wiring and circuits are required to share a clock
signal between the sender and receiver.
13
A form of Synchronous transmission is used with printers and fixed disk devices in that
the data is sent on one set of wires while a clock or strobe is sent on a different wire. Printers and
fixed disk devices are not normally serial devices because most fixed disk interface standards
send an entire word of data for each clock or strobe signal by using a separate wire for each bit of
the word. In the PC industry, these are known as Parallel devices. The standard serial
communications hardware in the PC does not support Synchronous operations. This mode is
described here for comparison purposes only
When a word is given to the UART for Asynchronous transmissions, a bit called the
"Start Bit" is added to the beginning of each word that is to be transmitted. The Start Bit is used
to alert the receiver that a word of data is about to be sent, and to force the clock in the receiver
into synchronization with the clock in the transmitter. These two clocks must be accurate enough
to not have the frequency drift by more than 10% during the transmission of the remaining bits in
the word. (This requirement was set in the days of mechanical teleprinters and is easily met by
modern electronic equipment.)
After the Start Bit, the individual bits of the word of data are sent, with the Least
Significant Bit (LSB) being sent first. Each bit in the transmission is transmitted for exactly the
same amount of time as all of the other bits, and the receiver “looks” at the wire at approximately
halfway through the period assigned to each bit to determine if the bit is a 1 or a 0. For example,
if it takes two seconds to send each bit, the receiver will examine the signal to determine if it is a
1 or a 0 after one second has passed, then it will wait two seconds and then examine the value of
the next bit, and so on.
The sender does not know when the receiver has “looked” at the value of the bit. The
sender only knows when the clock says to begin transmitting the next bit of the word.When the
14
entire data word has been sent, the transmitter may add a Parity Bit that the transmitter generates.
The Parity Bit may be used by the receiver to perform simple error checking. Then at least one
Stop Bit is sent by the transmitter.
When the receiver has received all of the bits in the data word, it may check for the Parity
Bits (both sender and receiver must agree on whether a Parity Bit is to be used), and then the
receiver looks for a Stop Bit. If the Stop Bit does not appear when it is supposed to, the UART
considers the entire word to be garbled and will report a Framing Error to the host processor
when the data word is read. The usual cause of a Framing Error is that the sender and receiver
clocks were not running at the same speed, or that the signal was interrupted.Regardless of
whether the data was received correctly or not, the UART automatically discards the Start, Parity
and Stop bits. If the sender and receiver are configured identically, these bits are not passed to
the host.If another word is ready for transmission, the Start Bit for the new word can be sent as
soon as the Stop Bit for the previous word has been sent.
3.6 MICROCONTROLLER
ATmega8
15
Fig. 3.6.1 Pin Out of ATmega8
AVR core combines a rich instruction set with 32 general-purpose working registers. All the 32
registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent
registers to be accessed in one single instruction executed in one clock cycle. The resulting
architecture is more code efficient while achieving throughputs up to ten times faster than
conventional CISC microcontrollers.
16
Up to 16 MIPS Throughput at 16 MHz
On-chip 2-cycle Multiplier
• High Endurance Non-volatile Memory segments
17
Power-on Reset and Programmable Brown-out Detection
Internal Calibrated RC Oscillator
External and Internal Interrupt Sources
Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and Standby
• I/O and Packages
0 - 8 MHz (ATmega8L)
0 - 16 MHz (ATmega8)
• Power Consumption at 4 Mhz, 3V, 25°C
Active: 3.6 mA
Idle Mode: 1.0 mA
Power-down Mode: 0.5 μA
The Idle mode stops the CPU while allowing the USART, Two-wire interface, A/D
Converter, SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The
Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip
functions until the next External Interrupt or Hardware Reset.
In Power-save mode, the Asynchronous Timer continues to run, allowing the user to
maintain a timer base while the rest of the device is sleeping. The ADC Noise Reduction mode
stops the CPU and all I/O modules except Asynchronous Timer and ADC, to minimize switching
noise during ADC conversions.
18
By combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a
monolithic chip, the Atmel ATmega8 is a powerful microcontroller that provides a highly
flexible and cost-effective solution to many embedded control applications.
GND- Ground.
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit). The Port B output buffers have symmetrical drive characteristics with both high sink and
source capability. As inputs, Port B pins that are externally pulled low will source current if the
pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes
active, even if the clock is not running. Depending on the clock selection fuse settings, PB6 can
be used as input to the inverting Oscillator amplifier and input to the internal clock operating
circuit. Depending on the clock selection fuse settings, PB7 can be used as output from the
inverting Oscillator amplifier. If the Internal Calibrated RC Oscillator is used as chip clock
source, PB7..6 is used as TOSC2..1 input for the Asynchronous Timer/Counter2 if the AS2 bit in
ASSR is set.
Port C (PC5..PC0)
Port C is an 7-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit). The Port C output buffers have symmetrical drive characteristics with both high sink and
source capability. As inputs, Port C pins that are externally pulled low will source current if the
pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes
active, even if the clock is not running.
PC6/RESET
If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical
characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is
19
unprogrammed, PC6 is used as a Reset input. A low level on this pin for longer than the
minimum pulse length will generate a Reset, even if the clock is not running
Port D (PD7..PD0)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit). The Port D output buffers have symmetrical drive characteristics with both high sink and
source capability. As inputs, Port D pins that are externally pulled low will source current if the
pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes
active, even if the clock is not running.
RESET
Reset input. A low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a
reset.
AVCC
AVCC is the supply voltage pin for the A/D Converter, Port C (3..0), and ADC (7..6). It
should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it
should be connected to VCC through a low-pass filter. Note that Port C (5..4) use digital supply
voltage, VCC.
AREF
In the TQFP and QFN/MLF package, ADC7..6 serve as analog inputs to the A/D
converter. These pins are powered from the analog supply and serve as 10-bit ADC channels.
20
Fig 3.6.2.1 BLOCK DIAGRAM OF AT mega 8
The ATmega8 AVR is supported with a full suite of program and system development tools
including: C compilers, macro assemblers, program debugger/simulators, in-circuit emulators,
and evaluation kits.
A flexible interrupt module has its control registers in the I/O space with an additional
global interrupt enable bit in the Status Register. All interrupts have a separate interrupt vector in
the interrupt vector table. The interrupts have priority in accordance with their interrupt vector
21
position. The lower the interrupt vector address, the higher the priority. The I/O Memory can be
accessed directly, or as the Data Space locations following those of the Register File, 20h - 5Fh
All AVR ports have true Read-Modify-Write functionality when used as general digital I/O
ports. This means that the direction of one port pin can be changed without unintentionally
changing the direction of any other pin with the SBI and CBI instructions. The same applies
when changing drive value (if configured as output) or enabling/disabling of pull-up resistors (if
configured as input). Each output buffer has symmetrical drive characteristics with both high
sink and source capability. The pin driver is strong enough to drive LED displays directly. All
port pins have individually selectable pull-up resistors with a supply-voltage invariant resistance.
All I/O pins have protection diodes to both VCC and Ground.
All registers and bit references in this section are written in general form. Three I/O
memory address locations are allocated for each port, one each for the Data Register – PORTx,
Data Direction Register – DDRx, and the Port Input Pins – PINx. The Port Input Pins I/O
location is read only, while the Data Register and the Data Direction Register are read/write. In
addition, the Pull-up Disable – PUD bit in SFIOR disables the pull-up function for all pins in all
ports when set.
Most port pins are multiplexed with alternate functions for the peripheral features on the
device. Enabling the alternate function of some of the port pins does not affect the use of the
other pins in the port as general digital I/O.
The ports are bi-directional I/O ports with optional internal pull-ups. Each port pin consists of
three register bits: DDxn, PORTxn, and PINxn. The DDxn bits are accessed at the DDRx I/O
address, the PORTxn bits at the PORTx I/O address, and the PINxn bits at the PINxI/O address.
The DDxn bit in the DDRx Register selects the direction of this pin. If DDxn is written logic
one, Pxn is configured as an output pin. If DDxn is written logic zero, Pxn is configured as an
input pin. If PORTxn is written logic one when the pin is configured as an input pin, the pull-up
resistor is activated. To switch the pull-up resistor off, PORTxn has to be written logic zero or
the pin has to be configured as an output pin. The port pins are tri-stated when a reset condition
22
becomes active, even if no clocks are running. If PORTxn is written logic one when the pin is
configured as an output pin, the port pin is driven high (one). If PORTxn is written logic zero
when the pin is configured as an output pin, the port pin is driven low (zero). Normally, the pull-
up enabled state is fully acceptable, as a high-impedance environment will not notice the
difference between a strong high driver and a pull-up. If this is not the case, the PUD bit in the
SFIOR Register can be set to disable all pull-ups in all ports.
23
Fig 3.6.3.1 General I/O Block diagram
Independent of the setting of Data Direction bit DDxn, the port pin can be read through the
PINxn Register bit. The PINxn Register bit and the preceding latch constitute a synchronizer.
This is needed to avoid meta stability if the physical pin changes value near the edge of the
internal clock, but it also introduces a delay. The maximum and minimum propagation delays are
denoted tpd, max and tpd, min respectively.
24
Fig 3.6.3.2 Timing Diagram while Reading an 1
Consider the clock period starting shortly after the first falling edge of the system clock.
The latch is closed when the clock is low, and goes transparent when the clock is high, as
indicated by the shaded region of the “SYNC LATCH” signal. The signal value is latched when
the system clock goes low. It is clocked into the PINxn Register at the succeeding positive clock
edge. As indicated by the two arrows tpd, max and tpd, min, a single signal transition on the pin will be
delayed between ½ and 1½ system clock period depending upon the time of assertion.When
reading back a software assigned pin value, a nop instruction must be inserted. The out
instruction sets the “SYNC LATCH” signal at the positive edge of the clock. In this case, the
delay tpd through the synchronizer is one system clock period.
25
3.7 8-bit Timer/Counter Register Description
The FOC2 bit is only active when the WGM bits specify a non-PWM mode. However, for
ensuring compatibility with future devices, this bit must be set to zero when TCCR2 is written
when operating in PWM mode. When writing a logical one to the FOC2 bit, an immediate
Compare Match is forced on the waveform generation unit. The OC2 output is changed
according to its COM21:0 bits setting. Note that the FOC2 bit is implemented as a strobe.
Therefore it is the value present in the COM21:0 bits that determines the effect of the forced
compare. A FOC2 strobe will not generate any interrupt, nor will it clear the timer in CTC mode
using OCR2 as TOP. The FOC2 bit is always read as zero.
These bits control the counting sequence of the counter, the source for the maximum
(TOP) counter value, and what type of waveform generation to be used. Modes of operation
supported by the Timer/Counter unit are: Normal mode, Clear Timer on Compare Match (CTC)
mode, and two types of Pulse Width Modulation (PWM) modes
26
table 3.7.1 TCCR modes
• Bit 5:4 – COM21:0: Compare Match Output Mode
These bits control the Output Compare Pin (OC2) behavior. If one or both of the COM21:0 bits
are set, the OC2 output overrides the normal port functionality of the I/O pin it is connected to.
However, note that the Data Direction Register (DDR) bit corresponding to OC2 pin must be set
in order to enable the output driver. When OC2 is connected to the pin, the function of the
COM21:0 bits depends on the WGM21:0 bit setting.
Timer/Counter unit 8-bit counter. Writing to the TCNT2 Register blocks (removes) the Compare
Match on the following timer clock. Modifying the counter (TCNT2) while the counter is
running, introduces a risk of missing a Compare Match between TCNT2 and the OCR2 Register.
27
Output Compare Register – OCR2
Timer/Counter0 is a general purpose, single channel, 8-bit Timer/Counter module. The main
features are:
• Frequency Generator
Overview
A simplified block diagram of the 8-bit Timer/Counter is shown in Fig 3.8.1 . For the actual
placement of I/O pinsCPU accessible I/O Registers, including I/O bits and I/O pins, are shown in
bold. The device-specific I/O Register and bit locations are listed in the “8-bit Timer/Counter
Register Description”.
28
Fig 3.8.1 8-bit Timer/Counter
Registers
The Timer/Counter (TCNT0) is an 8-bit register. Interrupt request (abbreviated to Int. Req. in the
figure) signals are all visible in the Timer Interrupt Flag Register (TIFR). All interrupts are
individually masked with the Timer Interrupt Mask Register (TIMSK). TIFR and TIMSK are not
shown in the figure since these registers are shared by other timer units. The Timer/Counter can
be clocked internally or via the prescaler, or by an external clock source on the T0 pin. The
Clock Select logic block controls which clock source and edge the Timer/Counter uses to
increment its value. The Timer/Counter is inactive when no clock source is selected. The output
from the clock select logic is referred to as the timer clock (clkT0).
Definitions
Many register and bit references in this document are written in general form. A lower case “n”
replaces the Timer/Counter number, in this case 0. However, when using the register or bit
defines in a program, the precise form must be used i.e. TCNT0 for accessing Timer/Counter0
The Timer/Counter can be clocked by an internal or an external clock source. The clock source
29
is selected by the clock select logic which is controlled by the clock select (CS02:0) bits located
Counter Unit
The counting direction is always up (incrementing), and no counter clear is performed. The
counter simply overruns when it passes its maximum 8-bit value (MAX = 0xFF) and then
restarts from the bottom (0x00). In normal operation the Timer/Counter Overflow Flag (TOV0)
will be set in the same timer clock cycle as the TCNT0 becomes zero. The TOV0 Flag in this
case behaves like a ninth bit, except that it is only set, not cleared. However, combined with the
timer overflow interrupt that automatically clears the TOV0 Flag, the timer resolution can be
increased by software. A new counter value can be written anytime.
Timing Diagrams
The Timer/Counter is a synchronous design and the timer clock (clkT0) is therefore shown as a
clock enable signal in the following figures. The figures include information on when Interrupt
Flags are set. Figure contains timing data for basic Timer/Counter operation. The figure
30
shows the count sequence close to the MAX value.
31
CHAPTER-IV
32
Why would you want to interface the Keyboard? The IBM keyboard can be a cheap alternative
to a keyboard on a Microprocessor development system. Or maybe you want a remote terminal,
just couple it with a LCD Module.
Maybe you have a RS-232 Barcode Scanner or other input devices, which you want to use with
existing software which only allows you to key in numbers or letters. You could design yourself
a little box to convert RS-232 into a Keyboard Transmission, making it transparent to the
software.
An interfacing example is given showing the keyboard's protocols in action. This interfacing
example uses a 68HC705J1A MCU to decode an IBM AT keyboard and output the ASCII
equivalent of the key pressed at 9600 BPS.
Note that this page only deals with AT Keyboards. If you have any XT keyboards, you wish to
interface, consider placing them in a museum. We will not deal with this type of keyboard in this
document. XT Keyboards use a different protocol compared to the AT, thus code contained on
this page will be incompatible.
PC Keyboard Theory
The IBM keyboard you most probably have sitting in front of you, sends scan codes to
your computer. The scan codes tell your Keyboard Bios, what keys you have pressed or
released. Take for example the 'A' Key. The 'A' key has a scan code of 1C (hex). When
you press the 'A' key, your keyboard will send 1C down it's serial line. If you are still
holding it down, for longer than its typematic delay, another 1C will be sent. This keeps
occurring until another key has been pressed, or if the 'A' key has been released.
However your keyboard will also send another code when the key has been released.
Take the example of the 'A' key again, when released, the keyboard will send F0 (hex) to
tell you that the key with the proceeding scan code has been released. It will then send
1C, so you know which key has been released.
33
Your keyboard only has one code for each key. It doesn't care it the shift key has been
pressed. It will still send you the same code. It's up to your keyboard BIOS to determine
this and take the appropriate action. Your keyboard doesn't even process the Num Lock,
Caps Lock and Scroll Lock. When you press the Caps Lock for example, the keyboard
will send the scan code for the cap locks. It is then up to your keyboard BIOS to send a
code to the keyboard to turn on the Caps lock LED.
Now there are 101 keys and 8 bits make 256 different combinations, thus you only need
to send one byte per key, right?
Nop. Unfortunately a handful of the keys found on your keyboard are extended keys, and
thus require two scan code. These keys are preceded by a E0 (hex). But it doesn't stop at
two scan codes either. How about E1, 14, 77, E1, F0, 14, F0, 77! Now that can't be a
valid scan code? Wrong again. It's happens to be sent when you press the Pause/break
key. Don't ask me why they have to make it so long! Maybe they were having a bad day
or something?
When an extended key has been released, it would be expect that F0 would be sent to tell
you that a key has been released. Then you would expect E0, telling you it was an
extended key followed by the scan code for the key pressed. However this is not the case.
E0 is sent first, followed by F0, when an extended key has been released.
Keyboard Commands
Besides Scan codes, commands can also be sent to and from the keyboard. The following
section details the function of these commands. By no means is this a complete list.
These are only some of the more common commands.
Host Commands
34
These commands are sent by the Host to the Keyboard. The most common command would be
the setting/resetting of the Status Indicators (i.e. the Num lock, Caps Lock & Scroll Lock LEDs).
The more common and useful commands are shown below.
ED Set Status LED's - This command can be used to turn on and off the Num
Lock, Caps Lock & Scroll Lock LED's. After Sending ED, keyboard will
reply with ACK (FA) and wait for another byte which determines their
Status. Bit 0 controls the Scroll Lock, Bit 1 the Num Lock and Bit 2 the
Caps lock. Bits 3 to 7 are ignored.
F0 Set Scan Code Set. Upon Sending F0, keyboard will reply with ACK
(FA) and wait for another byte, 01-03 which determines the Scan Code
Used. Sending 00 as the second byte will return the Scan Code Set
currently in Use
FE Resend - Upon receipt of the resend command the keyboard will re-
35
transmit the last byte sent.
Commands
Now if the Host Commands are send from the host to the keyboard, then the keyboard
commands must be sent from the keyboard to host. If you think this way, you must be correct.
Below details some of the commands which the keyboard can send.
FA Acknowledge
FE Resend - Upon receipt of the resend command the Host should re-
transmit the last byte sent.
Scan Codes
36
The diagram below shows the Scan Code assigned to the individual keys. The Scan
code is shown on the bottom of the key. E.g. The Scan Code for ESC is 76. All the scan
codes are shown in Hex.
As you can see, the scan code assignments are quite random. In many cases the
easiest way to convert the scan code to ASCII would be to use a look up table.
Below is the scan codes for the extended keyboard & Numeric keypad.
37
The Keyboard's Connector
The PC's AT Keyboard is connected to external equipment using four wires. These wires
are shown below for the 5 Pin DIN Male Plug & PS/2 Plug.
5 Pin DIN
1. KBD Clock
2. KBD Data
3. N/C
4. GND
5. +5V (VCC)
PS/2
1. KBD Clock
2. GND
3. KBD Data
4. N/C
5. +5V (VCC)
38
6. N/C
A fifth wire can sometimes be found. This was once upon a time implemented as a
Keyboard Reset, but today is left disconnected on AT Keyboards. Both the KBD Clock
and KBD Data are Open Collector bi-directional I/O Lines. If desired, the Host can talk
to the keyboard using these lines.
Note: Most keyboards are specified to drain a maximum 300mA. This will need to be
considered when powering your devices
Keyboard to Host
The keyboard is free to send data to the host when both the KBD Data and KBD Clock
lines are high (Idle). The KBD Clock line can be used as a Clear to Send line. If the host
takes the KBD Clock line low, the keyboard will buffer any data until the KBD Clock is
released, ie goes high. Should the Host take the KBD Data line low, then the keyboard
will prepare to accept a command from the host.
39
CHAPTER V
40
Circuit Description and operation
41
Schematic Diagram:
Schematic Diagram:
42
Figure 1: Schematic Diagram
Scan codes:
43
Kit Layou t
44
CHAPTER-VI
POWER SUPPLY
This type of regulation is ideal for having a simple variable bench power supply.
Actually this is quite important because one of the first projects a hobbyist should
undertake is the construction of a variable regulated power supply. While a dedicated
supply is quite handy e.g. 5V or 12V, it's much handier to have a variable supply on hand,
especially for testing.
45
Most digital logic circuits and processors need a 5 volt power supply. To use these
parts we need to build a regulated 5 volt source. Usually you start with an unregulated
power To make a 5 volt power supply, we use a LM7805 voltage regulator IC (Integrated
Circuit). The IC is shown below.
• Brief description of operation: Gives out well regulated +5V output, output current
capability of 100 mA
• Availability of components: Easy to get, uses only very common basic components
46
• Design testing: Based on datasheet example circuit, I have used this circuit
successfully as part of many electronics projects
• Component costs: Few dollars for the electronics components + the input
transformer cost
47
Fig 8.3.1 Circuit DIAGRAM of Power supply
48
CHAPTER-X
CONCLUSION
CONCLUSION
49
As next-generation electronic information systems evolve, it is critical that all people
have access to the equipments via computer systems. Examples of developing and future
information systems include interactive computer and connected devices.
This Project presents a miniature robot which basically does the surveillance activities
with the help of a wired webcam.
50
CHAPTER-X1
RESULT
RESULT
51
Our project is executed successfully. We are operating the robot through RF transmitter
according to the program the two DC motors and stepper motor is controlled. If we press 1 the
robot moves forward direction, if we press 2 then the robot takes right turn. If we press 3 the
robot takes left turn, if we press 4 then the robot gets stop. If we press 1&2 simultaneously then
the stepper motor rotates web cam in clock wise direction.
The transmitter transmits the signals then receiver receives the signals up to 32
meters. The signals penetrate through the walls of buildings and they are not light sensitive not
as sensitive to weather/environmental conditions. We are using Ask modulation for the
transmission purpose. We are going to control two devices using this project.
We are using hardware equipments like power supply Circuit, Atmega8
microcontroller, HT12E encoder, TLP434A transmitter, RLP434A receiver, HT12D decoder,
Relays and two DC motors and one stepper motor for this project. We are using WINAVR to
compile the source file and generate the hex code and ATProg to program the microcontroller.
REFERENCE
52
Prentice Hall of India-2003
2. Das .J-"Principles of Digital Communication"-1st edition-Published by
New Age International Publication 1986
3. Muhammad Ali Mazidi-"The 8051 Microcontroller and Embedded System
Using Assemble C"-2nd edition-Published by Pearson Education 2006
4. Rajiv Kapadia-"8051 Micro Controllers and Embedded System"-
1st edition-Published by JaicoBooks 2004
5. RAY.A.K -"Advanced Micro Processors and Peripherals"-2nd edition-
Published by TATA McGraw-Hill 2006-07
6. Simon Hawkins-"Digital Communication"-1st edition-Published by Wiley India 2009
7. www.chetanasprojects.com
8. www.1000projects.com
9. www.microcontrollers.com
53