Ilights Documentation
-
Upload
naresh-maragani -
Category
Documents
-
view
218 -
download
0
Transcript of Ilights Documentation
-
8/2/2019 Ilights Documentation
1/40
3. RF COMMUNICATION
3.1 Introduction
Companies look for any advantage to remain competitive in todays high-speed business
climate. They work to streamline their supply chain management systems, knowing that even a
few minutes in order processing time can make a huge difference in getting product to end user.
And that can be the difference between who gets the job and who doesnt - even who gets to stay
in business and who doesn't. One of the ways to save minutes that turn into competitive advantages
is to save seconds on highly repetitive tasks by using fast, accurate radio frequency (RF)
technology. More and more companies are evaluating RF technology because they have learned
that wirelessly transmitting data can provide tremendous time and cost savings.
RF communication works by creating electromagnetic waves at a source and being able
to pick up those electromagnetic waves at a particular destination. These electromagnetic waves
travel through the air at near the speed of light. The wavelength of an electromagnetic signal is
inversely proportional to the frequency; the higher the frequency, the shorter the wavelength.
Frequency is measured in Hertz (cycles per second) and radio frequencies are measured
in kilohertz (KHz or thousands of cycles per second), megahertz (MHz or millions of cycles per
second) and gigahertz (GHz or billions of cycles per second). Higher frequencies result in shorter
wavelengths. The wavelength for a 900 MHz device is longer than that of a 2.4 GHz device.
In general, signals with longer wavelengths travel a greater distance and penetrate
through, and around objects better than signals with shorter wavelengths.
3.2 What is RF?
When you hear someone say "RF," he or she is generally referring to radio frequency
data communications. In the past, it has also been referred to as RFDC, to differentiate it from
-
8/2/2019 Ilights Documentation
2/40
radio frequency identification (RFID), which is a different and potentially complementary
technology. Wireless local area networks (WLANs) are a very popular form of RFDC.
RF is the wireless transmission of data by digital radio signals at a particular frequency. It
maintains a two-way, online radio connection between a mobile terminal and the host computer.
The mobile terminal, which can be portable, even worn by the worker, or mounted on a forklift
truck, collects and displays data at the point of activity. The host computer can be a PC, a
minicomputer or a much larger mainframe.
The end result is a seamless flow of information to and from the host, allowing workers
to go wherever they need to go to get their job done without fear of being out of touch with the
data they need. RFDC improves the timeliness of information, and therefore the value of
information, especially in time-sensitive operating environments like cross-dock, make-to-order
manufacturing and just-in-time replenishment.
3.3 System Overview
A basic RF system consists of up to three components:
A mobile RF terminal;
A base station (sender/receiver); and A network controller.
The mobile terminal forms the link (interface) between the user and the RF system. It collects the
data to be sent, receives instructions or data from the host, and allows the user to view the data or
messages on its display screen. The terminal also has a radio sender/receiver and antenna to
provide communication with the rest of the system. The base station has a system antenna and
acts as a bridge between wireless and wired networks. It is connected to a controller, (controller
can be a separate device or included in the base station), which in turn is connected to the host.
The controller receives and processes information it gets from the host computer and passes
this information to the mobile terminals via the base station.
3.4 The RF Advantage
-
8/2/2019 Ilights Documentation
3/40
The advantages of a RF communication system are many. Start with the simple fact that
if it is wireless, you don't have to lay cable all over your facility. Cable is expensive, less flexible
than RF coverage and is prone to damage. For new facilities, implementing a wireless
infrastructure may be more cost effective than running cable through industrial environments,
especially if the space configuration may change to support different storage space allocation or
flexible manufacturing stations.
Accessibility is a key benefit. If workers are within range of the system and they always
should be if a proper site survey is performed (as explained on page 8) they are always in touch
with their data. This advantage cannot be overstated. To always have your data literally at your
fingertips whenever needed means there is no break in productivity and no empty or deadhead
trips to a stationary terminal, docking station or dispatch location to receive pick or putaway
instructions. Critical decisions can be made and action taken immediately at the point of activity.
Less wasted time means you can do significantly more, faster, without adding additional
employees.
Other general advantages of real-time RF communication include a significant
improvement in order accuracy (>99%), the elimination of paperwork, replacement of time-
consuming batch processing by rapid real-time data processing, prompt response times and
improved service levels. Complementing a real-time data collection system with automated data
entry by bar code scanning or another automatic data collection technology improves the
accuracy of information and eliminates the need for redundant data entry, which provides
another set of time- and cost-saving advantages.
Many points in the supply chain can realize important advantages of accurate, real-time
data that RF provides. Here are some examples of RF applied to a few common environments.
3.5 RF Transmitter
-
8/2/2019 Ilights Documentation
4/40
RF transmitters are widely used in radio frequency communications systems, such as
cellular and satellite mobile phone communications devices. Such wireless communication
device includes a built-in radio transceiver or is coupled to an associated radio transceiver. The
RF transmitter may be part of an RF transceiver, wherein a duplexer or RF switch is placed
between the RF power amplifier and the antenna, so that received communication signals from
the antenna may be switched to a receive circuit. An RF transmitter includes a data modulation
device, intermediate frequency circuits, and a power amplifier. The modulator modulates an
input signal and converts raw data into baseband signals in accordance with the particular
wireless communication standard. The intermediate frequency circuits mix the baseband signals
with one or more local oscillations to produce RF signals. In order to make it possible to raise the
power of the RF signals for transmission, the transmitter is provided with a power amplifier
which is coupled to the modulator to amplify the modulated input signal. The radio frequency
power amplifier is connected to an antenna that transmits the amplified modulated input signal.
Compact RF transmitters are widely employed to transmit radiating signals for use in connection
with remote signal communication systems. Compact handheld transmitters are usually battery
operated and are generally required to accommodate a compact enclosure and to exhibit efficient
power usage.
RF Communication
o Widely used, including Bluetooth, Radios, Cell phones, Satellite etco Wide range, from few meters to millions of kilometers (Can be Used to control
Robots in Mars)
o Does not require two devices to be in line of sight.o Can cross many obstacleso Circuits can be complicated and costly.
3.6 RF Receiver
In an RF receiver, an incoming RF signal is first passed through an RF bandpass filter to
remove signal components outside of the frequency range of the desired signal. The resulting
http://www.electronics-manufacturers.com/products/http://www.electronics-manufacturers.com/products/http://www.electronics-manufacturers.com/products/http://www.electronics-manufacturers.com/products/http://www.electronics-manufacturers.com/products/http://www.electronics-manufacturers.com/products/ -
8/2/2019 Ilights Documentation
5/40
filtered signal is then usually amplified by a low noise amplifier. A radio frequency receiver
includes a frequency converter for converting a received radio frequency signal to an
intermediate frequency (IF) signal. An IF filter is coupled to the frequency converter for limiting
the IF signal to the bandwidth of a communication channel. The band -limited signal is applied
to a demodulator where the signal is processed to recover the original baseband frequency signal.
A low power RF receiver circuit comprises a low noise preamplifier and double-balanced mixer,
using novel monolithic micro strip inductors and transformers for radio frequency IC (integrated
circuit) applications using submicron bipolar CMOS process technology. RF receivers normally
include a means for preventing tracking error, which is the deviation between a tuning frequency
of an RF tuning circuit and a frequency of an RF signal to be converted to a desired IF signal at a
mixer circuit. A direct-conversion receiver in a radio communication system is configured to
have a varying gain in order to track the varying signal strength of the received RF signal. Radio
frequency (RF) receivers for cellular phone base stations must provide high degrees of both
selectivity and sensitivity. An important measure of a receiver's performance is its sensitivity and
one means for measuring this sensitivity is to compare the measured bit error rate (BER) of a
received signal with the signal to noise ratio. Antennas are provided as accessories of RF
receivers in order to provide the receivers with the capability of receiving RF signals that are
transmitted over the air.
3.7 How does RF communication System Work?
Imagine an RF transmitter wiggling an electron in one location. This wiggling electron
causes a ripple effect, somewhat akin to dropping a pebble in a pond. The effect is an
electromagnetic (EM) wave that travels out from the initial location resulting in electrons
wiggling in remote locations. An RF receiver can detect this remote electron wiggling.
The RF communication system then utilizes this phenomenon by wiggling electrons in a
specific pattern to represent information. The receiver can make this same information availableat a remote location; communicating with no wires. In most wireless systems, a designer has two
overriding constraints: it must operate over a certain distance (range) and transfer a certain
amount of information within a time frame (data rate). Then the economics of the system must
work out (price) along with acquiring government agency approvals (regulations and licensing).
http://www.electronics-manufacturers.com/products/http://www.electronics-manufacturers.com/products/ -
8/2/2019 Ilights Documentation
6/40
3.8 Range Determination
In order to accurately compute rangeit is essential to understand a few terms:
dB - Decibels
Decibels are logarithmic units that are often used to represent RF power. To convert from watts
to dB: Power in dB = 10* (log x) where x is the power in watts.
Another unit of measure that is encountered often is dBm (dB milliwatts). The conversion
formula for it is Power in dBm = 10* (log x) where x is the power in milliwatts.
Line-of-site (LOS)
Line-of-site when speaking of RF means more than just being able to see the receiving antenna
from the transmitting antenna. In, order to have true line-of-site no objects (including trees,
houses or the ground) can be in the Fresnel zone. The Fresnel zone is the area around the visual
line-of-sight that radio waves spread out into after they leave the antenna. This area must be clear
or else signal strength will weaken.
There are essentially two parameters to look at when trying to determine range.
Transmit Power:- Transmit power refers to the amount of RF power that comes out of the
antenna port of the radio. Transmit power is usually measured in Watts, milliwatts or dBm.
Receiver sensitivity:-Receiver sensitivity refers to the minimum level signal the radio can
demodulate. It is convenient to use an example with sound waves; Transmit power is how loud
someone is yelling and receive sensitivity would be how soft a voice someone can hear. Transmit
power and receive sensitivity together constitute what is known as link budget. The link
budget is the total amount of signal attenuation you can have between the transmitter and
receiver and still have communication occur.
Example:
Maxstream 9XStream TX Power: 20dBm
Maxstream 9XStream RX Sensitivity: -110dBm
Total Link budget: 130dBm.
-
8/2/2019 Ilights Documentation
7/40
For line-of-site situations, a mathematical formula can be used to figure out the approximate
range for a given link budget. For non line-of-site applications range calculations are more
complex because of the various ways the signal can be attenuated.
3.9 RF communications and data rate
Data rates are usually dictated by the system - how much data must be transferred and
how often does the transfer need to take place. Lower data rates, allow the radio module to have
better receive sensitivity and thus more range. In the XStream modules the 9600 baud module
has 3dB more sensitivity than the 19200 baud module. This means about 30% more distance in
line-of-sight conditions. Higher data rates allow the communication to take place in less time,
potentially using less power to transmit.
3.10 RF Module
A RF Module is a small circuit pre built and tested. They come in Pair. One is RX or the
receiver and other is a TX or Transmitter. The one we will be using is a low cost module. They
have reasonable range and works very good. Typical data rate is 1000 bits per seconds.
Fig 3.1 Pin Diagrams of TX and RX
-
8/2/2019 Ilights Documentation
8/40
They have very low pin count. This is because they are highly modular in design. The PINs are
TX1. Antenna2. Vcc (Positive Supply)3. DATA (Data Input)4. GND
RX5. Antenna6. GND7. GND8. Vcc (Positive Supply)9. Vcc (Positive Supply)10.DATA11.DATA12.GND
How RF Module Works
Working of RF Modules is simple but with a little trick. The working is shown in figure
below.
-
8/2/2019 Ilights Documentation
9/40
Fig 3.2 Working of RF Module.
Here whatever digital data you input on "Data In" of TX is available on "Data Out" of RX.
Say, if you set "data in" high, the "data out" will become high as well. But here lies the trick! The
fact is that you cannot Keep Logic HIGH or LOW for a Long period of time, say for a few
millisecond second. If you apply a logic low on "data in" the "data out" will become low but only
for few milliseconds and it will start oscillating (become high/low repeatedly) after that. Same
thing will happen if you set "data in" to high state.
Let us assume we have connected the RF modules with MCUs as shown below.
-
8/2/2019 Ilights Documentation
10/40
Fig 3.3RF Modules connected to USART of Microcontrollers.
When the TX unit is switched off or not transmitting data, then as I said the "data out" of RX
will be oscillating high and low and as this is connected to RX of MCU's USART, the MCU#2
will be receiving garbage data. And when TX unit will send some data, MCU#2 will also be
receiving them. So MCU #2 is always receiving data, even when MCU#1 is not sending
anything. So there must be a mechanism to differentiate real data with garbage data.
3.11 RF Transmitter
General Description:
The ST-TX01-ASK is an ASK Hybrid transmitter module. ST-TX01-ASK is designed by the Saw Resonator, with an effective low cost, small size,
and simple-to-use for designing.
Frequency Range: 315 / 433.92 MHZ. Supply Voltage: 3~12V. Output Power : 4~16dBm
Applications
Wireless security systems
-
8/2/2019 Ilights Documentation
11/40
-
8/2/2019 Ilights Documentation
12/40
Fig.4.5 Interfacing TX module to a Micro controller
3.12 RF Receiver
General Description:
The ST- RX04-ASK is an ASK superhetro receiver module with PLL synthesizer andcrystal oscillator.
The circuit shape is: PLL. Receiver Frequency: 315 / 433.92 MHZ Operation Voltage 5V IF Frequency: 500k Typical sensitivity: -105dBm Supply Current: 2.3mA
Applications:
Car security system Wireless security systems Sensor reporting Automation system Remote Keyless entry
-
8/2/2019 Ilights Documentation
13/40
Features
Low power consumption. Easy for application. Operation voltage: 5 Volts. Available frequency at : 315/434 MHz
Fig 4.6 315/434MHz ASK Receiver
Fig 4.7 Pin Diagram of Receiver
-
8/2/2019 Ilights Documentation
14/40
4. INTRODUCTION TO EMBEDDED SYSTEM
4.1 What is a System?
A systems is something that maintains its existence and functions as a whole through theinteraction of its parts. E.g. Body, Mankind, Access Control, etc
A system is a part of the world that a person or group of persons during some timeinterval and for some purpose choose to regard as a whole, consisting of interrelated
components, each component characterized by properties that are selected as being
relevant to the purpose.
System Constituents
4.2 EMBEDDED SYSTEM:
We can define an embedded system as a computing device, built in to a device that is
not a computer, and meant for doing specific computing tasks.
An embedded system is a special-purpose computer system usually built into aEnvironment connected to systems through sensors , actuators and other I/O
interfaces.
Embedded system must meet timing & other constraints imposed on it byenvironment
-
8/2/2019 Ilights Documentation
15/40
Typical Embedded System
Technically, there are prevalent and common characteristics of embedded
systems. From a programmer's perspective the following components are minimum: Central
Processing Unit (CPU), Random Access Memory (RAM), Programmable Read Only Memory
(PROM) or Erasable PROM (EPROM), and Input/Output (I/O) space.
Micro-processor:
The CPU is a unit that centrally fetches and processes a set of general purpose
instructions. The CPU instruction set includes instructions for data transfer operations, ALU
operations, stack operations, I/P &O/P operations and program control sequencing and
supervising operations. Any CPU must process the following basic functionality units:
1. A control unit to fetch and control the sequential processing of given commands or
instruction and for communicating with the rest of the system.
2. An ALU for the arithmetic and logic operations on the bytes or words. It may be capable
of processing 8,16,32or 64-bit words at an instant.
3. A microprocessor is a single VLSI chip that has a chip and may also have some other
units that are additionally present and that result in faster processing of instructions.
-
8/2/2019 Ilights Documentation
16/40
Microcontroller
A microcontroller is a single chip VLSI unit (also called microcomputer) which though having
limited computational capabilities posses an enhanced I/P, O/P capabilities and a number of on-chip
functional units micro-controllers are particularly suited for use in embedded systems for real time
applications with on-chip program memory and devices.
4.3 LIFE CYCLE
REQUIRMENTS
Finalize the functional requirement of the system that has to be implemented
ANALYSIS
Analyze the requirements and finalise the system requirements
IMPLEMENTATION
Based on the hardware design make the layout of the PCB and design the routing
Get the PCB fabricated Mount the components on to the PCB
-
8/2/2019 Ilights Documentation
17/40
PROGRAMMING
Use the designated tools for programming the microcontroller or processor whichever is selected
Atmel Kiel 'C- compiler Uc flash programmer
Micro chip Mplab IDE
ICD2 ARM-GCC,ADS
TESTING/DEBUGGING
Hardware debugging Software debugging Functionality test
PACKAGING/IMPLEMENTATION
Mount the module into the designed enclosure Install the designed system in the required application area
-
8/2/2019 Ilights Documentation
18/40
-
8/2/2019 Ilights Documentation
19/40
The Essence
An embedded system is a microcontroller-based, software driven, reliable, real-time control
system, autonomous, or human or network interactive, operating on diverse physical variables
and in diverse environments and sold into a competitive and cost conscious market .
4.4 Software design and working of embedded systems:
In the design of the software, it simply has a loop called control loop. The loop
calls subroutines. Each subroutine manages a part of the hardware or software. Interrupts
generally set flags, or update counters that are read by the rest of the software.
A simple API disables and enables interrupts. Done right, it handles nested calls in nested
subroutines, and restores the preceding interrupt state in the outermost enable. This is one of the
simplest methods of creating an exokernel. There is some sort of subroutine in the loop to
manage a list of software timers, using a periodic real time interrupt. Hardware events fail about
once in a trillion times. A change of state stores a different function into the pointer. The function
pointer is executed every time the loop runs. Many designers read each IO device once per loop,
and storing the result so the logic acts on consistent values
-
8/2/2019 Ilights Documentation
20/40
5. HARDWARE DESCRIPTION
5.1 Microcontroller Unit (AT89C51)
Introduction
A Micro controller consists of a powerful CPU tightly coupled with memory, various I/O
interfaces such as serial port, parallel port timer or counter, interrupt controller, data acquisition
interfaces-Analog to Digital converter, Digital to Analog converter, integrated on to a single
silicon chip.
If a system is developed with a microprocessor, the designer has to go for externalmemory such as RAM, ROM, EPROM and peripherals. But controller is provided all these
facilities on a single chip. Development of a Micro controller reduces PCB size and cost of
design.
One of the major differences between a Microprocessor and a Micro controller is that a
controller often deals with bits not bytes as in the real world application.
Intel has introduced a family of Micro controllers called the MCS-51.
The Major Features:
Compatible with MCS-51 products 4k Bytes of in-system Reprogrammable flash
memory
Fully static operation: 0HZ to 24MHZ Three level programmable clock 128 * 8bit timer/counters Six interrupt sources Programmable serial channel
-
8/2/2019 Ilights Documentation
21/40
Low power idle power-down modesWhy AT 89C51
The system requirements and control specifications clearly rule out the use of 16, 32
or 64 bit micro controllers or microprocessors. Systems using these may be earlier to implement
due to large number of internal features. They are also faster and more reliable but, 8-bit micro
controller satisfactorily serves the above application. Using an inexpensive 8-bit Microcontroller
will doom the 32-bit product failure in any competitive market place.
Coming to the question of why to use AT89C51 of all the 8-bit microcontroller available
in the market the main answer would be because it has 4 Kb on chip flash memory which is just
sufficient for our application. The on-chip Flash ROM allows the program memory to be
reprogrammed in system or by conventional non-volatile memory Programmer. Moreover
ATMEL is the leader in flash technology in todays market place and hence using AT 89C51 is
the optimal solution.
AT89C51 MICROCONTROLLER ARCHITECTURE
The 89C51 architecture consists of these specific features:
Eightbit CPU with registers A (the accumulator) and B Sixteen-bit program counter (PC) and data pointer (DPTR) Eight- bit stack pointer (PSW) Eight-bit stack pointer (Sp) Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51) Internal RAM of 128 bytes:
1. Four register banks, each containing eight registers2.
Sixteen bytes, which may be addressed at the bit level
3. Eighty bytes of general- purpose data memory Thirtytwo input/output pins arranged as four 8-bit ports:p0-p3 Two 16-bit timer/counters: T0 and T1 Full duplex serial data receiver/transmitter: SBUF
-
8/2/2019 Ilights Documentation
22/40
Control registers: TCON, TMOD, SCON, PCON, IP, and IE Two external and three internal interrupts sources. Oscillator and clock circuits.
Fig 4.8 Functional block diagram of micro controller
-
8/2/2019 Ilights Documentation
23/40
Types of memory:-The 89C51 have three general types of memory. They are on-chip memory,
external Code memory and external Ram. On-Chip memory refers to physically existing
memory on the micro controller itself. External code memory is the code memory that resides
off chip. This is often in the form of an external EPROM. External RAM is the Ram that resides
off chip. This often is in the form of standard static RAM or flash RAM.
a) Code memory
Code memory is the memory that holds the actual 89C51 programs that is to be run. This
memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have
4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory
is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA
b) Internal RAM
The 89C51 have a bank of 128 of internal RAM. The internal RAM is found on-chip. So
it is the fastest Ram available. And also it is most flexible in terms of reading and writing.
Internal Ram is volatile, so when 89C51 is reset, this memory is cleared. 128 bytes of internal
memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains
8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These
bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are
numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB
and CLR.
FLASH MEMORY:
Flash memory (sometimes called "flash RAM") is a type of constantly-powered non
volatile that can be erased and reprogrammed in units of memory called blocks. It is a variation
of electrically erasable programmable read-only memory (EEPROM) which, unlike flash
memory, is erased and rewritten at the byte level, which is slower than flash memory updating.
Flash memory is often used to hold control code such as the basic input/output system (BIOS) in
a personal computer. Flash memory gets its name because the microchip is organized so that a
section of memory cells are erased in a single action or "flash." The erasure is caused by Fowler-
Nordheim tunneling in which electrons pierce through a thin dielectric material to remove an
electronic charge from a floating gate associated with each memory cell. Intel offers a form of
-
8/2/2019 Ilights Documentation
24/40
flash memory that holds two bits (rather than one) in each memory cell, thus doubling the
capacity of memory without a corresponding increase in price.
Flash memory is used in digital cellular phones, digital cameras, LAN switches, PC
Cards for notebook computers, digital set-up boxes, embedded controllers, and other devices.
Memory Type
Features
FLASH Low-cost, high-density, high-speed
architecture; low power; high reliability
ROMRead-Only Memory
Mature, high-density, reliable, low cost;time-consuming mask required, suitable for
high production with stable code
SRAM
Static Random-Access Memory
Highest speed, high-power, low-density
memory; limited density drives up cost
EPROM
Electrically Programmable Read-Only
Memory
High-density memory; must be exposed to
ultraviolet light for erasure
EEPROMorE2PROM
Electrically Erasable Programmable Read-
Only Memory
Electrically byte-erasable; lower reliability,
higher cost, lowest density
DRAM
Dynamic Random Access Memory
High-density, low-cost, high-speed, high-
power
-
8/2/2019 Ilights Documentation
25/40
Fig 4.10 Pin diagram of AT89C51
PIN DESCRIPTION:
VCC: Supply voltage.
GND: Ground.
Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink
eight TTL inputs. When ones are written to port 0 pins, the pins can be used as high impedance
inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during
-
8/2/2019 Ilights Documentation
26/40
accesses to external program and data memory. In this mode P0 has internal pull-ups. Port 0 also
receives the code bytes during Flash programming, and outputs the code bytes during program
verification. External pull-ups are required during program verification.
Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. Port 1 also receives the low-order
address bytes during Flash programming and verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers
can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address
byte during fetches from external program memory and during accesses to external data
memories that use 16-bit addresses (MOVX @DPTR)Port 2 emits the contents of the P2 Special
Function Register. Port 2 also receives the high-order address bits and some control signals
during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled
low will source current (IIL) because of the pull-ups.
Port 3 also serves the functions of various special features of the AT89C51 as listed below:
Port 3 also receives some control signals for Flash programming and verification
-
8/2/2019 Ilights Documentation
27/40
Table 4.2 Port pins and their alternate functions
RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during Flash
programming. In normal operation ALE is emitted at a constant rate of 1/6the oscillator
frequency, and may be used for external timing or clocking purposes.
.
PSEN:
Program Store Enable is the read strobe to external program memory. When the AT89C51 is
executing code from external program memory, PSEN is activated twice each machine cycle,
except that two PSEN activations are skipped during each access to external data memory.
-
8/2/2019 Ilights Documentation
28/40
EA/VPP:
External Access Enable EA must be strapped to GND in order to enable the device to fetch code
from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the 12-
volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt
VPP.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2:
It is the Output from the inverting oscillator amplifier.
REGISTERS:
In the CPU, registers are used to store information temporarily. That information could
be a byte of data to be processed, or an address pointing to the data to be fetched. The vast
majority of 8051 registers are 8bit registers. In the 8051 there is only one data type: 8bits. The
8bits of a register are shown in the diagram from the MSB (most significant bit) D7 to the LSB
(least significant bit) D0. With an 8-bit data type, any data larger than 8bits must be broken into
8-bit chunks before it is processed. Since there are a large number of registers in the 8051, we
will concentrate on some of the widely used general-purpose registers and cover special registers
in future chapters.
-
8/2/2019 Ilights Documentation
29/40
D7 D6 D5 D4 D3 D2 D1 D0
The most widely used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4,
R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the above registers are 8-
bits, except DPTR and the program counter. The accumulator, register A, is used for all
arithmetic and logic instructions.
SFRs (Special Function Registers)
Among the registers R0-R7 is part of the 128 bytes of RAM memory. What about
registers A, B, PSW, and DPTR? Do they also have addresses? The answer is yes. In the 8051,
registers A, B, PSW and DPTR are part of the group of registers commonly referred to as SFR
(special function registers). There are many special function registers and they are widely used.
The SFR can be accessed by the names (which is much easier) or by their addresses. For
example, register A has address E0h, and register B has been ignited the address F0H, as shown
in table.
The following two points should noted about the SFR addresses.
1. The Special function registers have addresses between 80H and FFH. Theseaddresses are above 80H, since the addresses 00 to 7FH are addresses of RAM
memory inside the 8051.
2. Not all the address space of 80H to FFH is used by the SFR. The unused locations80H to FFH are reserved and must not be used by the 8051 programmer.
Regarding direct addressing mode, notice the following two points: (a) the address value
is limited to one byte, 00-FFH, which means this addressing mode is limited to accessing RAM
locations and registers located inside the 8051. (b) If you examine the lst
file for an assembly
language program, you will see that the SFR registers names are replaced with their addresses as
listed in table.
-
8/2/2019 Ilights Documentation
30/40
Table 4.3Special Function Registers with Address
Symbol Name Address
ACC Accumulator 0E0H
B B register 0F0H
PSW Program status word 0D0H
SP Stack pointer 81H
DPTR Data pointer 2 bytes
DPL Low byte 82H
DPH High byte 83H
P0 Port0 80H
P1 Port1 90H
P2 Port2 0A0H
P3 Port3 0B0H
IP Interrupt priority control 0B8H
IE Interrupt enable control 0A8H
TMOD Timer/counter mode control 89H
TCON Timer/counter control 88H
T2CON Timer/counter 2 control 0C8H
T2MOD Timer/counter mode2 control 0C9H
TH0 Timer/counter 0high byte 8CH
TL0 Timer/counter 0 low byte 8AH
-
8/2/2019 Ilights Documentation
31/40
TH1 Timer/counter 1 high byte 8DH
TL1 Timer/counter 1 low byte 8BH
TH2 Timer/counter 2 high byte 0CDH
TL2 Timer/counter 2 low byte 0CCH
RCAP2H T/C 2 capture register high byte 0CBH
RCAP2L T/C 2 capture register low byte 0CAH
SCON Serial control 98H
SBUF Serial data buffer 99H
PCON Power control 87H
A Register (Accumulator)
This is a general-purpose register which serves for storing intermediate results during operating.
A number (an operand) should be added to the accumulator prior to execute an instruction upon
it. Once an arithmetical operation is preformed by the ALU, the result is placed into the
accumulator. If a data should be transferred from one register to another, it must go through
accumulator.
B Register
B register is used during multiply and divide operations which can be performed only upon
numbers stored in the A and B registers. All other instructions in the program can use this
register as a spare accumulator (A).
-
8/2/2019 Ilights Documentation
32/40
During programming, each of registers is called by name so that their exact address is not
so important for the user. During compiling into machine code (series of hexadecimal numbers
recognized as instructions by the microcontroller), PC will automatically, instead of registers
name, write necessary addresses into the microcontroller.
R Registers (R0-R7)
This is a common name for the total 8 general purpose registers (R0, R1, and R2 ...R7). Even
they are not true SFRs, they deserve to be discussed here because of their purpose. Which of the
banks will be active depends on two bits included in the PSW Register. These registers are stored
in four banks in the scope of RAM.
The following example best illustrates the useful purpose of these registers. Suppose that
mathematical operations on numbers previously stored in the R registers should be performed:
(R1+R2) - (R3+R4). Obviously, a register for temporary storing results of addition is needed.
Everything is quite simple and the program is as follows:
-
8/2/2019 Ilights Documentation
33/40
MOV A, R3; Means: move number from R3 into accumulator
ADD A, R4; Means: add number from R4 to accumulator (result remains in accumulator)
MOV R5, A; Means: temporarily moves the result from accumulator into R5
MOV A, R1; Means: move number from R1 into accumulator
ADD A, R2; Means: add number from R2 to accumulator
SUBB A, R5; Means: subtract number from R5 (there are R3+R4)
INTERRUPTS:
A single microcontroller can serve several devices. There are two ways to do that:
INTERRUPTS or POLLING.
POLLING:
In polling the microcontroller continuously monitors the status of a given device; when
the status condition is met, it performs the service .After that, it moves on to monitor the next
device until each one is serviced. Although polling can monitor the status of several devices and
serve each of them as certain condition are met.
INTERRUPTS:
In the interrupts method, whenever any device needs its service, the device notifies the
microcontroller by sending it an interrupts signal. Upon receiving an interrupt signal, the
microcontroller interrupts whatever it is doing and serves the device. The program associated
with the interrupts is called the interrupt service routine (ISR).or interrupt handler.
INTERRUPTS Vs POLLING:
The advantage of interrupts is that the microcontroller can serve many devices (not allthe same time, of course); each device can get the attention of the microcontroller based on the
priority assigned to it. The polling method cannot assign priority since it checks all devices in
round-robin fashion.. This is again not possible with the polling method. The most important
reason that the interrupt method is preferable is that the polling method wastes much of the
-
8/2/2019 Ilights Documentation
34/40
microcontrollers time by polling devices that do not need service. So, in order to avoid tying
down the microcontroller, interrupts are used.
5.2 Encoder (HT12E)
The encoders are a series of CMOS LSIs for remote control system applications. They
are capable of encoding information, which consists of N address bits and 12_N data bits. Each
address/data input can be set to one of the two logic states.
Fig 4.13 Pin diagram of Encoder
The programmed addresses/data are transmitted together with the header bits via an RF or an
infrared transmission medium upon receipt of a trigger signal. The capability to select a TE
trigger on the HT12E
-
8/2/2019 Ilights Documentation
35/40
Table 4.9 Pin Description of Encoder
Functional Description
Operation
The encoders begin a 4-word transmission cycle upon receipt of a transmission enable (TE for
the HT12E, active low). This cycle will repeat itself as long as the transmission enable TE is held
low. Once the transmission enable returns high the encoder output completes its final cycle and
then stops as shown below
-
8/2/2019 Ilights Documentation
36/40
Transmission Enable
For the HT12E encoders, applying a low signal to the TE pin enables transmission.
Fig 4.14 Transmission timing Diagram
Address/Data Programming (Preset)
The status of each address/data pin can be individually pre-set to logic _high_ or _low_. If a
transmission-enable signal is applied, the encoder scans and transmits the status of the 12 bits of
address/data serially in the order A0 to AD11 for the HT12E encoder During information
transmission these bits are transmitted with a preceding synchronization bit. If the trigger signal
is not applied, the chip enters the standby mode and consumes a reduced current of less than 1_A
for a supply voltage of 5V.
Usual applications preset the address pins with individual security codes using DIPswitches or
PCB wiring, while the data is selected by push buttons or electronic switches.
-
8/2/2019 Ilights Documentation
37/40
Fig 4.15 Flow chart of encoder
Electrical characteristics
-
8/2/2019 Ilights Documentation
38/40
5.3 Decoder (HT12D)
General Description
The decoders are a series of CMOS LSIs for remote Control system applications. For proper
operation, a pair of encoder/decoder with the same number of addresses and data format should
be chosen. The decoders receive serial addresses and data from programmed encoders. Which
are transmitted by a carrier using an RF or an IR transmission medium. They compare the serial
input data three times continuously with their local addresses.
If no error or unmatched Codes are found the input data codes are decoded and
then transferred to the output pins. The VT pin also goes high to indicate a valid transmission. of
decoders are capable of decoding Information that consists of N bits of address and 12_NBits of
data of this series, the HT12D is arranged to provide8 address bits and 4 data bits, and HT12F is
used to Decode 12 bits of address information
Fig 4.16Pin Diagram of Decoder
-
8/2/2019 Ilights Documentation
39/40
PIN DESCRIPTION OF DECODER
Table 4.10 Pin Description of Decocder
Functional Description:
Operation: The decoders receive data that are transmitted by an encoder and interpret the first
N bits of code period as Addresses and the last 12_N bits as data, where N is the address codenumber. A signal on the DIN pin activates the oscillator, which in turn decodes the incoming
address and data. The decoders will then check the received address three times continuously. If
the received address codes all match the contents of the decoders local address, the 12_N bits of
data are decoded to activate the output pins and the VT pin is set high to indicate a valid
transmission. This will last unless the address code is incorrect or no signal is received. The
output of the VT pin is high only when the transmissionis valid. Otherwise it is always low.
-
8/2/2019 Ilights Documentation
40/40
Decoder timing
5.4 Led matrix (5x8)
General Description
The CP23058 SR2/C/A is a 1.4 inch (35.76mm)