REMOTE DISPLAY AND ANALYSIS OF ATMOSPHERIC DATAA FOR AIRCRAFT
FLYING
PREFACE
The purpose of this report is to present the concept and
necessary information regarding the project Remote Display and
Analysis of Atmospheric Datas for Aircraft Flying. The project
involves the development of data acquisition system to acquire and
display atmospheric parameters from different sensors.The
transmitter module consists of various sensors, pic
microcontroller, LCD display. Emphasis is made in this report on
analog to digital data conversion, data processing and display of
the atmospheric parameters. RF communication is used for the
transmission of the atmospheric datas from the transmitter to the
receiver.The first chapter of the report gives introduction and
requirement of carrying out this work in a ground based station for
ATC. The second and third chapters deal with the basic system model
and various parts of the system. The fourth and fifth chapters give
detailed hardware description and software description with source
codes. The sixth chapter provides the result analysis and the
seventh, eighth and ninth gives the advantages, disadvantages,
concluding remarks and future scope of the project.CHAPTER 1
INTRODUCTION
Air traffic control (ATC) is a service provided by ground-based
controllers who direct aircraft on the ground and in the air. The
primary purpose of ATC systems worldwide is to separate aircraft to
prevent collisions, to organize and expedite the flow of traffic,
and to provide information and other support for pilots when able.
In some countries, ATC may also play a security or defense role or
be run entirely by the military.
Preventing collisions is referred to as separation, which is a
term used to prevent aircraft from coming too close to each other
by use of lateral, vertical and longitudinal separation minima;
many aircraft now have collision avoidance systems installed to act
as a backup to ATC observation and instructions. In addition to its
primary function, the ATC can provide additional services such as
providing information to pilots, weather and navigation information
and Notice to Air Mens.
In many countries, ATC services are provided throughout the
majority of airspace, and its services are available to all users
(private, military, and commercial). When controllers are
responsible for separating some or all aircraft, such airspace is
called "controlled airspace" in contrast to "uncontrolled airspace"
where aircraft may fly without the use of the air traffic control
system. Depending on the type of flight and the class of airspace,
ATC may issue instructions that pilots are required to follow, or
merely flight information to assist pilots operating in the
airspace. In all cases, however, the pilot in command has final
responsibility for the safety of the flight, and may deviate from
ATC instructions in an emergency.Air traffic control basically
depends on atmospheric datas such as wind speed, temperature,
pressure, humidity, rain, altitude, light etc. These atmospheric
parameters must be monitored by the ground-based controller and
when there is any variation in the values of the monitored
parameters from the acceptable range, a warning signal should be
given to the pilot in the form of audio output (buzzer sound) and a
LED flash light for facilitating aircraft flying.
CHAPTER 2
BASIC MODEL OF THE SYSTEM
Fig 2.1 TRANSMITTER MODULE
Fig 2.2 RECEIVER MODULECHAPTER 3
PARTS OF THE SYSTEMSensors (Data acquisition system) Temperature
sensor (LM35) Humidity sensor module (HY-SS 220)
Wind speed sensor (with motor)
Pic Microcontroller (16F877A)AT89S52 MicrocontrollerLiquid
Crystal Display (Hitachi's HD44780)
Actuators Relays
LED Flash lights
Buzzer
TRANSDUCERS: A sensor is a device that measures a physical
quantity and converts it into a signal which can be read by an
observer or by an instrument. This part of the system consists of
various sensors, namely Wind speed, humidity, pressure, light,
rain, altitude and temperature sensors. These sensors sense
respective parameters which are analogous and send them to the Pic
Microcontroller for processing.
PIC MICROCONTROLLER: The Pic Microcontroller is the heart of the
proposed embedded system. It consists of an inbuilt analog to
digital convertor. It constantly monitors the digitized parameters
of the various sensors and verifies them with the predefined
threshold values and checks if any corrective action is to be taken
for the condition at that instant of time. In case such a situation
arises, it activates the actuators to perform a controlled
operation.
AT89S52 MICROCONTROLLER: AT89S52 microcontroller is a great
family compatible with Intel MCS-51 . AT89S52 este creat de ctre
Atmel, lucru indicat de iniialele "AT". Atmel AT89S52 is indicated
by the initials "AT". Acest microcontroler are un consum sczut, ns
CMOS -ul de 8 bii i d performane ridicate, avnd o memorie Flash
intern de 8K Bytes. This is a low power microcontroller, but the
8-bit CMOS gives high performance with an 8K Bytes of internal
flash memory. It is compatible with standard 80C51. Chip-ul Flash
permite memoriei s fie reprogramat intern sau programat de ctre o
memorie nevolatil. Flash memory chip allows internal or scheduled
to be reprogrammed by a non-volatile memory. Atmel AT89S52
microcontroller is very powerful, has great flexibility and is thus
the perfect solution for many embedded applications.ACTUATORS: An
array of actuators can be used in the system such as relays,
contactors, and change over switches etc. They are used to turn on
AC devices such as motors, coolers, pumps, fogging machines,
sprayers. For the purpose of demonstration relays have been used to
drive AC bulbs to simulate actuators and AC devices. A complete
working system can be realized by simply replacing these simulation
devices by the actual devices.DISPLAY UNIT: A Liquid crystal
display is used to indicate the present status of parameters. The
information is displayed in real time. Any display can be
interfaced to the system with respective changes in driver
circuitry and code.
LED FLASH LIGHTS: A flashlight is a hand-held electric-powered
light source. Usually the light source is a small incandescent
light bulb or light-emitting diode (LED). Any variation in the
values of the parameter from the acceptable range will be indicated
by the LED flash lights.
BUZZER: A buzzer or beeper is an audio signaling device, which
may be mechanical, electromechanical, or piezoelectric. Typical
uses of buzzers and beepers include alarms, timers and confirmation
of user input such as a mouse click or keystroke. Any variation in
the values of the parameter from the acceptable range will be
indicated by an alarm of the buzzer.
CHAPTER 4 HARDWARE DESCRIPTION
TRANSDUCERS: A transducer is a device which measures a physical
quantity and converts it into a signal which can be read by an
observer or by an instrument. Monitoring and controlling of
atmospheric datas involves sensing the changes occurring in
environment. The parameters which are of importance are the
temperature humidity, wind speed etc. Since all these parameters
are interlinked, a closed loop (feedback) control system is
employed in monitoring it. The sensors used in this system are:
1. Temperature Sensor (LM35)
2. Wind speed Sensor using motor.
3. Humidity Sensor (HY-SS 220).
TEMPERATURE SENSOR: National Semiconductors LM35 IC has been
used for sensing the temperature. It is an integrated circuit
sensor that can be used to measure temperature with an electrical
output proportional to the temperature. The temperature can be
measured more accurately with it than using a thermistor. The
sensor circuitry is sealed and not subject to oxidation, etc.
Fig 4.1 LM35 temperature sensor
Features:Calibrated directly in Celsius (Centigrade)
Linear + 10.0 mV/C scale factor
0.5C accuracy guaranteed (at +25C)
Rated for full 55 to +150C range
Suitable for remote applications
Low cost due to wafer-level trimming
Operates from 4 to 30 volts
Less than 60 A current drain
Low self-heating, 0.08C in still air
Nonlinearity only 14C typical
Fig 4.2 Temperature sensor circuitFunctional description:The
sensor has a sensitivity of 10mV / oC.
The output of LM35 is amplified using a LM324 single power
supply (+5V) op-amp.
The op-amp is designed to have a gain of 5.
The circuitry measures temperatures with a resolution of up to
0.5 oC.
The output voltage is converted to temperature by a simple
conversion factor. The general equation used to convert output
voltage to temperature is: Temperature ( oC) = (Vout * 100) / 5 oC
. So if Vout is 5V, then, Temperature = 100 oC.
The output voltage varies linearly with temperature.
HUMIDITY SENSORThe humidity sensor HY-SS 220, manufactured by
Honeywell is used for sensing the humidity. It delivers
instrumentation quality RH (Relative Humidity) sensing performance
in a low cost. Relative humidity is a measure, in percentage, of
the vapour in the air compared to the total amount of vapour that
could be held in the air at a given temperature.
Fig 4.3 HY- SS 220Humidity SensorFeatures:Linear voltage output
vs. %RH
Laser trimmed interchangeability
Low power design
High accuracy
Fast response time Stable, low drift performance
Chemically resistant
The RH sensor is a laser trimmed, thermoset polymer capacitive
sensingelement with on-chip integrated signal conditioning. The
sensing element'smultilayer construction provides excellent
resistance to most application hazards such as wetting, dust, dirt,
oils and common environmental chemicals. Fig 4.4 HUMIDITY SENSOR
MODULE SY-HS-220
LIGHT SENSOR: Light Dependent Resistor (LDR) also known as
photoconductor or photocell, is a device which has a resistance
which varies according to the amount of light falling on its
surface. Since LDR is extremely sensitive in visible light range,
it is well suited for the proposed application.
Fig 4.5 Light Dependent ResistorFeatures of the light sensor:The
Light Dependent Resistor (LDR) is made using the
semiconductorCadmiumSulphide (CdS).
The light falling on the brown zigzag lines on the sensor causes
the resistance of the device to fall. This is known as a negative
co-efficient. There are some LDRs that work in the opposite way
i.e. their resistance increases with light (called positive co-
efficient).
he resistance of the LDR decreases as the intensity of the light
falling on it increases. Incident photons drive electrons from the
valence band into the conduction band.
Fig 4.6 Structure of a Light Dependent Resistor, showing Cadmium
Sulphide track and an atom to illustrate electrons in the valence
and conduction bandsFunctional description:An LDR and a normal
resistor are wired in series across a voltage, as shown in the
circuit below. Depending on which is tied to the 5V and which to
0V, the voltage at the point between them, call it the sensor node,
will either rise or fall with increasing light. If the LDR is the
component tied directly to the 5V, the sensor node will increase in
voltage with increasing light
The LDR's resistance can reach 10 k ohms in dark conditions and
about 100 ohms in full brightness.
The circuit used for sensing light in our system uses a 10 k
fixed resistor which is tied to +5V. Hence the voltage value in
this case decreases with increase in light intensity.
VCC
10k
ADC IN4
LDR
GND
Fig 4.7 Light sensor circuitThe sensor node voltage is compared
with the threshold voltages for different levels of light intensity
corresponding to the four conditions- Optimum, dim, dark and
night.The relationship between the resistance RL and light
intensity Lux for a typical LDR is:RL = 500 / Lux k
MICROCONTROLLER (AT89S52CRITERIA FOR CHOOSING A
MICROCONTROLLER:
The basic criteria for choosing a microcontroller suitable for
the application are:
1) The first and foremost criterion is that it must meet the
task at hand efficiently and cost effectively. In analyzing the
needs of a microcontroller-based project, it is seen whether an 8-
bit, 16-bit or 32-bit microcontroller can best handle the computing
needs of the task most effectively. Among the other considerations
in this category are:
(a) Speed: The highest speed that the microcontroller
supports.(b) Packaging: It may be a 40-pin DIP (dual inline
package) or a QFP (quad flat package), or some other packaging
format. This is important in terms of space, assembling, and
prototyping the end product.
(c) Power consumption: This is especially critical for
battery-powered products.
(d) The number of I/O pins and the timer on the chip.
(d) How easy it is to upgrade to higher performance or lower
consumption versions.
(e) Cost per unit: This is important in terms of the final cost
of the product in which a microcontroller is used.
2) The second criterion in choosing a microcontroller is how
easy it is to develop products around it. Key considerations
include the availability of an assembler, debugger, compiler,
technical support.
3) The third criterion in choosing a microcontroller is its
ready availability in needed quantities both now and in the future.
Currently of the leading 8-bit microcontrollers, the 8051 family
has the largest number of diversified suppliers. By supplier is
meant a producer besides the originator of the microcontroller. In
the case of the 8051, this has originated by Intel several
companies also currently producing the 8051. Thus the
microcontroller AT89S52, satisfying the criterion necessary for the
proposed application is chosen for the task.
DESCRIPTION: The 8051 family of microcontrollers is based on an
architecture which is highly optimized for embedded control
systems. It is used in a wide variety of applications from military
equipment to automobiles to the keyboard. Second only to the
Motorola 68HC11 in eight bit processors sales, the 8051 family of
microcontrollers is available in a wide array of variations from
manufacturers such as Intel, Philips, and Siemens. These
manufacturers have added numerous features and peripherals to the
8051 such as I2C interfaces, analog to digital converters, watchdog
timers, and pulse width modulated outputs. Variations of the 8051
with clock speeds up to 40MHz and voltage requirements down to 1.5
volts are available. This wide range of parts based on one core
makes the 8051 family an excellent choice as the base architecture
for a company's entire line of products since it can perform many
functions and developers will only have to learn this one
platform.
The AT89S52 is a low-power, high-performance CMOS 8-bit
microcontroller with 8K bytes of in-system programmable Flash
memory. The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry-
standard 80C51 instruction set and pinout. The on-chip Flash allows
the program memory to be reprogrammed in-system or by a
conventional nonvolatile memory programmer. By combining a
versatile 8-bit CPU with in-system programmable Flash on a
monolithic chip, the Atmel AT89S52 is a powerful microcontroller
which provides a highly-flexible and cost- effective solution to
many embedded control applications. In addition, the AT89S52 is
designed with static logic for operation down to zero frequency and
supports two software selectable power saving modes. The Idle Mode
stops the CPU while allowing the RAM, timer/counters, serial port,
and interrupt system to continue functioning. The Power-down mode
saves the RAM con-tents but freezes the oscillator, disabling all
other chip functions until the next interrupt or hardware
reset.
FEATURES: The basic architecture of AT89C51 consists of the
following features:Compatible with MCS-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)PIN CONFIGURATION:
Fig 4.8 Pin diagram of AT89S52
ARCHITECTURE OF 80C51 FAMILY MICROCONTROLLER:
Fig 4.9 Block diagram of the microcontrollerPIN DESCRIPTION:VCC:
Supply voltage.
GND: Ground.
Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. As
an output port, each pin can sink eight TTL inputs. When 1s are
written to port 0 pins, the pins can be used as high-impedance
inputs. Port 0 can also be configured to be the multiplexed
low-order address/data bus during accesses to external program and
data memory. In this mode, P0 has internal pull-ups.
Port 1: Port 1 is an 8-bit bidirectional 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, Port1
pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups. In addition, P1.0 and P1.1 can be
configured to be the timer/counter2 external count input (P1.0/T2)
and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as
shown in the following table.
Port 2: Port 2 is an 8-bit bidirectional 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, Port2
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 memory that use 16- bit addresses (MOVX @
DPTR). In this application, Port 2 uses strong internal pull- ups
when emitting 1s. During accesses to external data memory that uses
8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2
Special Function register.
Port 3: Port 3 is an 8-bit bidirectional 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, Port3
pins that are externally being pulled low will source current (IIL)
because of the pull-ups. Port 3 receives some control signals for
Flash programming and verification. Port 3 also serves the
functions of various special features of the AT89S52.
RST: Reset input. A high on this pin for two machine cycles
while the oscillator is running resets the device. This pin drives
high for 98 oscillator periods after the watchdog times out.Fig
4.10 Power-on reset circuit
In order for the RESET input to be effective, it must have a
minimum duration of two machine cycles.
ALE/PROG: Address Latch Enable (ALE) is an 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/6 the oscillator frequency and may be used for
external timing or clocking purposes. Note, however, that one ALE
pulse is skipped during each access to external data memory. If
desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. With the bit set, ALE is active only during a MOVX or
MOVC instruction. Otherwise, the pin is weakly pulled high. Setting
the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
PSEN: Program Store Enable (PSEN) is the read strobe to external
program memory. When the AT89S52 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.
EA: 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.
XTAL1: Input to the inverting oscillator amplifier and input to
the internal clock operating circuit.
XTAL2: Output from the inverting oscillator amplifier.
The AT89S52 oscillator clock circuit: It uses a quartz crystal
oscillator.
We can observe the frequency on the XTAL2 pin.
C2
XTAL2
30pF
C1
XTAL1
30pF
GN D
Fig 4.11 Oscillator circuit
SPECIAL FUNCTION REGISTERS:
The Special Function Registers (SFRs) contain memory locations
that are used for special tasks. Each SFR occupies internal RAM
from 0x80 to 0xFF.They are 8-bits wide.
The A (accumulator) register or accumulator is used for most ALU
operations and Boolean Bit manipulations.
Register B is used for multiplication & division and can
also be used for general purpose storage.
PSW (Program Status Word) is a bit addressable register
PC or program counter is a special 16-bit register. It is not
part of SFR. Program instruction bytes are fetched from locations
in memory that are addressed by the PC.Stack Pointer (SP) register
is eight bits wide. It is incremented before data is stored during
PUSH and CALL executions. While the stack may reside anywhere in
on-chip RAM, the Stack Pointer is initialized to 07H after a reset.
This causes the stack to begin at location 08H.
DPTR or data pointer is a special 16-bit register that is
accessible as two 8- bitregisters: DPL and DPH, which are used to
used to furnish memory addresses for internal and external code
access and external data access.
Control Registers: Special Function Registers IP, IE, TMOD,
TCON, SCON, and PCON contain control and status bits for the
interrupt system, the Timer/Counters, and the serial port.
Timer Registers: Register pairs (TH0, TL0) and (TH1, TL1) are
the 16-bit Counter registers for Timer/Counters 0 and 1,
respectively.
MEMORY ORGANIZATION:MCS-51 devices have a separate address space
for Program and Data Memory. Up to 64K bytes each of external
Program and Data Memory can be addressed.
Program Memory: If the EA pin is connected to GND, all program
fetches are directed to external memory. On the AT89S52, if EA is
connected to VCC, program fetches to addresses 0000H through 1FFFH
are directed to internal memory and fetches to addresses 2000H
through FFFFH are to external memory.
Data Memory: The AT89S52 implements 256 bytes of on-chip RAM.
The upper 128 bytes occupy a parallel address space to the Special
Function Registers. This means that the upper 128 bytes have the
same addresses as the SFR space but are physically separate from
SFR space. When an instruction accesses an internal location above
address 7FH, the address mode used in the instruction specifies
whether the CPU accesses the upper 128 bytes of RAM or the SFR
space. Instructions which use direct addressing access the SFR
space. The lower 128bytes of RAM can be divided into three
segments:1. Register Banks 0-3: locations 00H through 1FH (32
bytes). The device after reset defaults to register bank 0. To use
the other register banks, the user must select them in software.
Each register bank contains eight 1-byte registers R0-R7. Reset
initializes the stack point to location 07H, and is incremented
once to start from 08H, which is the first register of the second
register bank.2. Bit Addressable Area: 16 bytes have been assigned
for this segment 20H-2FH. Eachone of the 128 bits of this segment
can be directly addressed (0-7FH). Each of the 16 bytes in this
segment can also be addressed as a byte.3. Scratch Pad Area:
30H-7FH are available to the user as data RAM. However, if the data
pointer has been initialized to this area, enough bytes should be
left aside to prevent SP data destruction. Fig 4.12 Internal memory
block
WATCHDOG TIMER (One-time Enabled with Reset-out): The WDT is
intended as a recovery method in situations where the CPU may be
subjected to software upsets. The WDT consists of a 14-bit counter
and the Watchdog Timer Reset (WDTRST) SFR. The WDT is defaulted to
disable from exiting reset. To enable the WDT, a user must write
01EH and 0E1H in sequence to the WDTRST register (SFR location
0A6H). When the WDT is enabled, it will increment every machine
cycle while the oscillator is running. The WDT timeout period is
dependent on the external clock frequency. There is no way to
disable the WDT except through reset (either hardware reset or WDT
overflow reset). When WDT over-flows, it will drive an output RESET
HIGH pulse at the RST pin.
TIMERS AND COUNTERS: Many microcontroller applications require
the counting of external events such as the frequency of a pulse
train, or the generation of precise internal time delays between
computer actions. Both of these tasks can be accomplished using
software techniques, but software loops for counting or timing keep
the processor occupied so that, other perhaps more important,
functions are not done. Hence the better option is to use
interrupts & the two 16- bit count- up timers. The
microcontroller can programmed for either of the following:
1. Count internal - acting as timer
2. Count external - acting as counter
All counter action is controlled by the TMOD (Timer Mode) and
the TCON (Timer/Counter Control) registers. TCON Timer control SFR
contains timer 1& 2 overflow flags, external interrupt flags,
timer control bits, falling edge/low level selector bit etc. TMOD
timer mode SFR comprises two four-bit registers (timer #1, timer
#0) used to specify the timer/counter mode and operation.
The timer may operate in any one of four modes that are
determined by modes bits M1 and M0 in the TMOD register:
TIMER MODE-0: Setting timer mode bits to 00b in the TMOD
register results in using the TH register as an 8-bit counter and
TL as a 5-bit counter. Therefore mode0 is a 13-bit counter.TIMER
MODE-1: Mode-1 is similar to mode-0 except TL is configured as a
full 8-bit counter when the mode bits are set to 01b in TMOD.TIMER
MODE-2: Setting the mode bits to 10b in TMOD configures the timer
to use only the TL counter as an 8-bit counter. TH is used to hold
a value that is loaded into TL every time TL overflows from FFh to
00h. The timer flag is also set when TL overflows.TIMER MODE-3: In
mode-3, timer-1 simply hold its count, where as timer 0 registers
TL0 and TH0 are used as two separate 8-bit counters. TL0 uses the
Timer-0 control bits. TH0 counts machine cycles and takes over the
use of TR1 and TF1 from Timer-1.
INTERRUPTS A computer has only two ways to determine the
conditions that exist in internal and external circuits. One method
uses software instructions that jump to subroutines on the states
of flags and port pins. The second method responds to hardware
signals, called interrupts that force the program to call a
subroutine.
The AT89S52 has a total of six interrupt vectors: two external
interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1,
and 2), and the serial port interrupt. Each of these interrupt
sources can be individually enabled or disabled by setting or
clearing a bit in Special Function Register IE. IE also contains a
global disable bit, EA, which disables all interrupts at once. Each
interrupt forces the processor to jump at the interrupt location in
the memory. The interrupted program must resume operation at the
instruction where the interrupt took place. Program resumption is
done by storing the interrupted PC address on to stack. RETI
instruction at the end of ISR will restore the PC address.
MICROCONTROLLER CONFIGURATION USED IN THE SET-UP The
microcontroller is interfaced with the ADC in polling mode. INT0 is
used for the LCD mode selection switch in order to switch between
two modes of display:
1) Sensor output display
2) Actuator status display
Port details:
Port 0: Interfaced with the LCD data lines.
Port 1: Interfaced with the ADC data lines
Port 2: Interfaced with the LCD Control lines and AC Interface
control
Port 3: Interfaced with the ADC control lines
PIC16F877A MICROCONTROLLER: PIC is a family of Harvard
architecture microcontrollers made by Microchip Technology, derived
from the PIC1640 originally developed by General Instrument's
Microelectronics Division. The name PIC initially referred to
"Peripheral Interface Controller".
PICs are popular with both industrial developers and hobbyists
alike due to their low cost, wide availability, large user base,
extensive collection of application notes, availability of low cost
or free development tools, and serial programming (and
re-programming with flash memory) capability.CORE ARCHITECTURE: The
PIC architecture is characterized by its multiple attributes:
Separate code and data spaces (Harvard architecture) for devices
other than PIC32, which has a Von Neumann architecture.
A small number of fixed length instructions. Most instructions
are single cycle execution (2 clock cycles), with one delay cycle
on branches and skips.
One accumulator (W0), the use of which (as source operand) is
implied (i.e. is not encoded in the opcode).
All RAM locations function as registers as both source and/or
destination of math and other functions.
A hardware stack for storing return addresses.
A fairly small amount of addressable data space (typically 256
bytes), extended through banking.
Data space mapped CPU, port, and peripheral registers.
The program counter is also mapped into the data space and
writable (this is used to implement indirect jumps).
There is no distinction between memory space and register space
because the RAM serves the job of both memory and registers, and
the RAM is usually just referred to as the register file or simply
as the registers.
DATA SPACE (RAM): PICs have a set of registers that function as
general purpose RAM. Special purpose control registers for on-chip
hardware resources are also mapped into the data space. The
addressability of memory varies depending on device series, and all
PIC devices have some banking mechanism to extend addressing to
additional memory. Later series of devices feature move
instructions which can cover the whole addressable space,
independent of the selected bank. In earlier devices, any register
move had to be achieved via the accumulator.
To implement indirect addressing, a "file select register" (FSR)
and "indirect register" (INDF) are used. A register number is
written to the FSR, after which reads from or writes to INDF will
actually be to or from the register pointed to by FSR. Later
devices extended this concept with post- and pre-
increment/decrement for greater efficiency in accessing
sequentially stored data. This also allows FSR to be treated almost
like a stack pointer (SP).
CODE SPACE: The code space is generally implemented as ROM,
EPROM or flash ROM. In general, external code memory is not
directly addressable due to the lack of an external memory
interface. The exceptions are PIC17 and select high pin count PIC18
devices.
WORD SIZE: All PICs handle (and address) data in 8-bit chunks.
However, the unit of addressability of the code space is not
generally the same as the data space. For example, PICs in the
baseline and mid-range families have program memory addressable in
the same word size as the instruction width, i.e. 12 or 14 bits
respectively. In contrast, in the PIC18 series, the program memory
is addressed in 8-bit increments (bytes), which differs from the
instruction width of 16 bits. In order to be clear, the program
memory capacity is usually stated in number of (single word)
instructions, rather than in bytes.
STACKS: PICs have a hardware call stack, which is used to save
return addresses. The hardware stack is not software accessible on
earlier devices, but this changed with the 18 series devices.
Hardware support for a general purpose parameter stack was lacking
in early series, but this greatly improved in the 18 series, making
the 18 series architecture more friendly to high level language
compilers.
INSTRUCTION SET: A PIC's instructions vary from about 35
instructions for the low-end PICs to over 80 instructions for the
high-end PICs. The instruction set includes instructions to perform
a variety of operations on registers directly, the accumulator and
a literal constant or the accumulator and a register, as well as
for conditional execution, and program branching.
Some operations, such as bit setting and testing, can be
performed on any numbered register, but bi-operand arithmetic
operations always involve W (the accumulator), writing the result
back to either W or the other operand register. To load a constant,
it is necessary to load it into W before it can be moved into
another register. On the older cores, all register moves needed to
pass through W, but this changed on the "high end" cores.
PIC cores have skip instructions which are used for conditional
execution and branching. The skip instructions are 'skip if bit
set' and 'skip if bit not set'. Because cores before PIC18 had only
unconditional branch instructions, conditional jumps are
implemented by a conditional skip (with the opposite condition)
followed by an unconditional branch. Skips are also of utility for
conditional execution of any immediate single following
instruction.
The 18 series implemented shadow registers which save several
important registers during an interrupt, providing hardware support
for automatically saving processor state when servicing
interrupts.
In general, PIC instructions fall into 5 classes:
1. Operation on working register (WREG) with 8-bit immediate
("literal") operand. E.g. movlw (move literal to WREG), andlw (AND
literal with WREG). One instruction peculiar to the PIC is retlw,
load immediate into WREG and return, which is used with computed
branches to produce lookup tables.2. Operation with WREG and
indexed register. The result can be written to either the Working
register (e.g. addwf reg,w). or the selected register (e.g. addwf
reg,f).3. Bit operations. These take a register number and a bit
number, and perform one of 4 actions: set or clear a bit, and test
and skip on set/clear. The latter are used to perform conditional
branches. The usual ALU status flags are available in a numbered
register so operations such as "branch on carry clear" are
possible.4. Control transfers. Other than the skip instructions
previously mentioned, there are only two: goto and call.5. A few
miscellaneous zero-operand instructions, such as return from
subroutine, and sleep to enter low-power mode.
ADVANTAGES: The PIC architectures have these advantages:
Small instruction set to learn
RISC architecture
Built in oscillator with selectable speeds
Inexpensive microcontrollers
Wide range of interfaces including I2C, SPI, USB, USART, A/D,
programmable Comparators, PWM, LIN, CAN, PSP, and Ethernet.
DISADVANTAGES: The PIC architectures have these limitations:
One accumulator.
Register-bank switching is required to access the entire RAM of
many devices.
Operations and registers are not orthogonal; some instructions
can address RAM and/or immediate constants, while others can only
use the accumulator.
The following limitations have been addressed in the PIC18
series, but still apply to earlier cores:
Stack:
The hardware call stack is not addressable, so preemptive task
switching cannot be implemented
Software-implemented stacks are not efficient, so it is
difficult to generate reentrant code and support local
variablesWith paged program memory, there are two page sizes to
worry about: one for CALL and GOTO and another for computed GOTO
(typically used for table lookups). For example, on PIC16, CALL and
GOTO have 11 bits of addressing, so the page size is 2048
instruction words. For computed GOTOs, where you add to PCL, the
page size is 256 instruction words. In both cases, the upper
address bits are provided by the PCLATH register. This register
must be changed every time control transfers between pages. PCLATH
must also be preserved by any interrupt handler.
Architecturally, although they share the PIC moniker, they are
very different from the 8-bit PICs. The most notable differences
are:[10] They feature a set of 16 working registers (W0-W15)
They fully support a stack in RAM, and do not have a hardware
stack
Bank switching is not required to access RAM or special function
registers
Data stored in program memory can be accessed directly using a
feature called Program Space Visibility
Interrupt sources may be assigned to distinct handlers using an
interrupt vector table
Some features are:
Hardware MAC (multiply-accumulate)
Barrel shifting Bit reversal
(1616)-bit single-cycle multiplication and other DSP
operations
Hardware divide assist (19 cycles for 16/32-bit divide)
Hardware support for loop indexing
Direct memory accessLIQUID CRYSTAL DISPLAY A liquid crystal
display (LCD) is a thin, flat display device made up of any number
of color or monochrome pixels arrayed in front of a light source or
reflector. Each pixel consists of a column of liquid crystal
molecules suspended between two transparent electrodes, and two
polarizing filters, the axes of polarity of which are perpendicular
to each other. Without the liquid crystals between them, light
passing through one would be blocked by the other. The liquid
crystal twists the polarization of light entering one filter to
allow it to pass through the other. Many microcontroller devices
use 'smart LCD' displays to output visual information. LCD displays
designed around Hitachi's LCD HD44780 module, are inexpensive, easy
to use, and it is even possible to produce a readout using the 8x80
pixels of the display. They have a standard ASCII set of characters
and mathematical symbols.
For an 8-bit data bus, the display requires a +5V supply plus 11
I/O lines. For a 4-bit data bus it only requires the supply lines
plus seven extra lines. When the LCD display is not enabled, data
lines are tri-state and they do not interfere with the operation of
the microcontroller.
Data can be placed at any location on the LCD. For 162 LCD, the
address locations are:First line 80 81 82 83 84 85 86 through
8FSecond line C0 C1 C2 C3 C4 C5 C6 through CF
Address locations for a 2x16 line LCD
SIGNALS TO THE LCD:
The LCD also requires 3 control lines from the
microcontroller:1) Enable (E): This line allows access to the
display through R/W and RS lines. When this line is low, the LCD is
disabled and ignores signals from R/W and RS. When (E) line is
high, the LCD checks the state of the two control lines and
responds accordingly.
2) Read/Write (R/W): This line determines the direction of data
between the LCD and microcontroller. When it is low, data is
written to the LCD. When it is high, data is read from the LCD.
3) Register select (RS): With the help of this line, the LCD
interprets the type of data on data lines. When it is low, an
instruction is being written to the LCD. When it is high, a
character is being written to the LCD.
Logic status on control lines: E - 0 Access to LCD disabled- 1
Access to LCD enabled
R/W - 0 Writing data to LCD- 1 Reading data from LCD
RS - 0 Instruction- 1 Character
Writing and reading the data from the LCD:
Writing data to the LCD is done in several steps:1) Set R/W bit
to low
2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low
Read data from data lines (if it is reading):1) Set R/W bit to
high
2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low
PIN DESCRIPTIONMost LCDs with 1 controller has 14 Pins and LCDs
with 2 controller has 16 Pins (two pins are extra in both for
back-light LED connections).
Fig 4.13 Pin diagram of 2x16 line LCD
Table 4.1 Pin description of the LCDALARM CIRCUITRYBUZZER:A
buzzer or beeper is a signaling device, usually electronic,
typically used in automobiles, household appliances such as a
microwave oven.
Fig 4.14 Electrical symbol of a buzzer
It is connected to the control unit through the transistor that
acts as an electronic switch for it. When the switch forms a closed
path to the buzzer, it sounds a warning in the form of a continuous
or intermittent buzzing or beeping sound.
The transistor acts as a normal controlled by the base
connection. It switches ON when a positive voltage from the control
unit is applied to the base. If the positive voltage is less than
0.6V, the transistor switches OFF. No current flows through the
buzzer in this case and it will not buzz. As can be seen in the
buzzer circuitry given below, a protection resistor of 10k ohm is
used in order to protect the transistor from being damaged in case
of excessive current flow. In our system, the buzzer is designed to
give a small beep whenever one of the devices such as a cooler or a
bulb turns on in order to alert the user.
Fig 4.15 Buzzer circuitryRELAYS A relay is an electrical switch
that opens and closes under the 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 to be, in a broad sense, a form of an
electrical amplifier.
Fig 4.16 Sugar cube relayDespite the speed of technological
developments, some products prove so popular that their key
parameters and design features remain virtually unchanged for
years. One such product is the sugar cube relay, shown in the
figure above, which has proved useful to many designers who needed
to switch up to 10A, whilst using relatively little PCB area Since
relays are switches, the terminology applied to switches is also
applied to relays. A relay will switch one or more poles, each of
whose contacts can be thrown by energizing the coil in one of three
ways:
1.Normally - open (NO) contacts connect the circuit when the
relay is activate d; the circuit is disconnected when the relay is
inactive. It is also called a FORM A contact or make contact.
2.Normally - closed (NC) contacts disconnect the circuit when
the relay is activated ; the circuit is connected when relay is
inactive. It is also called FORM B contact or break contact
3.Change-over or double-throw contacts control two circuits ;
one normally open contact and one normally closed contact with a
common terminal. It is also called a Form C transfer contact.
The following types of relays are commonly encountered:
"C" denotes the common terminal in SPDT and DPDT types
Different types of RelaysSPST - Single Pole Single Throw: These
have two terminals which can be connected or disconnected.
Including two for the coil, such a relay has four terminals in
total. It is ambiguous whether the pole is normally open or
normally closed. The terminology "SPNO" and "SPNC" is sometimes
used to resolve the ambiguity.SPDT - Single Pole Double Throw: A
common terminal connects to either of two others. Including two for
the coil, such a relay has five terminals in total.DPST - Double
Pole Single Throw: These have two pairs of terminals. Equivalent to
two SPST switches or relays actuated by a single coil. Including
two for the coil, such a relay has six terminals in total. It is
ambiguous whether the poles are normally open, normally closed, or
one of each.
DPDT - Double Pole Double Throw: These have two rows of
change-over terminals. Equivalent to two SPDT switches or relays
actuated by a single coil. Such a relay has eight terminals,
including the coil.
QPDT - Quadruple Pole Double Throw: Often referred to as Quad
Pole Double Throw, or 4PDT. These have four rows of change-over
terminals. Equivalent to four SPDT switches or relays actuated by a
single coil, or two DPDT relays. In total, fourteen terminals
including the coil.
The Relay interfacing circuitry used in the application is Fig
4.17 Relay circuitry
POWER SUPPLY CONNECTION:The power supply section consists of
step down transformers of 230V primary to 9V and 12V secondary
voltages for the +5V and +12V power supplies respectively. The
stepped down voltage is then rectified by 4 1N4007 diodes. The high
value of capacitor 1000 F charges at a slow rate as the time
constant is low, and once the capacitor charges there is no
resistor for capacitor to discharge. This gives a constant value of
DC. IC 7805 is used for regulated supply of +5 volts and IC 7812 is
used to provide a regulated supply of +12 volts in order to prevent
the circuit ahead from any fluctuations. The filter capacitors
connected after this IC filters the high frequency spikes. These
capacitors are connected in parallel with supply and common so that
spikes filter to the common. These give stability to the power
supply circuit.
As can be seen from the above circuit diagrams, the rectified
voltage from the 4 diodes is given to pin 1 of the respective
regulators. Pin 2 of the regulators is connected to ground and pin
3 to Vcc. With adequate heat sinking the regulator can deliver 1A
output current. If internal power dissipation becomes too high for
the heat sinking provided, the thermal shutdown circuit takes over
preventing the IC from overheating.
Fig 4.18 +12V Power supply Circuit
Fig 4.19 +5V Power supply circuitCHAPTER 5SOFTWARE DESCRIPTION C
is a general-purpose computer programming language developed
between 1969 and 1973 by Dennis Ritchie at the Bell Telephone
Laboratories for use with the Unix operating system. Although C was
designed for implementing system software, it is also widely used
for developing portable application software. C is one of the most
popular programming languages of all time and there are very few
computer architectures for which a C compiler does not exist. C has
greatly influenced many other popular programming languages, most
notably C++, which began as an extension to C.
C is an imperative (procedural) systems implementation language.
It was designed to be compiled using a relatively straightforward
compiler, to provide low-level access to memory, to provide
language constructs that map efficiently to machine instructions,
and to require minimal run-time support. C was therefore useful for
many applications that had formerly been coded in assembly
language.
Despite its low-level capabilities, the language was designed to
encourage cross-platform programming. A standards-compliant and
portably written C program can be compiled for a very wide variety
of computer platforms and operating systems with few changes to its
source code. The language has become available on a very wide range
of platforms, from embedded microcontrollers to supercomputers.
HI-TECH Software is an Australian-based company that provides
ANSI C compilers and development tools. Founded in 1984, the
company is best known for its HI-TECH C PRO compilers with
whole-program compilation technology, or Omniscient Code Generation
(OCG). HI-TECH Software was bought by Microchip on 20th February
2009, whereupon it refocused its development effort exclusively on
supporting Microchip products.Hi-Tech C language is used to code
the microcontroller in this project and the source code for the
transmitter and receiver module is given as follows;
SOURCE CODE OF TRANSMITTER MODULE:#include
// INCLUDE PIC16 CODE
#include
// INCLUDE DELAY FUNCTIONS
#include
#include
// INCLUDE LCD FUNCTIONS
#include
#include
// INCLUDE DISPLAY FUNCTIONS TO DISPLAY INTEGERS AND
FRACTIONS
#include
// INCLUDE FUNCTION TO PREPARE STRINGS FOR SD CARD AND UART DATA
TRANSIMISSION
#include
void adc_read(unsigned char channel);
unsigned int gadcv (int i,int j);
unsigned int adcch(unsigned char cha);
unsigned char adcchanno;
void main (void)
{
unsigned char ii;
unsigned long adc_val=0;
unsigned char adc_val1;
TRISC=0X00;
TRISB=0X00;
lcd_init();
lcd_clear();
lcd_goto(0x00);
lcd_puts("DATA LOGGER");
while(1)
{
adc_val=0;
for(ii=0;ii