Sie sind auf Seite 1von 69

Embedded Based Smart Antenna Orientation System

Department of ECE 1 H.K.B.K.C.E




Chapter 1
INTRODUCTION
1.1 Introduction And Literature Survey
Antenna forms a basic component of any RF/Microwave System that uses Free
Space to propagate on for Communications, Radio Detection, Remote sensing, etc and is
important part of the modern communication system. Antennas are transitional device
between free space and guiding device like Waveguides or transmission lines. Antennas
are eyes and ears of the modern world.
Since the early days of wireless communications, there has been the simple dipole
antenna, which radiates and receives equally well in all directions. To find its users, this
single-element design broadcasts Omni directionally in a pattern resembling ripples
radiating outward in a pool of water. While adequate for simple RF environments where
no specific knowledge of the users' whereabouts is available, this unfocused approach
scatters signals, reaching desired users with only a small percentage of the overall energy
sent out into the environment. In addition, other users will experience the power radiated
in other directions as interference.
In recent years, the limitations of broadcast antenna technology on the quality,
capacity, and coverage of wireless systems have prompted an evolution in the fundamental
design and role of the antenna in a wireless system. Sectorized systems, diversity systems
using directional and smart antennas have evolved. However in order to accomplish
maximum signal strength, user often has to adjust the antenna manually. A Smart Antenna
Orientation System will do this automatically and increase the spectrum efficiency.
1.2 Objective Of The Project
To develop with the help of embedded coding a Smart- Antenna Orientation
system with which the system automatically recognizes the direction from which
maximum Signal strength can be achieved within the designated frequency.


Embedded Based Smart Antenna Orientation System

Department of ECE 2 H.K.B.K.C.E


1.3 Block Diagram
1.3.1 Transmitter

TX antenna





Fig 1.1 Transmitter

1.3.2 Receiver













Fig 1.2 Receiver



Micro
Controller

Keypad
LCD Display
Stepper Motor
ADC
RF Detector
Microwave
Signal
Source
(TX)
RX Antenna
Embedded Based Smart Antenna Orientation System

Department of ECE 3 H.K.B.K.C.E


1.4 Description
The proposed system any Antennas mounted on to the system is programmed to
automatically orient towards direction of Maximum signal strength to ensure better signal
strength for clear Audio and Video Signals at the receiver side. This system is ideal for
service providers of SATCOM, World space radios, Live Event coverage and
Transmission, All Line of sight communication etc.,
The Transmitter part of the Orientation System consists of microwave source, a
VCO in this case operating in c-band at a frequency of 2-4 GHz (can be operated in s and
x band if required) which generates a radio frequency altering current, which is applied to
the transmitting antenna. When excited by this alternating current this antenna radiates
radio waves.
The transmitting and receiving antenna used for demonstrating purpose is a Patch
Antenna, whose directionality is greater compared to other antenna. Patch antennas are
low cost, have a low profile and are easily fabricated.
At the receiver side, the receiving antenna (i.e patch antenna) is mounted on a
stepper motor using a mounting rod. The stepper motor is controlled using a PIC
controller. The received signal is detected using a RF detector and converted in to a digital
signa using the inuit in PI The receive signa is etecte for every ange 1
per step) by rotating the stepper motor. The corresponding power levels are displayed on
LCD.
The keypad (44) is used for aligning, resetting the module, to find maximum and
pausing the module.
1.5 Methodology
Step 1. Microcontroller is initialised and request for alignment (Initially).
Step 2. The stepper motor rotates the receiver antenna for 360 degree and microcontroller
scans for the signal strength. The power intensity (highest value) is stored in internal
memory of the microcontroller.
Step 3. It automatically aligns to the angle of last found maximum signal direction.

Embedded Based Smart Antenna Orientation System

Department of ECE 4 H.K.B.K.C.E


Step 4. The device continuously monitors the power/signal strength. If any change it
Automatically aligns to the direction of maximum signal strength.
1.6 Assumption
The system Antennas should have very low side lobes. The Gain of the Antennas
should be high. Higher the Gain of the receiver antenna, better the performance of
the setup.
The return loss of the antenna used should be reasonable around -10 db and above
for optimum performance.
At some point the transmitter and receiver antenna may be slightly out of sight line,
but the signal level may still be high, this may be due to multiple reflections the
receiving antenna may receive at that point.














Embedded Based Smart Antenna Orientation System

Department of ECE 5 H.K.B.K.C.E


Chapter 2
HARDWARE DESCRIPTION
2.1 Peripheral Interface Controller (PIC18F452)
This family offers the advantages of all PIC18 microcontrollers namely, high
computational performance at an economical price with the addition of high endurance,
Enhanced Flash program memory. On top of these features, the
PIC18F2420/2520/4420/4520 family introduces design enhancements that make these
microcontrollers a logical choice for many high performances, power sensitive
applications.

Fig 2.1 PIC18F452
Microchip introduced the PIC18 architecture in 2000. Unlike the 17 series, it has
proven to be very popular, with a large number of device variants presently in
manufacture. In contrast to earlier devices, which were more often than not programmed
in assembly, C has become the predominant development language.
The 18 series inherits most of the features and instructions of the 17 series, while adding a
number of important new features:
The call stack is 21 bits wide and much deeper (31 levels deep).
The call stack may be read and written (TOSU:TOSH:TOSL registers).
Embedded Based Smart Antenna Orientation System

Department of ECE 6 H.K.B.K.C.E


Conditional branch instructions.
Indexed addressing mode (PLUSW).
Extending the FSR registers to 12 bits, allowing them to linearly address the entire
data address space.
The additions of another FSR register (bringing the number up to 3).

Fig 2.2 Pin Configuration of PIC18F452
The RAM space is 12 bits, addressed using a 4-bit bank select register and an 8-bit
offset in each instruction. An additional "access" bit in each instruction selects between
bank 0 (a=0) and the bank selected by the BSR (a=1).
A 1-level stack is also available for the STATUS, WREG and BSR registers. They are
saved on every interrupt, and may be restored on return. If interrupts are disabled, they
may also be used on subroutine call/return by setting the s bit.
Embedded Based Smart Antenna Orientation System

Department of ECE 7 H.K.B.K.C.E


The auto increment/decrement feature was improved by removing the control bits and
adding four new indirect registers per FSR. Depending on which indirect file register is
being accessed it is possible to post-decrement, post-increment, or pre-increment FSR; or
form the effective address by adding W to FSR.
In more advanced PIC18 devices, an "extended mode" is available which makes the
addressing even more favourable to compiled code:
A new offset addressing mode; some addresses which were relative to the access
bank are now interpreted relative to the FSR2 register.
The addition of several new instructions, notable for manipulating the FSR
registers.
These changes were primarily aimed at improving the efficiency of a data stack
implementation. If FSR2 is used either as the stack pointer or frame pointer, stack items
may be easily indexed allowing more efficient re-entrant code.
2.1.1 New Core Features
Nano Watt Technology:
All of the devices in the PIC18F2420/2520/4420/4520 family incorporate a range
of features that can significantly reduce power consumption during operation.
Key items include:
Alternate Run Modes: By clocking the controller from the Timer1 source or the
internal oscillator block, power consumption during code execution can be reduced
by as much as 90%.
Multiple Idle Modes: The controller can also run with its CPU core disabled but
the peripherals still active. In these states, power consumption can be reduced even
further, to as little as 4% of normal operation requirements.
On-the-fly Mode Switching: The power managed modes are invoked by user
code during operation, allowing the user to incorporate power saving ideas into
their applications software design.
Low Consumption in Key Modules: The power requirements for both Timer1
and the Watchdog Timer is minimized.
Embedded Based Smart Antenna Orientation System

Department of ECE 8 H.K.B.K.C.E


2.1.2 Multiple Oscillator Options And Features
All of the devices in the PIC18F2420/2520/4420/4520family offer ten different
oscillator options, allowing users a wide range of choices in developing application
hardware. These include:
Four Crystal modes, using crystals or ceramic resonators.
Two External Clock modes, offering the option of using two pins (oscillator input
and a divide-by-4 clock output) or one pin (oscillator input, with the second pin
reassigned as general I/O).
Two External RC Oscillator modes with the same pin options as the External
Clock modes.
An internal oscillator block which provides an 8 MHz clock and an INTRC source
(approximately 31 kHz), as well as a range of 6 user selectable clock frequencies,
between 125 kHz to 4 MHz, for a total of 8 clock frequencies. This option frees the
two oscillator pins for use as additional general purpose I/O.
A Phase Lock Loop (PLL) frequency multiplier, available to both the high-speed
crystal and internal oscillator modes, which allows clock speeds of up to 40 MHz.
Used with the internal oscillator, the PLL gives users a complete selection of clock
speeds, from 31 kHz to 32 MHz all without using an external crystal or clock
circuit.
Besides its availability as a clock source, the internal oscillator block provides a stable
reference source that gives the family additional features for robust operation:
Fail-Safe Clock Monitor: This option constantly monitors the main clock source
against a reference signal provided by the internal oscillator. If a clock failure
occurs, the controller is switched to the internal oscillator block, allowing for
continued low-speed operation or a safe application shutdown.
Two-Speed Start-up: This option allows the internal oscillator to serve as the
clock source from Power-on Reset, or wake-up from Sleep mode, until the primary
clock source is available.




Embedded Based Smart Antenna Orientation System

Department of ECE 9 H.K.B.K.C.E


2.1.3 Other Special Features
Memory Endurance: The Enhanced Flash cells for both program memory and
data EEPROM are rated to last for many thousands of erase/write cycles up to
100,000 for program memory and 1,000,000 for EEPROM. Data retention without
refresh is conservatively estimated to be greater than 40 years.
Self-programmability: These devices can write to their own program memory
spaces under internal software control. By using a boot loader routine located in
the protected Boot Block at the top of program memory, it becomes possible to
create an application that can update itself in the field.
Extended Instruction Set: The PIC18F2420/ 2520/4420/4520 families introduce
an optional extension to the PIC18 instruction set, which adds 8 new instructions
and an Indexed Addressing mode. This extension, enabled as a device
configuration option, has been specifically designed to optimize re-entrant
application code originally developed in high-level languages, such as C.
Enhanced CCP module: In PWM mode, this module provides 1, 2 or 4
modulated outputs for controlling half-bridge and full-bridge drivers. Other
features include Auto-Shutdown, for disabling PWM outputs on interrupt or other
select conditions and Auto-Restart, to reactivate outputs once the condition has
cleared.
Enhanced Addressable USART: This serial communication module is capable of
standard RS-232 operation and provides support for the LIN bus protocol. Other
enhancements include automatic baud rate detection and a 16-bit Baud Rate
Generator for improved resolution. When the microcontroller is using the internal
oscillator block, the USART provides stable operation for applications that talk to
the outside world without using an external crystal (or its accompanying power
requirement).
10-bit A/D Converter: This module incorporates programmable acquisition time,
allowing for a channel to be selected and a conversion to be initiated without
waiting for a sampling period and thus, reduce code overhead.
Extended Watchdog Timer (WDT): This enhanced version incorporates a 16-bit
prescaler, allowing an extended time-out range that is stable across operating
voltage and temperature.

Embedded Based Smart Antenna Orientation System

Department of ECE 10 H.K.B.K.C.E


2.2 Patch Antenna
A patch antenna (also known as a rectangular microstrip antenna) is a type of
radio antenna with a low profile, which can be mounted on a flat surface. It consists of a
flat rectangular sheet or "patch" of metal, mounted over a larger sheet of metal called
a ground plane. The assembly is usually contained inside a plastic random, which protects
the antenna structure from damage. Patch antennas are simple to fabricate and easy to
modify and customize. They are the original type of microstrip antenna described by
Howell;the two metal sheets together form a resonant piece of microstrip transmission
line with a length of approximately one-half wavelength of the radio waves. The radiation
mechanism arises from discontinuities at each truncated edge of the microstrip
transmission line. The radiation at the edges causes the antenna to act slightly larger
electrically than its physical dimensions, so in order for the antenna to be resonant, a
length of microstrip transmission line slightly shorter than one-half a wavelength at the
frequency is used. A patch antenna is usually constructed on a dielectric substrate, using
the same materials and lithography processes used to make printed circuit boards.


Fig 2.3 Patch Antenna

2.2.1 Properties of a Basic Microstrip Patch
A Microstrip or patch antenna is a low profile antenna that has a number of
advantages over other antennas it is lightweight, inexpensive, and easy to integrate with
Embedded Based Smart Antenna Orientation System

Department of ECE 11 H.K.B.K.C.E


accompanying electronics. While the antenna can be 3D in structure (wrapped around an
object, for exampe), the eements are usuay fat Hence their other name, planar
antennas. Note that a planar antenna is not always a patch antenna.
The following drawing shows a patch antenna in its basic form: a flat plate over a
ground plane (usually a PC board). The center conductor of a coax serves as the feed
probe to couple electromagnetic energy in and/or out of the patch. The electric field
distribution of a rectangular patch excited in its fundamental mode is also indicated. The
electric field is zero at the center of the patch, maximum (positive) at one side, and
minimum (negative) on the opposite side. It should be mentioned that the minimum and
maximum continuously change side according to the instantaneous phase of the applied
signal.
The electric field does not stop abruptly at the patchs periphery as in a cavity
rather, the fields extend the outer periphery to some degree. These field extensions are
known as fringing fields cause the patch to radiate.
2.2.2 Gain
The gain of a rectangular Microstrip patch antenna with air dielectric can be very
roughly estimated as follows. Since the length of the patch, half a wavelength, is about the
same as the length of a resonant dipole, we get about 2 dB of gain from the directivity
relative to the vertical axis of the patch. If the patch is square, the pattern in the horizontal
plane will be directional, somewhat as if the patch were a pair of dipoles separated by a
half-wave; this counts for about another 2-3 dB. Finally, the addition of the ground plane
cuts off most or all radiation behind the antenna, reducing the power averaged over all
directions by a factor of 2 (and thus increasing the gain by 3 dB). Adding this all up, we
get about 7-9 dB for a square patch, in good agreement with more sophisticated
approaches.
A typical radiation pattern for a linearly-polarized 900-MHz patch antenna is
shown below. The figure shows a cross-section in a horizontal plane; the pattern in the
vertical plane is similar though not identical. The scale is logarithmic, so (for example) the
power radiated at 180 (90 to the left of the beam center) is about 15 dB less than the
power in the center of the beam. The beam width is about 65 and the gain is about 9 dBi.
An infinitely-large ground plane would prevent any radiation towards the back of the
Embedded Based Smart Antenna Orientation System

Department of ECE 12 H.K.B.K.C.E


antenna (angles from 180 to 360), but the real antenna has a fairly small ground plane,
and the power in the backwards direction is only about 20 dB down from that in the main
beam.

Fig 2.4 Radiation Pattern

2.2.3 Impedance Matching
Looking at the current (magnetic field) and voltage (electrical field) variation along the
patch, the current is maximal at the center and minimal near the left and right edges, while
the electrical field is zero in the center and maximal near the left and minimal near the
right edges. The figures below clarify these quantities.


Fig 2.5 Current distribution on the Patch Antenna
Embedded Based Smart Antenna Orientation System

Department of ECE 13 H.K.B.K.C.E



Fig 2.6 U, I, Z Distribution along the Patchs resonant length

From the magnitude of the current and the voltage, we can conclude the impedance
is minimum (theoretically zero W) in the middle of the patch and maximum (typically
around 200 W, but depending on the Q of the leaky cavity) near the edges. Put differently,
there is a point where the impedance is 50 W somewhere along the "resonant length" (x)
axis of the element.
2.3 Stepper Motor
A stepper motor is a special type of electric motor that moves in increments, or
steps, rather than turning smoothly as a conventional motor does. The size of the
increment is measured in degrees and can vary depending on the application. Typical
increments are 0.9 or 1.8 degrees, with 400 or 200 increments thus representing a full
circle. The speed of the motor is determined by the time delay between each incremental
movement.

Fig. 2.7 Stepper Motor

Embedded Based Smart Antenna Orientation System

Department of ECE 14 H.K.B.K.C.E


2.3.1 Stepper motor basics with Working
A stepper motor is an electro mechanical device which converts electrical pulses
into discrete mechanical movements. The shaft or spindle of a stepper motor rotates
indiscrete step increments when electrical command pulses are applied to it in the proper
sequence. The motors rotation has several direct relationships to these applied input
pulses. The sequence of the applied pulses is directly related to the direction of motor
shafts rotation. The speed of the motor shafts rotation is directly related to the frequency
of the input pulses and the length of rotation is directly related to the number of input
pulses applied.

Fig 2.8 Phase Stepper motor
The most common stepper motors have 4 stator windings that are paired with a
centre-taped common. This type of stepper motor is commonly referred to as four-phase or
unipolar stepper motor.
The centre tap allows a change of current direction in each of two coils. When a
winding is grounded there by resulting in a polarity change of the stator. The Stepper
motor moves in fixed repeatable increment, which allows one to move it to a precise
position. This repeatable fixed movement is possible as a result of basic magnetic theory
where poles of the same polarity ripple and opposite poles attract. The stator poles are
determined by the circuit send through the wired coil. As the direction of the current
changes the polarity is also changed causing the reverse motion of the rotor. Here, Step
angle is the minimum degree of rotation associated with a single step. For example, for a
step angle of 1.8, the step per revolution is 200.
Embedded Based Smart Antenna Orientation System

Department of ECE 15 H.K.B.K.C.E




Fig 2.9 Unipolar stepper motor
Bipolar motors have a single winding per phase. The current in a winding needs to
be reversed in order to reverse a magnetic pole, so the driving circuit must be more
complicated, typically with an H-bridge arrangement (however there are several off-the-
shelf driver chips available to make this a simple affair). There are two leads per phase,
none are common.
Static friction effects using an H-bridge have been observed with certain drive
topologies. Dithering the stepper signal at a higher frequency than the motor can respond
to will reduce this "static friction" effect.
Because windings are better utilized, they are more powerful than a unipolar motor
of the same weight. This is due to the physical space occupied by the windings. A unipolar
motor has twice the amount of wire in the same space, but only half used at any point in
time, hence is 50% efficient (or approximately 70% of the torque output available).
Though a bipolar stepper motor is more complicated to drive, the abundance of driver
chips means this is much less difficult to achieve.
An 8-lead stepper is wound like a unipolar stepper, but the leads are not joined to
common internally to the motor. This kind of motor can be wired in several
configurations:
Unipolar.
Bipolar with series windings. This gives higher inductance but lower current per
winding.
Bipolar with parallel windings. This requires higher current but can perform better as
the winding inductance is reduced.
Embedded Based Smart Antenna Orientation System

Department of ECE 16 H.K.B.K.C.E


Bipolar with a single winding per phase. This method will run the motor on only half
the available windings, which will reduce the available low speed torque but require
less current


Fig 2.10 Bipolar Stepper Motor

2.3.2 Step Modes
Stepper motor "step modes" include Full, Half and Microstep. The type of step mode output
of any stepper motor is dependent on the design of the driver. Omegamation

offers stepper
motor drives with switch selectable full and half step modes, as well as microstepping drives with
either switch-selectable or software-selectable resolutions.
1. Full Step
Standard hybrid stepping motors have 200 rotor teeth, or 200 full steps per revolution of the
motor shaft. Dividing the 200 steps into the 360 of rotation equals a 1.8 full step angle.
Normally, full step mode is achieved by energizing both windings while reversing the current
alternately. Essentially one digital pulse from the driver is equivalent to one step.
2. Half Step
Half step simply means that the step motor is rotating at 400 steps per revolution. In this mode,
one winding is energized and then two windings are energized alternately, causing the rotor to
Embedded Based Smart Antenna Orientation System

Department of ECE 17 H.K.B.K.C.E


rotate at half the distance, or 0.9. Although it provides approximately 30% less torque, half-step
mode produces a smoother motion than full-step mode.
3. Microstep
Micro stepping is a relatively new stepper motor technology that controls the current in the motor
winding to a degree that further subdivides the number of positions between poles. Omegamation
micro stepping drives are capable of dividing a full step (1.8) into 256 micro steps, resulting in
51,200 steps per revolution (.007/step). Micro stepping is typically used in applications that
require accurate positioning and smoother motion over a wide range of speeds. Like the half-step
mode, micro stepping provides approximately 30% less torque than full-step mode.
2.3.3 Stepper Motor Advantages
1. The rotation angle of the motor is proportional to the input pulse.
2. The motor has full torque at standstill (if the windings are energized).
3. Precise positioning and repeatability of movement since good stepper motors have an
accuracy of 3 to 5% of a step and this error is non-cumulative from one step to the next.
4. Excellent response to starting/stopping/reversing.
5. Very reliable since there are no contact brushes in the motor. Therefore the life of the step
motor is simply dependant on the life of the bearing.
6. The stepper motors response to digital input pulses provides open-loop control, making
the motor simpler and less costly to control.
7. It is possible to achieve very low speed synchronous rotation with a load that is directly
coupled to the shaft.
8. A wide range of rotational speeds can be realized as the speed is proportional to the
frequency of the input pulses.
2.4 Transistor BC547

Fig 2.11 BC547
Embedded Based Smart Antenna Orientation System

Department of ECE 18 H.K.B.K.C.E


A BC547 transistor is a negative-positive-negative (NPN) transistor that is used for
many purposes. Together with other electronic components, such as resistors, coils, and
capacitors, it can be used as the active component for switches and amplifiers. Like all
other NPN transistors, this type has an emitter terminal, a base or control terminal, and a
collector terminal. In a typical configuration, the current flowing from the base to the
emitter controls the collector current. A short vertical line, which is the base, can indicate
the transistor schematic for an NPN transistor, and the emitter, which is a diagonal line
connecting to the base, is an arrowhead pointing away from the base.
There are various types of transistors, and the BC547 is a bipolar junction transistor
(BJT). There are also transistors that have one junction, such as the junction field-effect
transistor, or no junctions at all, such as the metal oxide field-effect transistor (MOSFET).
During the design and manufacture of transistors, the characteristics can be predefined and
achieved. The negative (N)-type material inside an NPN transistor has an excess of
electrons, while the positive (P)-type material has a lack of electrons, both due to a
contamination process called doping.
2.5 Power Supply - LM7805
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output
voltages. The general features of 7805 are output current up to 1A, output voltages of 5, 6,
8, 9, 10, 12, 15, 18, 24V, thermal overload protection, short circuit protection, output
transistor safe operating area protection

Fig 2.12 IC 7805
The IC 7805 is used to regulate this obtained 1V voltage. As can be seen, there are
ripples in the output of the 7805. The capacitors 1000F and 100F allows AC to flow
through it and these ripples flow to the ground and the pulsating DC is converted into DC
of 12V. The IC 7805 converts the 12V DC to 5V DC and this voltage is supplied to PIC
Controller.
The LM78XX series of three terminal regulators is available with several fixed
output voltages making them useful in a wide range of applications. One of these is local
Embedded Based Smart Antenna Orientation System

Department of ECE 19 H.K.B.K.C.E


on card regulation, eliminating the distribution problems associated with single point
regulation. The voltages available allow these regulators to be used in logic systems,
instrumentation, HiFi, and other solid state electronic equipment. Although designed
primarily as fixed voltage regulators these devices can be used with external components
to obtain adjustable voltages and currents.
The LM78XX series is available in an aluminium TO-3 package which will allow
over 1.0A load current if adequate heat sinking is provided. Current limiting is included to
limit the peak output current to a safe value. Safe area protection for the output transistor
is provided to limit internal power dissipation. If internal power dissipation becomes too
high for the heat sinking provided, the thermal shutdown circuit takes over preventing the
IC from overheating. Considerable effort was expanded to make the LM78XX series of
regulators easy to use and minimize the number of external components. It is not
necessary to bypass the output, although this does improve transient response. Input
bypassing is needed only if the regulator is located far from the filter capacitor of the
power supply. For output voltage other than 5V, 12V and 15V the LM117 series provides
an output voltage range from 1.2V to 57V.
2.6 MAX232
The MAX232 is an integrated circuit, first created by Maxim Integrated Products,
that converts signals from an RS-232 serial port to signals suitable for use
in TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and
typically converts the RX, TX, CTS and RTS signals.
The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a single
+ 5 V supply via on-chip charge pumps and external capacitors. This makes it useful for
implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V
to + 5 V range, as power supply design does not need to be made more complicated just
for driving the RS-232 in this case.
The receivers reduce RS-232 inputs (which may be as high as 25 V), to standard
5 V TTL levels. These receivers have a typical threshold of 1.3 V, and a
typical hysteresis of 0.5 V.
Embedded Based Smart Antenna Orientation System

Department of ECE 20 H.K.B.K.C.E


The later MAX232A is backwards compatible with the original MAX232 but may
operate at higher baud rates and can use smaller external capacitors 0.1 F in place of
the 1.0 F capacitors use with the origina evice
The newer MAX3232 is also backwards compatible, but operates at a broader
voltage range, from 3 to 5.5 V.



Fig 2.13 MAX232

2.7 Liquid Crystal Display (LCD)
Liquid crystal display (LCD), electronic display device that operates by applying
a varying electric voltage to a layer of liquid crystal, thereby inducing changes in its
optical properties. LCDs are commonly used for portable electronic games, as viewfinders
for digital cameras and camcorders, in video projection systems, for electronic billboards,
as monitors for computers, and in flat-panel televisions.
Embedded Based Smart Antenna Orientation System

Department of ECE 21 H.K.B.K.C.E




Fig 2.14 204 LCD

2.7.1 204 LCD

Fig 2.15 LCD Layout
This 20-character, 4-line parallel liquid crystal display achieves a large viewing area in a
compact package. It features a yellow-green LED backlight and uses the common
HD44780 interface, so sample interface code is widely available for a variety of
Embedded Based Smart Antenna Orientation System

Department of ECE 22 H.K.B.K.C.E


microcontrollers. This is the same LCD that is included as part of some of our Orangutan
X2 robot controller packages.
Pin Symbol Function
1 Vss Ground (0 V)
2 Vdd 5 V Logic supply voltage
3 Vo Contrast adjustment
4 RS H/L register select signal
5 R/W H/L read/write signal
6 E H/L enable signal
7-14 DB0 DB7 H/L data bus for 4- or 8-bit mode
15 A (LED+) Backlight anode
16 K (LED-) Backlight cathode

Table 2.1 Pin Configuration
2.7.2 Specifications of 20X4 LCD
1. Display Format : 20 characters (W) x 4 lines (H)
2. General Dimensions : 80.0 mm (W) x 36.0 mm (H) x 9.5 mm (T)
3. Character Size : 2.95 mm (W) x 4.35 mm (H)
4. Viewing Area : 64.0 mm (W) x 13.8 mm (H)
5. Power Supply : 5.0V
6. Controller :KS0066 Or Equal
7. View nge : 6 ocock or 12 ocock
8. Temperature Range : 0
o
C to 50
o
C (Normal); -20
o
C to 70
o
C (Wide)

The 20x4 LCD is electrically and mechanically interchangeable with 20x4 LCDs from
several other vendors. The only differences we've seen among different 20x4 LCDs are:
Embedded Based Smart Antenna Orientation System

Department of ECE 23 H.K.B.K.C.E


LED backlight brightness, voltage and current vary widely, as does the quality of
the display.
There is a resistor Rf which sets the spee of the L interface y controing
the internal oscillator frequency. Several displays evaluated have a low resistor
value. This makes the display too slow.
At 5V the resistor Rf should be 91k ohms. At 3V it should be 75k ohms. Using a 3V
display at 5V is acceptable from a voltage standpoint (the display can operate on 3-5V) but
the oscillator will then be running too slowly. One fix is to always check the busy flag and
not use a fixed time delay in the code, and then it will work regardless of the LCD speed.
The other option is to always allow enough delay for the slower display.
2.8 Keypad
A keypad is a set of buttons arranged in a block or "pad" which usually bear digits,
symbols and usually a complete set of alphabetical letters. If it mostly contains numbers
then it can also be called a numeric keypad. Keypads are found on many alphanumeric
keyboards and on other devices such as calculators, push-button telephones, combination
locks, and digital door locks, which require mainly numeric input.

Fig 2.16 Keypad



Embedded Based Smart Antenna Orientation System

Department of ECE 24 H.K.B.K.C.E


2.9 RF Detector and Connector
2.9.1 RF Connector
A coaxial RF connector is an electrical connector designed to work at radio
frequencies in the multi-megahertz range. RF connectors are typically used with coaxial
cables and are designed to maintain the shielding that the coaxial design offers. Better
models also minimize the change in transmission line impedance at the connection.
Mechanically, they provide a fastening mechanism (thread, bayonet, braces, push pull)
and springs for a low ohmic electric contact while sparing the gold surface, thus allowing
above 1000 reconnects and reducing the insertion force. Research activity in the area of
radio-frequency (RF) circuit design has surged in the 2000s in direct response to the
enormous market demand for inexpensive, high-data-rate wireless transceivers


Fig 2.17 SMA Connector
SMA (Sub Miniature version A) connectors are semi-precision coaxial RF
connectors developed in the 1960s as a minimal connector interface for coaxial cable with
a screw type coupling mechanism. The connector has a 50 impedance. It is designed for
use from DC to 18 GHz
2.9.2 RF Detector
The RF Detector, like most bug detectors, detect radio frequency signals sent from
listening devices such as electronic bugs hidden in objects, or covertly placed in rooms.
This RF Detector is able to sweep a room or area for privacy invading bugs and warn you
about active RF transmitters.
Embedded Based Smart Antenna Orientation System

Department of ECE 25 H.K.B.K.C.E


The RF Detector can detect RF emissions and show the signal strength on its
unique bar graph display. This is extremely helpful when you want to detect an active
listening device, and attempt to locate it by observing the increase in the listening devices
signal output. As you physically come closer to the listening device, you can verify the
transmission signal strength using the RF Detectors graphic indicator.

Fig 2.18 RF Detector

Most users of this RF Detector are not consumers but professionals with a
technical back ground and or scientific understanding of the radio signals encountered.
In addition, its graphic indicator is made up of 8 segments to help determine the
signal level of the radio field emission, giving the user the ability to track down the
proximity of audio surveillance devices, as well as detect cellular phones.
The RF Detector will also display the operating mode during bug sweeps and rf
sweeps. The RF Detector provides a wide spectrum of measurement for radio signal
analysis applications including RF transmission and microwave frequency identification at
the greatest possible distance. Once a transmitter has been located and found, the RF
Detector pinpoints and locks onto the precise radio or microwave frequency broadcasting
your private conversations. The captured transmitter can then be used for disinformation
purposes.

Embedded Based Smart Antenna Orientation System

Department of ECE 26 H.K.B.K.C.E


Specifications:
Antenna: Integrated (built-in) for discreet bug sweeps
Display: 8 signal level bar graph (the primary alert indicator)
2.10 Universal Asynchronous Receiver Transmitter (UART)
The Universal Asynchronous Receiver Transmitter or simple UART ("you art" as
some will pronounce) is one of the common peripheral found on microcontrollers (MCU)
widely used for communication with the external devices and systems. Modules, ASIC's ,
and PC's are among the devices that the microcontroller can communicate to through the
UART.
For microcontrollers that offer this peripheral, the UART circuitry is built-in the
chip and can be accessed from 2 pins, a transmitter and a receiver usually named RX and
TX or RXD and TXD respectively.
With such a configuration, a full duplex set up is possible. Although in some
applications, such as in display modules, only the transmit pin may be utilized as the MCU
only needs to send graphic information to the display. A GPS module on the other hand,
may only require the UART's receive pin since the MCU only awaits the GPS data but
need not sent information to the module. In any case, we can say that the UART can
receive and transmit information to and from another compatible device.

2.10.1 UART Fundamentals

As mentioned earlier, the UART is used for digital communications. The elements
of a usual setup, which we shall adopt in this discussion, are a UART of an external device
or system connected to the built-in UART of the host MCU. So long as both UART's are
operating a the same voltage level, the connection between the two systems shall be a
direct connection either by wire or PCB track.
It is noteworthy to mention at this point that the UART is capable of transmitting
or receiving 7 or 8 bits of data plus 2 or 3 framing bits. One start bit, eight data bits and
one stop bit is the common configuration. We can therefore say that in common practice,
the UART can receive or transmit 1 byte of data.


Embedded Based Smart Antenna Orientation System

Department of ECE 27 H.K.B.K.C.E


The transmit and receive pins of the UART are almost independent of each other in
terms of its main function. In asynchronous mode, the RX pin can practically receive data
regaress of the TX pins activity an vice versa We cou therefore reak the system
into two independent half duplex systems as in Fig 2.19.


Fig 2.19 UART Communication System.

2.10.2 UART Data Packet
Fig 2.20 shows the arrangement of the data sent in one UART "packet". The
packet begins with start bit, which is a logic 0, being transmitted/received first. In the
software side, this bit is important as we can poll the RX pin for this bit to signal that a
packet of data is coming. The data bits or the payload may or may not have a parity bit.
Below shows how a typical data packet would be:




Fig 2.20 Data Packet







Embedded Based Smart Antenna Orientation System

Department of ECE 28 H.K.B.K.C.E


2.10.3 UART Registers
To use and control the UART, special internal registers are assigned to them.
Usually there will be at least four registers: control, status, receive and transmit registers.
All these vary in size depending on the MCU. For example, high-end processors will have
three-word control register for setting various features/settings that may not be present in
simpler processors, hence, one word register may be enough.

1. Control Register - Contains settings for the UART. This register/s must be set prior to
use. Some common settings/features include: Number of data bits, number of stop bits,
parity control, UART TX/RX enable/disable, baud rate setting, RX/TX interrupt enable,
etc.
2. Status Register - From its name, this contains information about the UART's condition
or state. During run-time, this register may be helpful in guiding the processor on the next
instruction to execute like when to retrieve data. Information that can be retrieved include:
data received flag, data send/receive ready, UART active flag,etc.
3. Receive Register - This is the where received data is temporarily stored.

2.10.4 Features
Functionally compatible with the NS16450 UART.
Faster performance than industry standard hardwired devices.
Inserts or extracts standard asynchronous communication bits (Start, Stop and
Parity) to or from the serial data.
Holding and shifting registers eliminate the need for precise synchronization
between the CPU and serial data.
Standard CPU Interface.
Separate interrupt lines for Data Received (RxRdyn) and Data Transmitted
(TxRdyn).
A common interrupt line for all internal UART Data and Error events. Interrupt
conditions include: receiver line errors, receiver buffer available, transmit buffer
empty and when a modem status flag change is detected.
Fully prioritized interrupt system control.
MODEM interface functions (CTS, RTS, DSR, DTR, RI and DCD).

Embedded Based Smart Antenna Orientation System

Department of ECE 29 H.K.B.K.C.E


Fully programmable serial interface characteristics:
- 5, 6, 7 or 8-bit characters.
- Even, odd, or no-parity bit generation and detection.
- 1, 1.5 or 2-stop bit generation and detection.
False Start bit detection.
Line break generation and detection.
Interactive control signalling and status reporting capabilities.
Separate input and output data buses for use as an embedded module in a larger
design.
Transmitter enabled by new data writes to Transmit Holding Register.
Receiver synchronizes off the Start bit.
Receiver samples all incoming bits at the centre of each bit.
2.11 Crystal Oscillator
A crystal oscillator is an electronic oscillator circuit that uses the
mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical
signal with a very precise frequency.
[1][2][3]
This frequency is commonly used to keep track
of time (as in quartz wristwatches), to provide a stable clock signal for digital integrated
circuits, and to stabilize frequencies for radio transmitters and receivers. The most
common type of piezoelectric resonator used is the quartz crystal, so oscillator circuits
incorporating them became known as crystal oscillators,
[1]
but other piezoelectric materials
including polycrystalline ceramics are used in similar circuits.
Quartz crystals are manufactured for frequencies from a few tens of kilohertz to
tens of megahertz. More than two billion crystals are manufactured annually. Most are
used for consumer devices such as wristwatches, clocks, radios, computers,
and cellphones. Quartz crystals are also found inside test and measurement equipment,
such as counters, signal generators, and oscilloscopes.

Fig 2.21 Crystal Oscillator
Embedded Based Smart Antenna Orientation System

Department of ECE 30 H.K.B.K.C.E


2.11.1 Operation
A crystal is a solid in which the constituent atoms, molecules, or ions are packed in
a regularly ordered, repeating pattern extending in all three spatial dimensions.
Almost any object made of an elastic material could be used like a crystal, with
appropriate transducers, since all objects have natural resonant frequencies of vibration.
For example, steel is very elastic and has a high speed of sound. It was often used
in mechanical filters before quartz. The resonant frequency depends on size,
shape, elasticity, and the speed of sound in the material. High-frequency crystals are
typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as
those used in digital watches, are typically cut in the shape of a tuning fork. For
applications not needing very precise timing, a low-cost ceramic resonator is often used in
place of a quartz crystal.
When a crystal of quartz is properly cut and mounted, it can be made to distort in
an electric field by applying a voltage to an electrode near or on the crystal. This property
is known as piezoelectricity. When the field is removed, the quartz will generate an
electric field as it returns to its previous shape, and this can generate a voltage. The result
is that a quartz crystal behaves like a circuit composed of
an inductor, capacitor and resistor, with a precise resonant frequency.
Quartz has the further advantage that its elastic constants and its size change in
such a way that the frequency dependence on temperature can be very low. The specific
characteristics will depend on the mode of vibration and the angle at which the quartz is
cut (relative to its crystallographic axes).Therefore, the resonant frequency of the plate,
which depends on its size, will not change much, either. This means that a quartz clock,
filter or oscillator will remain accurate. For critical applications the quartz oscillator is
mounted in a temperature-controlled container, called a crystal oven, and can also be
mounted on shock absorbers to prevent perturbation by external mechanical vibrations.
2.12 MOSFET
The metaloxidesemiconductor field-effect transistor (MOSFET, MOS-FET,
or MOS FET) is a transistor used for amplifying or switching electronic signals. Although
the MOSFET is a four-terminal device with source (S), gate (G), drain (D), and body (B)
Embedded Based Smart Antenna Orientation System

Department of ECE 31 H.K.B.K.C.E


terminals,the body (or substrate) of the MOSFET often is connected to the source
terminal, making it a three-terminal device like other field-effect transistors. Because these
two terminals are normally connected to each other (short-circuited) internally, only three
terminals appear in electrical diagrams. The MOSFET is by far the most common
transistor in both digital and analog circuits, though the bipolar junction transistor was at
one time much more common.

Fig 2.22 Enhancement Mode MOSFET
In enhancement mode MOSFETs, a voltage drop across the oxide induces
a conducting channel between the source and drain contacts via the field effect. The term
"enhancement mode" refers to the increase of conductivity with increase in oxide field that
adds carriers to the channel, also referred to as the inversion layer. The channel can
contain electrons (called an nMOSFET or nMOS), or holes (called a pMOSFET or
pMOS), opposite in type to the substrate, so nMOS is made with a p-type substrate, and
pMOS with an n-type substrate (see article on semiconductor devices). In the less
common depletion mode MOSFET, detailed later on, the channel consists of carriers in a
surface impurity layer of opposite type to the substrate, and conductivity is decreased by
application of a field that depletes carriers from this surface layer.
The 'metal' in the name MOSFET is now often a misnomer because the previously
metal gate material is now often a layer of polysilicon (polycrystalline
silicon). Aluminium had been the gate material until the mid-1970s, when polysilicon
became dominant, due to its capability to form self-aligned gates. Metallic gates are
regaining popularity, since it is difficult to increase the speed of operation of transistors
without metal gates.
Embedded Based Smart Antenna Orientation System

Department of ECE 32 H.K.B.K.C.E


Likewise, the 'oxide' in the name can be a misnomer, as different dielectric
materials are used with the aim of obtaining strong channels with applied smaller voltages.
An insulated-gate field-effect transistor or IGFET is a related term almost synonymous
with MOSFET. The term may be more inclusive, since many "MOSFETs" use a gate that
is not metal, and a gate insulator that is not oxide. Another synonym is MISFET for
metalinsulatorsemiconductor FET.
The traditional metaloxidesemiconductor (MOS) structure is obtained by
growing a layer of silicon dioxide (SiO
2
) on top of a silicon substrate and depositing a
layer of metal or polycrystalline silicon (the latter is commonly used). As the silicon
dioxide is a dielectric material, its structure is equivalent to a planar capacitor, with one of
the electrodes replaced by a semiconductor. When a voltage is applied across a MOS
structure, it modifies the distribution of charges in the semiconductor. If we consider a p-
type semiconductor (with the density of acceptors, p the density of holes; p = N
A
in
neutral bulk), a positive voltage, , from gate to body (see figure) creates a depletion
layer by forcing the positively charged holes away from the gate-insulator/semiconductor
interface, leaving exposed a carrier-free region of immobile, negatively charged acceptor
ions (see doping (semiconductor)). If is high enough, a high concentration of
negative charge carriers forms in an inversion layer located in a thin layer next to the
interface between the semiconductor and the insulator. Unlike the MOSFET, where the
inversion layer electrons are supplied rapidly from the source/drain electrodes, in the MOS
capacitor they are produced much more slowly by thermal generation through carrier
generation and recombination centers in the depletion region. Conventionally, the gate
voltage at which the volume density of electrons in the inversion layer is the same as the
volume density of holes in the body is called the threshold voltage. When the voltage
between transistor gate and source (V
GS
) exceeds the threshold voltage (V
th
), it is known
as overdrive voltage.
2.13 Additional
2.13.1 Real time Clock
A real-time clock (RTC) is a computer clock (most often in the form of an integrated
circuit) that keeps track of the current time. Although the term often refers to the devices
Embedded Based Smart Antenna Orientation System

Department of ECE 33 H.K.B.K.C.E


in personal computers, servers and embedded systems, RTCs are present in almost any
electronic device which needs to keep accurate time.
Purpose
Although keeping time can be done without an RTC, using one has benefits:
Low power consumption (important when running from alternate power)
Frees the main system for time-critical tasks
Sometimes more accurate than other methods
A GPS receiver can shorten its start up time by comparing the current time, according to
its RTC, with the time at which it last had a valid signal. If it has been less than a few
hours, then the previous ephemeris is still usable.
Power source
RTCs often have an alternate source of power, so they can continue to keep time while
the primary source of power is off or unavailable. This alternate source of power is
normally lithium in older systems, but some newer systems use a super capacitor, because
they are rechargeable and can be soldered. The alternate power source can also supply
power to battery backed RAM.
Timing
Most RTCs use a crystal oscillator, but some use the power line frequency. In many
cases the oscillator's frequency is 32.768 kHz. This is the same frequency used in quartz
clocks and watches, and for the same reasons, namely that the frequency is exactly
2
15
cycles per second, which is a convenient rate to use with simple binary counter
circuits.
2.13.2 Relay
A relay is an electrically operated switch. Many relays use an electromagnet to
operate a switching mechanism mechanically, but other operating principles are also used.
Relays are used where it is necessary to control a circuit by a low-power signal (with
complete electrical isolation between control and controlled circuits), or where several
circuits must be controlled by one signal. The first relays were used in long distance
telegraph circuits, repeating the signal coming in from one circuit and re-transmitting it to
Embedded Based Smart Antenna Orientation System

Department of ECE 34 H.K.B.K.C.E


another. Relays were used extensively in telephone exchanges and early computers to
perform logical operations.


Fig 2.23 Relay
A type of relay that can handle the high power required to directly control an electric
motor or other loads is called a contactor. Solid-state relays control power circuits with
no moving parts, instead using a semiconductor device to perform switching. Relays with
calibrated operating characteristics and sometimes multiple operating coils are used to
protect electrical circuits from overload or faults; in modern electric power systems these
functions are performed by digital instruments still called "protective relays".
Design and Operation
A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron
core, an iron yoke which provides a low reluctance path for magnetic flux, a movable
iron armature, and one or more sets of contacts (there are two in the relay pictured). The
armature is hinged to the yoke and mechanically linked to one or more sets of moving
contacts. It is held in place by a spring so that when the relay is de-energized there is an air
gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay
pictured is closed, and the other set is open. Other relays may have more or fewer sets of
contacts depending on their function. The relay in the picture also has a wire connecting
the armature to the yoke. This ensures continuity of the circuit between the moving
contacts on the armature, and the circuit track on the printed circuit board (PCB) via the
yoke, which is soldered to the PCB.
Embedded Based Smart Antenna Orientation System

Department of ECE 35 H.K.B.K.C.E


Then an electric current is passed through the coil it generates a magnetic field that
activates the armature and the consequent movement of the movable contact either makes
or breaks (depending upon construction) a connection with a fixed contact. If the set of
contacts was closed when the relay was de-energized, then the movement opens the
contacts and breaks the connection, and vice versa if the contacts were open. When the
current to the coil is switched off, the armature is returned by a force, approximately half
as strong as the magnetic force, to its relaxed position. Usually this force is provided by a
spring, but gravity is also used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low-voltage application this reduces noise; in a high
voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed across the coil to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a voltage spike dangerous to semiconductor circuit components. Some
automotive relays include a diode inside the relay case. Alternatively, a contact protection
network consisting of a capacitor and resistor in series (snubber circuit) may absorb the
surge. If the coil is designed to be energized with alternating current (AC), a small copper
"shading ring" can be crimped to the end of the solenoid, creating a small out-of-phase
current which increases the minimum pull on the armature during the AC cycle.
A solid-state relay uses a thyristor or other solid-state switching device, activated by
the control signal, to switch the controlled load, instead of a solenoid.
An optocoupler (a light-emitting diode (LED) coupled with a photo transistor) can be used
to isolate control and controlled circuits.
2.13.3 LM1117

Fig 2.24 LM117
Embedded Based Smart Antenna Orientation System

Department of ECE 36 H.K.B.K.C.E


The LM1117 is a series of low dropout voltage regulators with a dropout of 1.2V
at 800mA of load current. It has the same pin-out as Nationa Semiconuctors inustry
standard LM317.The LM1117 is available in an adjustable version, which can set the
output voltage from 1.25V to 13.8V with only two external resistors. In addition, it is also
available in five fixed voltages, 1.8V, 2.5V, 2.85V, 3.3V, and 5V.

The LM1117 offers current limiting and thermal shutdown. Its circuit includes a
zener trimmed bandgap reference to assure output voltage accuracy to within 1%.
The LM1117 series is available in LLP, TO-263, SOT-223, TO-220, and TO-252
D-PK packages minimum of 10F tantaum capacitor is require at the output to
improve the transient response and stability.
The LM1117-N is a series of low dropout voltage 2regulators with a dropout of 1.2V at
800mA of load current. It has the same pin-out as National Semiconductor's industry
standard LM317. The LM1117-N is available in an adjustable version, which can set the
output voltage from 1.25V to 13.8V with only two external resistors. In addition, it is also
available in five fixed voltages, 1.8V, 2.5V, 2.85V, 3.3V, and 5V. The LM1117-N offers
current limiting and thermal shutdown. Its circuit includes a zener trimmed bandgap
reference to assure output voltage accuracy to within 1%. The LM1117-N series is
available in WSON, PFM, SOT-223, TO-220, and TO-263 DDPAK packages. A
minimum of 10F tantaum capacitor is require at the output to improve the transient
response and stability.
The applications of LM117 are:
25V Moe for SSI-2 Active Termination
Post Reguator for Switching / onverter
High Efficiency Linear Reguators
Battery harger
Battery Powere Instrumentation




Embedded Based Smart Antenna Orientation System

Department of ECE 37 H.K.B.K.C.E


2.14 PCB Board

Fig 2.25 PCB Board






Embedded Based Smart Antenna Orientation System

Department of ECE 38 H.K.B.K.C.E


Chapter 3
SOFTWARE DESCRIPTION
3.1 Embedded C
3.1.1 Embedded Systems Programming
Embedded systems programming is different from developing applications on a
desktop computers. Key characteristics of an embedded system, when compared to PCs,
are as follows:
Embedded devices have resource constraints(limited ROM, limited RAM, limited
stack space, less processing power)
Components used in embedded system and PCs are different; embedded systems
typically uses smaller, less power consuming components.
Embedded systems are more tied to the hardware.

Two salient features of Embedded Programming are code speed and code size. Code
speed is governed by the processing power, timing constraints, whereas code size is
governed by available program memory and use of programming language. Goal of
embedded system programming is to get maximum features in minimum space and
minimum time.
Embedded systems are programmed using different type of languages:
Machine Code
Low level language, i.e., assembly
High level language like C, C++, Java, Ada, etc.
Application level language like Visual Basic, scripts, Access, etc.
3.1.2 Embedded C
Embedded C is a set of language extensions for the C Programming language by the C
Standards committee to address commonality issues that exist between C extensions for
different embedded systems. Historically, embedded C programming requires nonstandard
unions, etc.
Embedded Based Smart Antenna Orientation System

Department of ECE 39 H.K.B.K.C.E


3.1.3 Advantages of Embedded C
Extensions to the C language in order to support exotic features such as fixed-point
arithmetic, multiple distinct memory banks, and basic I/O operations.
In 2008, the C Standards Committee extended the C language to address these issues
by providing a common standard for all implementations to adhere to. It includes a
number of features not available in normal C, such as, fixed-point arithmetic, named
address spaces, and basic I/O hardware addressing.
Embedded C use most of the syntax and semantics of standard C, e.g., main() function,
variable definition, data type declaration, conditional statements (if, switch. case), loops
(while, for), functions, arrays and strings, structures and union, bit operations, macros,
Use of C in embedded systems is driven by following advantages
It is small and reasonably simpler to learn, understand, program and debug.
C Compilers are available for almost all embedded devices in use today, and there
is a large pool of experienced C programmers.
Unlike assembly, C has advantage of processor-independence and is not specific to
any particular microprocessor/ microcontroller or any system. This makes it
convenient for a user to develop programs that can run on most of the systems.
As C combines functionality of assembly language and features of high level
languages, C is treated as a mie-level computer anguage or high level
assembly anguage
It is fairly efficient
It supports access to I/O and provides ease of management of large embedded
projects.
Many of these advantages are offered by other languages also, but what sets C apart from
others like Pascal, FORTRAN, etc. is the fact that it is a middle level language; it provides
direct hardware control without sacrificing benefits of high level languages.
3.1.4 Difference Between C And Embedded C
Though C and embedded C appear different and are used in different contexts, they
have more similarities than the differences. Most of the constructs are same; the
difference lies in their applications.
Embedded Based Smart Antenna Orientation System

Department of ECE 40 H.K.B.K.C.E


C is used for desktop computers, while embedded C is for microcontroller based
applications. Accordingly, C has the luxury to use resources of a desktop PC like
memory, OS, etc. While programming on desktop systems, we need not bother
about memory. However, embedded C has to use with the limited resources
(RAM, ROM, I/Os) on an embedded processor. Thus, program code must fit into
the available program memory. If code exceeds the limit, the system is likely to
crash.
Compilers for C (ANSI C) typically generate OS dependant
executables. Embedded C requires compilers to create files to be downloaded to
the microcontrollers/microprocessors where it needs to run. Embedded compilers
give access to all resources which is not provided in compilers for desktop
computer applications.
Embedded systems often have the real-time constraints, which is usually not there
with desktop computer applications.
Embedded systems often do not have a console, which is available in case of
desktop applications.
So, what basically is different while programming with embedded C is the
mindset; for embedded applications, we need to optimally use the resources, make
the program code efficient, and satisfy real time constraints, if any. All this is done
using the basic constructs, syntaxes, and function libraries of
3.2 MPLAB IDE v8
The current version of MPLAB IDE is version 8.90. MPLAB IDE v8.92 which is
due to be released in June 2013 , will be the last MPLAB 8 version that will contain new
device support. It is a 32-bit application on Microsoft Windows and includes several free
software components for application development, hardware emulation and debugging.
MPLAB IDE also serves as a single, unified graphical user interface for additional
Microchip and third-party software and hardware development tools.
Both Assembly and C programming languages can be used with MPLAB IDE v8.
Others may be supported through the use of third-party programs.
Support for MPLAB IDE, along with sample code, tutorials, and drivers can be
found on Microchip's website. MPLAB IDE v8 does not support Linux, UNIX or
Macintosh operating systems.
Embedded Based Smart Antenna Orientation System

Department of ECE 41 H.K.B.K.C.E


3.2.1 MPLAB IDE Working Procedure
1. First download both MPLAB and C18 and install them into the default directories
2. After you have finished the above step, open MPLAB.

3. Go to Menu->Project->Project Wizard.

Embedded Based Smart Antenna Orientation System

Department of ECE 42 H.K.B.K.C.E


4. Hit Next to bypass the Welcome screen and select the PIC processor for the project and
hit Next.

5. Select the Microchip C18 Toolsuite and hit Next (This assumes C18 was installed
previously).

Embedded Based Smart Antenna Orientation System

Department of ECE 43 H.K.B.K.C.E


6. Give the project a name and directory and hit Next.

7. Hit OK to create directory, if needed.


Embedded Based Smart Antenna Orientation System

Department of ECE 44 H.K.B.K.C.E


8. Find the C18 lkr directory, usually C:\MCC18\lkr\18f458i.lkr, Hit Add>> and check
box.

9. Hit Next and then hit Finish.

10. Go to Menu->Project->Add New File to Project.
Embedded Based Smart Antenna Orientation System

Department of ECE 45 H.K.B.K.C.E



11. Browse and find your project directory.
To use MPLAB for an Assembly program, save a file with the .asm extension. MPLAB
will open the file.

Embedded Based Smart Antenna Orientation System

Department of ECE 46 H.K.B.K.C.E


12. Now you can type your Assembly code or insert the Assembly code into the file.

13. The ORG value is already set by the linker; however, if you want to compile the
program for a different PIC. processor you must copy and insert the new value for ORG
which is found in the .lkr file.

14. Click the Build Toolbar button to compile.
Embedded Based Smart Antenna Orientation System

Department of ECE 47 H.K.B.K.C.E



15. To simulate your program go to Menu->Debug->Select Tool->3 MPLAB SIM.




16. To view the registers and variables Go to Menu->View->Watch.
Embedded Based Smart Antenna Orientation System

Department of ECE 48 H.K.B.K.C.E



17. Select PORTB and PORTD and hit Add SFR.


1. To single step click on the icon on the Debug Toolbar.
Embedded Based Smart Antenna Orientation System

Department of ECE 49 H.K.B.K.C.E


2. To set a breakpoint on Line 11 right-click on the line and select Set Breakpoint.

3. Hit the Run Toolbar button several times and observe the values changing in Watch.

Embedded Based Smart Antenna Orientation System

Department of ECE 50 H.K.B.K.C.E


4. To use MPLAB for a C program, right-click on the .asm file in the project and select
Remove.

5. Go to Menu->Project->Add New File to Project Browse your project directory and save
a file with the .c extension. MPLAB will open the file.

Embedded Based Smart Antenna Orientation System

Department of ECE 51 H.K.B.K.C.E


6. Now you can type your C18 code or insert the C18 code into the file.

7. Click the Build Toolbar button to compile the program.

Embedded Based Smart Antenna Orientation System

Department of ECE 52 H.K.B.K.C.E


8.To simulate the program, set a breakpoint by right-clicking the line and selecting Set
Breakpoint.

9. Press F2 an Remove the asm reakpoint, which has a ? next to it, hit OK

Embedded Based Smart Antenna Orientation System

Department of ECE 53 H.K.B.K.C.E


10. Hit the Run Toolbar button several times and observe the values changing in Watch.


3.3 X-CTU
X-CTU is a Windows-based application provided by Digi. This program was
esigne to interact with the firmware fies foun on igis RF proucts an to provie a
simple-to-use graphical user interface to them.
X-CTU is designed to function with all Windows-based computers running
Microsoft Windows 98 SE and above. X-TU can either e ownoae from igis We
site or an installation CD. When properly installed it can be launched by clicking on the
icon on the PC desktop (see Fig 3.1) or selecting from the Start menu

Fig 3.1 Icon on PC Desktop
Embedded Based Smart Antenna Orientation System

Department of ECE 54 H.K.B.K.C.E




3.3.1 Working Procedure Of X-CTU
When launched, you will see four tabs across the top of the program. Each of these
tabs has a different function. The four tabs are:
PC Settings: Allows a customer to select the desired COM port and configure that
port to fit the radios settings.
Range Test: Allows a customer to perform a range test between two radios.
Terminal: Allows access to the computers COM port with a terminal emulation
program.
Modem Configuration: ows the aiity to program the raios firmware
settings via a graphical user interface. This tab also allows customers the ability to
change firmware versions.

Embedded Based Smart Antenna Orientation System

Department of ECE 55 H.K.B.K.C.E




1. PC Settings Tab
When the program is aunche, the efaut ta seecte is the P Settings ta The
PC Settings tab is broken down into three basic areas: The COM port setup, the Host
Setup, and the User Com ports.

COM port setup:
The PC settings tab allows the user to select a COM port and configure the selected COM
port settings when accessing the port. Some of these settings include: Baud Rate: Both
standard and non-standard Flow Control: Hardware, Software (Xon/Xoff), None Data bits:
4, 5, 6, 7, and 8 data bits Parity: None, Odd, Even, Mark and Space Stop bit: 1, 1.5, and 2
To change any of the above settings, select the pull down menu on the left of the value and
select the desired setting. To enter a non-standard baud rate, type the baud rate into the
baud rate box to the left. The Test / Query button is used to test the selected COM port and
PC settings. If the settings and COM port are correct, you will receive a response similar
to the one depicted in Fig below.
Embedded Based Smart Antenna Orientation System

Department of ECE 56 H.K.B.K.C.E




Host Setup:
The Host Setup tab allows the user to configure how the X-CTU program is to interface
with a raios firmware This incues etermining whether PI or T comman moe
wi e use to access the moues firmware as we as the proper comman moe
character and sequence. By default, the Host Settings are as follows: API mode: not
enabled (Not checked) Command mode Character: + (ACSII) 2B (Hex). Before Guard
Time: 1000 (1 Sec) After Guard Time: 1000 (1 Sec) This is the default value of our radios.
If this is not the value of the AT, BT, or GT commands of the connected radio, enter the
respective value here.

User COM ports:
The user OM port option aows the user to or eete a user-created COM port.
This is only for temporary use. Once the program has closed, the user-created COM port
will disappear and is no longer accessible to the program.

2. Range Test Tab
The range test tab is designed to verify the range of the radio link by sending a user-
specified data packet and verifying the response packet is the same, within the time
specified. For performing a standard range test, please follow the steps found in most
Quick Start or Getting Started Guides that ship with the product.


Packet Data and Size
By default, the size of the data packet sent is 32 bytes. This data packet specified can be
adjusted in either size or the text sent.

Embedded Based Smart Antenna Orientation System

Department of ECE 57 H.K.B.K.C.E




To moify the size of the packet sent, change the vaue next to the reate ata ox an
cick on the reate ata utton If you want to change the data sent, delete the text in
the transmit window and place in your desired text. By modifying the text, data packet
size, packet delay and the data receive timeout; the user is able to simulate a wide range of
scenarios.
API Function:
The X-CTU also allows the user to test the API function of a radio during a range test. To
perform a range test with the API function of the radio, follow the steps outlined below:
1: Configure the Base with API enabled and a unique 16 bit or 64 bit source address.
2: Configure the remote radio with a unique source address and set the Destination address
to equa the Base raios source aress
3: Enable the API option of the X-CTU on the PC Settings tab and connect the base radio
to the PC.
4: Connect the red loopback adapter to the remote radio and place them a distance apart.
5: Enter either the 16 bit or 64 bit destination address of the remote radio into the
Destination Address box on the Range Test tab.
6: Create a data packet of your choosing by typing in the data in the Transmit box
Embedded Based Smart Antenna Orientation System

Department of ECE 58 H.K.B.K.C.E


7: To start a Range test, click on Start.
You will notice the TX failures, Purge, CCA, and ACK messages will increment
accordingly while the range test is performed. To stop a range test, click on the top button.



3. The Terminal Tab
The Terminal tab has three basic functions: Terminal emulator Ability to send and
receive predefined data pacts (Assemble packet) Ability to send and receive data in Hex
and ASCII formats (Show/Hide hex)
The main terminal window
The main white portion of this tab is where most of the communications information will
occur while using X-CTU as a terminal emulator. The text in blue is what has been typed
in an irecte out to the raios seria port whie the re text is the incoming ata from
the raios serial port.
Embedded Based Smart Antenna Orientation System

Department of ECE 59 H.K.B.K.C.E



Assemble Packet
The Assemble Packet option on the Terminal tab is designed to allow the user to assemble
a data packet in either ASCII or Hex characters. This is accomplished by selecting the
Assemble packet window and choosing either ASCII (default) or Hex. Once selected, the
data packet is assembly by typing in the desired characters as depicted in Fig.



Embedded Based Smart Antenna Orientation System

Department of ECE 60 H.K.B.K.C.E


The Line Status indicators depicted in shows the status of the RS-232 hardware flow
control lines. Green indicates the line is asserted while black indicates de-asserted.
The Break option is for engaging the serial line break. This can be accomplished by
checking or asserting the Break option. Asserting the Break will place the DI line high and
prevent data from being sent to the radio.
4. Modem Configuration tab
The Modem configuration tab has four basic functions:
1: Provie a Graphica User Interface with a raios firmware
2: Rea an Write firmware to the raios microcontroer
3: Download updated firmware files from either the web or from a compressed file
4: Saving or loading a modem profile.

Reading a radios firmware
To rea a raios firmware, foow the steps outine eow:
1: Connect the radio module to the interface board and connect this assembly or a
package raio PKG) to the Ps corresponing port IE: USB, RS232, Ethernet
etc.)
2: Set the PC Settings tab to the raios efaut settings
3: On the Moem onfiguration ta, seect Rea from the Moem Parameters
and Firmware section.

Making changes to a radios firmware
Once the raios firmware has een rea, the configuration settings are ispaye in three
colors. Black not settable or read-only Green Default value Blue User-specified To
modify any of the user-settable parameters, click on the associated command and type in
the new value for that parameter. For ease of understanding a specific command, once the
command is selected, a quick description along with its limits is provided at the bottom of
the screen. Once all of the new values have been entered, the new values are ready to be
save to the raios non-volatile memory.
Embedded Based Smart Antenna Orientation System

Department of ECE 61 H.K.B.K.C.E




Writing firmware to the Radio
To write the parameter changes to the raios non-volatile memory, click on the Write
button located in the Modem Parameters and Firmware section.

Embedded Based Smart Antenna Orientation System

Department of ECE 62 H.K.B.K.C.E


Downloading Updated Firmware Files
Another function of the Modem Configuration tab is allowing the user to download
updated firmware files from either the web or install them from a disk or CD. This is
accomplished by following the steps below:
1: ick on the ownoa New Versions option uner the Version section
2a: Click on Web for downloading new firmware files from the web
2b: Click on the File when installing compressed firmware files from a CD or
saved file
2bi: Browse to the location the file is saved at and click on Open
3: Click on OK and Done when prompted.







Embedded Based Smart Antenna Orientation System

Department of ECE 63 H.K.B.K.C.E


Modem Profiles
The X-CTU has the ability to save and write saved modem profiles or configuration to the
radio. This function is useful in a production environment when the same parameters need
to be set on multiple radios. How to save a profile:
1: Set the desired settings within the raios firmware as escrie in the Making
changes to the radios firmware section
2: Click Save in the Profile section
3: Type in the desired name of this profile in the File Name box
4: Browse to the location where you wish to save your profile
5: Click Save



How to load a saved file
1. Click on load from the profile section
2. Browse to the location to the file and click on the desired file
3. Click open

Embedded Based Smart Antenna Orientation System

Department of ECE 64 H.K.B.K.C.E




To save the loaded profile to the radio once you have loaded the file, follow the steps
outlined in the Writing firmware to the radio section above.
Remote Modem Management
XBee 802.15.4 modules with firmware version 1xCx and above, XBee ZNet 2.5 modules,
and XBee ZB modules offer the ability to be configured with over the air commands. With
the addition of this new feature, the user is able to configure remote radio parameters with
X-CTU or API packets. To use the remote configuration tool, the following is required:
The radio connected to the PC must be in API mode
The remote radio must be associated or within range of the base radio

To access remote radios through X-TUs Moem onfiguration ta, perform the steps
below:
Enable API on the PC Settings tab
Verify the COM port selection and settings
On the Modem Configuration tab, select the Remote Configuration option on the
top left corner of the program

Embedded Based Smart Antenna Orientation System

Department of ECE 65 H.K.B.K.C.E






Embedded Based Smart Antenna Orientation System

Department of ECE 66 H.K.B.K.C.E


Select Open Com port
Select Discover
Select the desired modem from the discovered node list
On the Modem configuration tab, select Read

The remote raios configuration is now ispaye on the Moem onfiguration ta t
this point, the same options exist with respect to Read and Write parameter changes.
Pease note that the aiity to change firmware versions is sti imite to the raios
UART. To clear the discovered node list, click on Node List and Clear. The Node List
option provides several additional options, including:
Ability to print the discovered list
Ability to remove a specific node from a list
Ability to add additional nodes that have not been discovered
Save the Node List
Load a saved Node List
Select/filter All, Routers, or End nodes.

3.3 PICKit 3
3.3.1 PICkit 3 Features
USB (Full speed 12 Mbits/s interface to host PC)
Real-time execution
MPLAB IDE compatible (free copy included)
Built-in over-voltage/short circuit monitor
Firmware upgradeable from PC/web download
Totally enclosed
Supports low voltage to 2.0 volts (2.0v to 6.0v range)
Diagnostic LEDs (power, busy, error)
Read/write program and data memory of microcontroller
Erase of program memory space with verification
Freeze-peripherals at breakpoint
Embedded Based Smart Antenna Orientation System

Department of ECE 67 H.K.B.K.C.E


Program up to 512K byte flash with the Programmer-to-Go


Fig 3.16 PICKit 3













Embedded Based Smart Antenna Orientation System

Department of ECE 68 H.K.B.K.C.E


Chapter 4
ADVANTAGES AND DISADVANTAGES
4.1 Advantages
Fully Automatic, Intelligent unit, no need of manual adjustments
Highly Efficient, Easy to implement.
The size of the antenna used here is small compared to the antenna arrays.
Highly secure - Because the signals from smart antennas are specifically focused
rather than transmitting in a random way, they offer more security for the user.
Anyone wanting to intercept a communication would need to be in the exact
location as the antenna and the communication device it was connected to.

4.2 Disadvantages
Power supply is required for embedded system and stepper motor for continuous
monitoring of power level. But this can be overcome by using solar energy.
The system needs to be aligned before use to adapt to different environments.
The output depends on the environment in which area it is implemented
( reflections)

4.3 Applications
Military Application- Light weight video displays with inbuilt smart antenna are
used to exchange real time maps and pictures
Satellite Communication- Base stations are employed with smart antenna
Mobile communication
Wireless sensor network-Increased gain preserves connectivity
Terrestrial television reception





Embedded Based Smart Antenna Orientation System

Department of ECE 69 H.K.B.K.C.E


Chapter 5
CONCLUSION AND FUTURE SCOPE
Smart Antenna Orientation is very useful Based on the direction of signal arrival.
We can use more than one antenna to create an antenna pattern which takes in to account
Signal of Interest (SOI) and Signal not of Interest (SNOI)
And also using Monopulse techniques in the above setup the accuracy of angle
measurement can be improved. There is scope of improving the accuracy of determining
where the maximum signal occurs.
In the above setup the side lobe of the antenna should be low which means gain of
the antenna should be high. Higher the gain better the performance of the setup.

Das könnte Ihnen auch gefallen