Академический Документы
Профессиональный Документы
Культура Документы
INTRODUCTION
1
INTRODUCTION
___________________________________________________________
1.1 HISTORY
Trying to figure out where you are is probably one of humankind's oldest
problems. Navigation and positioning are crucial to so many activities and yet the
process has always been quite cumbersome and inexact. In the earliest days mankind
used the stars to navigate. Early instruments also sited the stars to determine position.
The science of horology began in part because navigation depended on precise timing
the movement of the stars.
Over the years all kinds of technologies have tried to simplify the task but every
one has had some disadvantage. Finally, the U.S. Department of Defense decided that
the military had to have a precise form of worldwide positioning. Fortunately they had
the deep pockets it took to build something really good.
2
The result is the Global Positioning System, a system that's changed navigation
forever.The Global Positioning System (GPS) is a worldwide radio-navigation system
formed from a constellation of 24 satellites and their ground stations.GPS uses these
"man-made stars" as reference points to calculate positions accurate to a matter of
meters.
In fact, with advanced forms of GPS you can make measurements to better than
a centimeter!In a sense it's like giving every square meter on the planet a unique
address. GPS receivers have been miniaturized to just a few integrated circuits and so
are becoming very economical. And that makes the technology accessible to virtually
everyone.These days GPS is finding its way into cars, boats, planes, construction
equipment, movie making gear, farm machinery, even laptop computers
GPS allows users to determine their location on land, sea, and in the air around
the Earth. It does this using satellites and receivers. There are currently 24 satellites in
orbit operated by the US Department of Defense that provide worldwide coverage 24
hours a day, 7 days a week, in all weather. These satellites are equipped with atomic
clocks and send out radio signals as to the exact time and their location. These radio
signals from the satellites are picked up by the GPS receiver. Once the GPS receiver
locks on to four or more of these satellites
GPS helps you determine exactly where you are, but sometimes important to
know how to get somewhere else. GPS was originally designed to provide navigation
information for ships and planes. So it's no surprise that while this technology is
appropriate for navigating on water, it's also very useful in the air and on the land.
3
GPS VEHICLE NAVIGATING SYSTEM
With today’s global position system (GPS) receivers, we are able to pinpoint
our own position. But, what’s more useful about GPS receivers is that they can transmit
our position information to other receivers. We decided to use both of these features to
create a wireless vehicle navigation system.
1.2 DESCRIPTION
MICRO CONTROLLER
4
GSM MODEM
GSM (Global System for Mobile communication) Mobile service provides the
user to receive a call, to call for the people at remote end, send SMS to remote areas
just by using GSM-SMS commands and Embedded systems. This device can be used to
receive a call and to call as many people as possible. GSM Mobile Interface can call to
remote areas and can receive a call from remote areas. GSM users can send and receive
data, at rates up to 9600 bps.
GPS RECEIVER
The Global Positioning System, usually called GPS, is the only fully-functional
satellite navigation system. A constellation of more than two dozen GPS satellites
broadcasts precise timing signals by radio, allowing any GPS receiver (abbreviated to
GPSr) to accurately determine its location (longitude, latitude and altitude) in any
weather, day or night, anywhere on Earth.
GPS receivers collect signals from satellites in view. They display the user's
position, velocity, and time, as needed for their marine, terrestrial, or aeronautical
applications. Some display additional data, such as distance and bearing to selected
waypoints or digital charts.
5
Calculating positions
GPS allows receivers to accurately calculate their distance from the GPS
satellites. The receivers do this by measuring the time delay between when the satellite
sent the signal and the local time when the signal was received. This delay, multiplied
by the speed of light, gives the distance to that satellite. The receiver also calculates the
position of the satellite based on information periodically sent in the same signal. By
comparing the two, position and range, the receiver can discover its own location.
6
1.3 BLOCK DIAGRAM
7
CHAPTER 2
DESCRIPTION OF
MICROCONTROLLER
8
DESCRIPTION OF MICROCONTROLLER
_________________________________________________________________
9
Fig 2.1 Block Diagram of Micro controller
10
2.2. FEATURES
Speed up to 30 MHz
Watchdog Timer
• -Idle mode
11
• Programming support available from many popular vendors.
10: Reset Signal; The device is reset whenever a logic “0“ is applied to RST for at
least 10 microseconds, placing a low level on the pin re-initializes the on-chip logic.
Reset must be asserted when power is initially applied to the XA and held until the
oscillator is running. The duration of reset must be extended when power is initially
12
applied or when using reset to exit power down mode. This is due to the need to allow
the oscillator time to start up and stabilize. For most power supply ramp up conditions,
this time is 10 milliseconds.
2–9: Port 1; Port 1 is an 8-bit I/O port with a user-configurable output type.
13
Pin 6: RXD1 – Receiver input for serial port 1
11,13-19: Port 3 as with Port 1, each of these pins can be used as universal input
or output. However, each pin of Port 3 has an alternative function.
Pin 18: WRL - signal for writing to external (add-on) RAM memory
20-21: X2 and X1; Input and output of internal oscillator. Quartz crystal
controlling the frequency commonly connects to these pins. Capacitances
within the oscillator mechanism (see the image) are not critical and are
normally about 22pF. Instead of a quartz crystal, miniature ceramic resonators
can be used for dictating the pace. In that case, manufacturers recommend using
somewhat higher capacitances (about 47 puffs). New Mucus works at
14
frequencies from 0Hz to 50MHz+.
36- 43: Port 0 if external memory is not present, pins of Port 2 act as universal
input/output. If external memory is present, this is the location of the higher
address byte, i.e. addresses A8 – A15. It is important to note that in cases when
not all the 8 bits are used for addressing the memory (i.e. memory is smaller
than 64kB), the rest of the unused bits are not available as input/output.
32: PSEN; MCU activates this bit (brings to low state) upon each reading of
byte (instruction) from program memory. If external ROM is used for storing
the program, PSEN is directly connected to its control pins.
15
Of the external memory, MCU sends the lower byte of the address register
(addresses A0 – A7) to port P0 and activates the output ALE. External register
(74HCT373 or 74HCT375 circuits are common), memorizes the state of port P0
upon receiving a signal from ALE pin, and uses it as part of the address for
memory chip. During the second part of the mechanical MCU cycle, signal on
ALE is off, and port P0 is used as Data Bus. In this way, by adding only one
cheap integrated circuit, data from port can be multiplexed and the port
simultaneously used for transferring both addresses and data.
35: EA; Bringing this pin to the logical state zero (mass) designates the ports P2
and P3 for transferring addresses regardless of the presence of the internal
memory. This means that even if there is a program loaded in the MCU it will
not be executed, but the one from the external ROM will be used instead.
Conversely, bringing the pin to the high logical state causes the controller to use
both memories, first the internal, and then the external (if present).
16
2.3 TIMERS
XA-G39 TIMER/COUNTERS
The XA has two standard 16-bit enhanced Timer/Counters: Timer 0 and Timer
1. Additionally, it has a third 16-bit Up/Down timer/counter, T2. A central timing
generator in the XA core provides the time-base for all XA Timers and Counters. The
timer/event counters can perform the following functions:
– Measure time intervals and pulse duration
– Count external events
– Generate interrupt requests
– Generate PWM or timed output waveforms
All of the timer/counters (Timer 0, Timer 1 and Timer 2) can be independently
programmed to operate either as timers or event counters via the C/T bit in the TnCON
register. All timers count up unless otherwise stated. These timers may be dynamically
read during program execution.
The base clock rate of all of the timers is user programmable. This applies to
timers T0, T1, and T2 when running in timer mode (as opposed to counter mode), and
the watchdog timer. The clock driving the timers is called TCLK and is determined by
the setting of two bits (PT1, PT0) in the System Configuration Register (SCR). The
frequency of TCLK may be selected to be the oscillator input divided by 4 (Osc/4), the
oscillator input divided by 16 (Osc/16), or the oscillator input divided by 64 (Osc/64).
This gives a range of possibilities for the XA timer functions, including baud rate
generation, Timer 2 capture. Note that this single rate setting applies to all of the timers.
Control bits C/T in the special function register TMOD select the “Timer” or
“Counter” function. These two Timer/Counters have four operating modes, which are
17
selected by bit-pairs (M1, M0) in the TMOD register. Timer modes 1, 2, and 3 in XA
are kept identical to the 80C51 timer modes for code compatibility. Only the mode 0 is
replaced in the XA by a more powerful 16-bit auto-reload mode. This will give the XA
timers a much larger range when used as time bases. The recommended M1, M0
settings for the different modes are shown in Figure 6.
7 6 5 4 3 2 1 0
Timer/Counter Control
18
Table 2.2 Timer 0 and 1 Mode control register
TMOD (45Ch) – Not bit addressable
Reset Value – 00H
For timers T0 or T1 the 13-bit count mode on the 80C51 (current Mode 0) has
been replaced in the XA with a 16-bit auto-reload mode. Four additional 8-bit data
registers (two per timer: RTHn and RTLn) are created to hold the auto-reload values. In
this mode, the TH overflow will set the TF flag in the TCON register and cause both
the TL and TH counters to be loaded from the RTL and RTH registers respectively.
19
These new SFRs will also be used to hold the TL reload data in the 8-bit auto-reload
mode (Mode 2) instead of TH.The overflow rate for Timer 0 or Timer 1 in Mode 0 may
be calculated as follows:
Mode 1
Mode 1 is the 16-bit non-auto reload mode.
Mode 2
Mode 2 configures the Timer register as an 8-bit Counter (TLn) with automatic
reload. Overflow from TLn not only sets TFn, but also reloads TLn with the contents of
RTLn, which is preset by software. The reload leaves THn unchanged. Mode 2
operations is the same for Timer/Counter 0.The overflow rate for Timer 0 or Timer 1 in
Mode 2 may be calculated as follows:
Mode 3
Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1
= 0.
Timer 0 in Mode 3 establishes TL0 and TH0 as two separate counters. TL0 uses the
Timer 0 control bits C/T, GATE, TR0, and TF0 as well as pin INT0. TH0 is locked into
a timer function and takes over the use of TR1 and TF1 from Timer 1. Thus, TH0 now
controls the “Timer 1” interrupt. Mode 3 is provided for applications requiring an extra
8-bit timer. When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching
it out of and into its own Mode 3, or can still be used by the serial port as a baud rate
generator, or in fact, in any application not requiring an interrupt
20
Table 2.3 Timer control register
TCON (410h) – bit addressable
7 6 5 4 3 2 1 0
Timer/Counter Control
21
Timer T2
Timer 2 in the XA is a 16-bit Timer/Counter, which can operate as either a
timer or as an event counter. This is selected by C/T2 in the special function register
T2CON. Upon timer T2 overflow/underflow, the TF2 flag is set, which may be used to
generate an interrupt. It can be operated in one of three operating modes: auto-reload
(up or down counting), capture, or as the baud rate generator (for either or both UARTs
via SFRs T2MOD and T2CON). These modes are
Table 2.4 Timer2 control register
T2CON (418h) – bit addressable
Reset Value: 00H
7 6 5 4 3 2 1 0
Timer/Counter Control
22
The timer2 operating modes
Table 2.5 Timer2 modes
Capture Mode
In the capture mode there are two options, which are selected by bit EXEN2 in
T2CON. If EXEN2 = 0, then timer 2 is a 16-bit timer or counter, which upon
overflowing sets bit TF2, the timer 2 overflow bit. This will cause an interrupt when the
timer 2 interrupt is enabled. If EXEN2 = 1, then Timer 2 still does the above, but with
the added feature that a 1-to-0 transition at external input T2EX causes the current
value in the Timer 2 registers, TL2 and TH2, to be captured into registers RCAP2L and
RCAP2H, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON
to be set. This will cause an interrupt in the same fashion as TF2 when the Timer 2
interrupt is enabled.
23
Baud Rate Generator Mode
By setting the TCLKn and/or RCLKn in T2CON or T2MOD, the Timer 2 can
be chosen as the baud rate generator for either or both UARTs. The baud rates for
transmit and receive can be simultaneously different.
7 6 5 4 3 2 1 0
Timer/Counter Control
24
2.4 SERIAL COMMUNICATION
25
1 0 01 0 1
11001010
Sender Receiver
The data coming in at the receiving end of the data line in a serial data transfer
is all 0's and 1's; it is difficult to make sense of the data unless the sender and receiver
agree on a set of rules, a protocol, on how the data is packed, how many bits constitute
the character, and when the data begins and ends.
26
2.4.4 Data transfer rate
The rate of data transfer in serial data communication is stated in bps (bits per
second). Another widely used terminology for bps is baud rate. Baud rate is defined as
the number of signal changes per second. As far as the conductor wire is concerned.
Fig 2.7 Data Framing
0 1 0 0 0 0 0 1 Start
stop mark
Space bit
bit
d7 d0
Goes out
Goes out last
first
MAX
System Micro
232
Controller
27
RS232 Level TTL Level
28
RS232 CONNECTORS
1 13
1
14 RS232P (DB25)
1 25
RS232 STANDARDS
RS232 PINS
Pin Description
1 Protective ground
2 Transmitted data (TxD)
3 Received data (RxD)
4 Request to send (RTS)
29
5 Clear to send (CTS)
6 Data set ready (DSR)
7 Signal ground (GND)
8 Data carrier detect (DCD)
9/10 Reserved for data setting
11 Unassigned
12 Secondary data carrier
13 Secondary clear send
14 Secondary transmitted data
15 Transmit signal element timing
16 Secondary received data
17 Receive signal element timing
18 Unassigned
19 Secondary request to send
20 Data terminal ready (DTR)
21 Signal quality detector
22 Ring indicator
23 Data signal rate select
24 Transmit signal element timing
25 Unassigned
The RS 232 is not compatible with micro controllers, so a line driver converts
the RS 232's signals to TTL voltage levels.
30
Fig 2.10 Describing the Function of Max 232
The two serial ports on the XA-G39 are identical and are called serial port 0 and
serial port 1.
The moment a byte is written into S0BUF, it is framed with the start and stop
bits and transferred serially via TxD0 line. Similarly when bits r received serially via
RxD0, the XA-G39 defames it by eliminating a byte out of the received, and then
placing it in the S0BUF.
31
2.5.2S0CON (Serial control register 0)
Bit addressable.
7 6 5 4 3 2 1 0
TB 8_0 - The 9th data bit that will be transmitted in Modes 2 and 3. Set or clear by
software as desired. The TB8 bit is not double buffered.
RB 8_0 - In Modes 2 and 3, is the 9th data bit that was received. In Mode 1, if SM2=0,
RB8 is the stop bit that was received. In Mode 0, RB8 is not used.
TI_0 - transmits interrupt flag. Set by hardware at the beginning of the stop bit in
mode 1. It must be cleared by software.
RI_0 -received interrupts flag. Set by hardware halfway through the stop bit time in
mode 1.It must be cleared by software.
32
Table 2.9 Modes of S0CON
The moment a byte is written into S1BUF, it is framed with the start and stop
bits and transferred serially via TxD1 line. Similarly when bits r received serially via
RxD1, the XA-G39 defames it by eliminating a byte out of the received, and then
placing it in the S1BUF.
2.5.4 S1CON (Serial control register 1)
Bit addressable.
7 6 5 4 3 2 1 0
33
SM2_0 - Enables the multiprocessor communication feature in Modes 2 and 3. In Mode
2 or 3, if SM2 is set to 1, then RI will not be activated if the received 9th data bit (RB8)
is 0. In Mode 1, if SM2=1 then RI will not be activated if a valid stop bit was not
received. In Mode 0, SM2 should be 0.
TB 8_1-The 9th data bit that will be transmitted in Modes 2 and 3. Set or clear by
software as desired. The TB8 bit is not double buffered.
RB 8_1 - In Modes 2 and 3, is the 9th data bit that was received. In Mode 1, if SM2=0,
RB8 is the stop bit that was received. In Mode 0, RB8 is not used.
TI_1 -transmits interrupts flag. Set by hardware at the beginning of the stop bit in
mode 1. It must be cleared by software.
RI_1 -received interrupts flag. Set by hardware halfway through the stop bit time in
mode 1. It must be cleared by software.
2.6 INTERRUPTS
34
A single micro controller can serve several devices. In the interrupt method,
whenever any device needs its service, the device notifies the micro controller by
sending it an interrupt signal. Upon receiving an interrupt signal, the micro controller
interrupts whatever it is doing and serves the device. The program associated with the
interrupt is called the interrupt service routine (ISR). The advantageous of interrupts is
that the micro controller can serve many devices based on the priority assigned to it.
XA-G3 Interrupts
• Trap Interrupts – These are TRAP instructions, generally used to call system
services in a multi-tasking system.
• Event Interrupts – These are peripheral interrupts from devices such as UARTs,
timers, and external interrupt inputs.
• Software Interrupts – These are equivalent to hardware event interrupts, but are
requested only under software control and have fixed priority levels.
The XA-G3 supports 38 vectored interrupt sources. These include 9 maskable Event
Interrupts (for the various
XA-G3 peripherals), 7 Software Interrupts, 6 Exception Interrupts and 16 Traps.
35
7 6 5 4 3 2 1 0
36
EX0 enables or disables external interrupt 0.
1. External Interrupts
2. Timer Interrupts
3. Serial Port Interrupts
7 6 5 4 3 2 1 0
Timer/Counter Control
External interrupts can be either falling edge triggered or low level triggered.
The Interrupt Type Control bits IT1/IT0 control this. If IT1/IT0 is set to “1” then that
interrupt will be set for falling edge trigger. If IT1/IT0 to “0” then that interrupt will be
set for low-level trigger. When an external interrupt is detected it will set the Interrupt
Edge Flag IE1/IE0. If the external interrupt is enabled the setting of this flag will
generate an External Interrupt 1 or External Interrupt 0. The IE1/IE0 flag will be
cleared when the interrupt is processed or it can be cleared by software at any time.
37
2.6.2 Timer Interrupts
7 6 5 4 3 2 1 0
Timer/Counter Control
The timer is turned on by setting the Timer Run Control bit TR1/TR0 to “1”.
Setting the Timer Run Control bit TR1/TR0 to “0” turns off the timer. When the
timer/counter overflows it will set the Timer Overflow Flag
TF1/TF0. If the timer interrupt is enabled the setting of this flag will generate a
Timer 0 Interrupt or a Timer 1 interrupt. The TF1/TF0 flag will be cleared when the
interrupt is processed or it can be cleared by software at any time.Timer 2 on the XA-
G3 has additional functional modes over Timer 0 and 1 that will not be discussed here.
Bits in the T2CON register as shown below control timer 2 interrupts:
38
7 6 5 4 3 2 1 0
Timer/Counter Control
Timer 2 is turned on by setting the Timer Run Control bit TR2 to “1”. Setting
the Timer Run turns off timer 2 Control bit TR2 to “0”. When the timer/counter
overflows it will set the Timer 2 Overflow Flag TF2. If the timer 2 interrupt is enabled,
the setting of this flag will generate a Timer 2 Interrupt. The TF2 flag will NOT be
cleared when the interrupt is processed so it must be cleared by software or the Timer 2
interrupt will reoccur. If RCLK1/RCLK0 or TCLK1/TCLK0 are set to “1”, then the
Timer 2 overflow rate is being used as a baud rate clock source for UART0 or UART1.
In this case the TF2 flag will NOT be set when the timer/counter overflows. If Timer 2
is enabled in external capture or reload mode, a negative transition on the T2EX pin
will set the Timer 2 external flag EXF2. If the Timer 2 interrupt is enabled, the setting
of the Timer 2 external flag EXF2 can also generate a Timer 2 Interrupt. The EXF2
flag will NOT be cleared when the interrupt is processed so it must be cleared by
software or the Timer 2 interrupt will reoccur.
The two Serial Ports on the XA-G3 are identical and are called Serial Port 0 and
Serial Port 1. Each Serial Port has two interrupts – one for the transmitter and one for
39
the receiver. Notice that this is an enhancement over the Serial Port on the 8051 (which
had only a single shared interrupt for both the transmitter and receiver). This gives the
XA-G3 a total of four interrupts for the Serial Ports:
1. Serial Port 0 Rx
2. Serial Port 0 Tx
3. Serial Port 1 Rx
4. Serial Port 1 Tx
Bits in identical registers called S0CON and S1CON control this Serial Port interrupts.
To avoid confusion we will look only at S0CON as shown below:
7 6 5 4 3 2 1 0
40
are enabled and any one of them can also generate a Serial Port 0 Rx Interrupt by
setting the RI_0 flag. These extended status flags include raming Error, Overrun Error
and Break Detect. Please refer to the XA-G3 data sheet for more details on these flags.
The RI_0 flag will NOT be cleared when the interrupt is processed so it must be
cleared by software or the Serial Port 0 Rx interrupt will reoccur. As mentioned earlier
the function of the Serial Port 1 Interrupts is identical to the Serial Port 0 Interrupts and
therefore will not be covered here.
41
CHAPTER 3
GSM MODEM
GSM MODEM
42
3.1 INTRODUCTION
Ana logic’s GSM Smart Modem is a multi-functional, ready to use, rugged
and versatile modem that can be embedded or plugged into any application. The Smart
Modem can be customized to various applications by using the standard AT commands.
The modem is fully type-approved and can directly be integrated into your projects
with any or all the features of Voice, Data, Fax, SMS, and Internet etc.
• User manual
The connectors integrated to the body, guarantee the reliable output and input
connections. An extractible holder is used to insert the SIM card (Micro-SIM type).
Status LED indicates the operating mode.
43
Table 3.1 Physical characteristics
To install the modem, plug the device on to the supplied SMPS Adapter. For
Automotive applications fix the modem permanently using the mounting slots (optional
44
as per your requirement dimensions).
To insert or Remove the SIM Card, it is necessary to press the SIM holder
ejector button with Sharp edged object like a pen or a needle. With this, the SIM holder
comes out a little, then pulls it out and insert or remove the SIM Card.
Make sure that the ejector is pushed out completely before accessing the SIM
Card holder do not remove the SIM card holder by force or tamper it (it may
permanently damage). Place the SIM Card Properly as per the direction of the
installation. It is very important that the SIM is placed in the right direction for its
proper working condition.
Connect GSM Smart Modem to the external antenna with cable end with
45
SMA male. The Frequency of the antenna may be GSM 900/1800 MHz. The
antenna may be (0dBi, 3dBi or short length L-type antenna) as per the field
conditions and signal conditions.
RS232 can be used to connect to the external device through the D-SUB/ USB
(for USB model only) device that is provided in the modem.
46
3.2.7. Connectors
Connector Function
SMA RF Antenna connector
15 pin or 9 pin D-SUB RS232 link
Audio link (only for 15 D-SUB)
Reset (only for 15 D-SUB)
USB (optional) USB communication port (optional)
2 pin Phoenix tm Power Supply Connector
47
- Power Supply (Via 2 pin Phoenix tm contact)
- SIM card holder
48
PIN NAME Designation Type
1 X None NC NC
9 X None NC NC
AT COMMANDS
3.6 GSM SHORT MESSAGES AT COMMANDS
49
3.6.1. AT commands features
Line settings
A serial link handler is set with the following default values (factory settings):
Auto baud, 8 bits data, 1 stop bit, no parity, flow control.
Command line
Commands always start with AT (which means attention) and finish with a <CR>
character.
Information responses and result codes
Responses start and end with <CR><LF>,.
1 If command syntax is incorrect, an ERROR string is returned.
2 If command syntax is correct but with some incorrect parameters, the +CME
ERROR: <Err> or +CMS ERROR: <SmsErr> strings are returned with different
error codes.
3 If the command line has been performed successfully, an OK string is returned.
4 In some cases, such as “AT+CPIN?” or (unsolicited) incoming events, the
product does not return the OK string as a response.
Description
The <address> field is the address of the terminal to which the message is sent.
To send the message, simply type, <ctrl-Z> character (ASCII 26). The text can contain
all existing characters except <ctrl-Z> and <ESC> (ASCII 27). This command can be
aborted using the <ESC> character when entering text. In PDU mode, only
hexadecimal characters are used (‘0’…’9’,’A’…’F’).
Syntax
50
AT+CMGS= <da> [ ,<toda> ] <CR>
text is entered <ctrl-Z / ESC >
Command syntax in PDU mode:
AT+CMGS= <length> <CR>
PDU is entered <ctrl-Z / ESC >
Table 3.5 Illustration of Commands For Sending Message And Their Response
The message reference, <mr>, which is returned to the application, is allocated by the
product. This number begins with 0 and is incremented by one for each outgoing
message (successful and failure cases); it is cyclic on one byte (0 follows 255).
Note: This number is not a storage number - outgoing messages are not stored.
51
CHAPTER 4
GPS RECEIVER
52
GPS RECEIVER
GPS satellites circle the earth twice a day in a very precise orbit and transmit
signal information to earth. GPS receivers take this information and use triangulation to
calculate the user's exact location. Essentially, the GPS receiver compares the time a
signal was transmitted by a satellite with the time it was received. The time difference
tells the GPS receiver how far away the satellite is. Now, with distance measurements
53
from a few more satellites, the receiver can determine the user's position and display it
on the unit's electronic map.
ACCURACY:
The accuracy of the receivers is dependent on the number and quality of the signals it is
getting from the satellites and from a factor called Selected Availability. Department
of Defense deliberately interfering with the satellite signals to reduce positional
accuracy to around 30m - 100m. With Selective Availability receivers are divided into
two types:
PPS is encrypted and only available for authorized (military) users, and are not affected
by Selective Availability. SPS has been made available to the general public.The GPS
uses satellites and computers to compute positions anywhere on earth. The GPS is
based on satellite ranging. That means the position on the earth is determined by
measuring the distance from a group of satellites in space.
The Space vehicles (SVs) transmit two microwave carrier signals. The L1 frequency
(1575.42 MHz) carries the navigation message and the SPS code signals. The L2
frequency (1227.60 MHz) is used to measure the ionospheric delay by PPS equipped
receivers
54
4.2 GPS SEGMENTS
The current GPS consists of three major segments. These are the
55
Fig 4.2 Simplified Representation Of Nominal GPS Constellation
The flight paths of the satellites are tracked by monitoring stations .The tracking
information is sent to the Air Force Space Command's master control station. each GPS
satellite regularly with a navigational update (using the ground antennas. These updates
synchronize the atomic clocks on board the satellites to within one microsecond and
adjust the ephemeris of each satellite's internal orbital model. The updates are created
by a Kalman Filter which uses inputs from the ground monitoring stations, space
weatrher information, and other various
56
Fig 4.3 GPS Control
The user's GPS receiver is the user segment of the GPS system. In general, GPS
receivers are composed of an antenna, tuned to the frequencies transmitted by the
satellites, receiver-processors, and a highly-stable clock (often a crystal oscillator).
They may also include a display for providing location and speed information to the
user. A receiver is often described by its number of channels: this signifies how many
satellites it can monitor simultaneously
57
Many GPS receivers can relay position data to a PC or other device using the
NMEA 0183 protocol. means by which marine instruments and also most GPS
receivers can communicate with each other. NMEA 2000 is a newer and less widely
adopted protocol. Both are proprietary and controlled by the US-based National Marine
Electronics Association.(NMEA)
GPS satellites broadcast three different types of data in the primary navigation signal.
The first one is almanac and second one is empheric.
58
GPS works in six logical steps:
Triangulation
Suppose we measure our distance from a satellite and find it to be 10,000 miles.
Knowing that we're 10,000 miles from a particular satellite narrows down all the
possible locations we could be in the whole universe to the surface of a sphere that is
centered on this satellite and has a radius of 10,000 miles
Next, say we measure our distance to a second satellite and find out that it's 11,000
miles away. That tells us that we're not only on the first sphere but we're also on a
sphere that's 11,000 miles from the second satellite. Or in other words, we're
somewhere on the circle where these two spheres intersect.
59
If we then make a measurement from a third satellite and find that we're 12,000
miles from that one, that narrows our position down even further, to the two points
where the 12,000 mile sphere cuts through the circle that's the intersection of the first
two spheres.
So by ranging from three satellites we can narrow our position to just two points in
space. This arrangement of satellites is also called a "constellation".
To decide which one is our true location we could make a fourth measurement
Measuring Distance
60
4. Multiply that travel time by the speed of light and you've got distance.
The timing problem is tricky. First, the times are going to be awfully short. If a
satellite were right overhead the travel time would be something like 0.06 seconds.
The signal coming from the satellite would be a little delayed because it had to travel
more than 11,000 miles.
If we wanted to see just how delayed the satellite's signal was, we could start delaying
the receiver's signal until they fell into perfect synchronus.
The amount we have to shift back the receiver's version is equal to the travel time of the
satellite's version. So we just multiply that time times the speed of light and voila!
we've got our distance to the satellite.
That’s Basically GPS Works.
Random Code:
The Pseudo Random Code (PRC) is a fundamental part of GPS. Physically it's
just a very complicated digital code, or in other words, a complicated sequence of "on"
61
and "off" pulses.The signal is so complicated that it almost looks like random electrical
noise. Hence the name "Pseudo-Random".
There are several good reasons for that complexity: First, the complex pattern helps
make sure that the receiver doesn't accidentally sync up to some other signal. The
patterns are so complex that it's highly unlikely that a stray signal will have exactly the
sameshape.
Since each satellite has its own unique Pseudo-Random Code this complexity also
guarantees that the receiver won't accidentally pick up another satellite's signal. So all
the satellites can use the same frequency without jamming each other. And it makes it
more difficult for a hostile force to jam the system. In fact the Pseudo Random Code
gives the Department of Defense a way to control access to the system.
But there's another reason for the complexity of the Pseudo Random Code, a reason
that's crucial to making GPS economical. The codes make it possible to use
"information theory" to "amplify" the GPS signal. And that's why GPS receivers don't
need big satellite dishes to receive the GPS signals.
Timing:
62
3. Receiver clocks don't have to be too accurate because an extra satellite range
measurement can remove errors.
On the satellite side, timing is almost perfect because they have incredibly
precise atomic clocks on board. Remember that both the satellite and the receiver
need to be able to precisely synchronushronize their pseudo-random codes to make
the system work. If our receivers needed atomic clocks (which cost upwards of
$50K to $100K) GPS would be a lame duck technology. Nobody could afford it.
To overcome this problem there one method is used that is one of the key
elements of GPS and as an added side benefit it means that every GPS receiver is
essentially an atomic-accuracy clock.
The secret to perfect timing is to make an extra satellite measurement. That's right,
if three perfect measurements can locate a point in 3-dimensional space, then four
imperfect measurements can do the same thing.
Extra Measurement Cures Timing Offset If receiver's clocks were perfect, then
all satellite ranges would intersect at a single point (which is our position). But with
imperfect clocks, a fourth measurement, done as a cross-check, will NOT intersect
with the first three.
The receiver looks for a single correction factor that it can subtract from all its
timing measurements that would cause them all to intersect at a single point. That
correction brings the receiver's clock back into synchronus with universal time.
Once it has that correction it applies to all the rest of its measurements and now
receiver got precise positioning.
One consequence of this principle is that any decent GPS receiver will need to
have at least four channels so that it can make the four measurements
simultaneously. with the pseudo-random code as a rock solid timing synchronus
pulse, and this extra measurement trick to get us perfectly synchronused to
universal time, we have got everything we need to measure our distance to a
63
satellite in space. But for the triangulation to work we not only need to know
distance, we also need to know exactly where the satellites are.
Satellite Tracking:
That 11,000 mile altitude is actually a benefit in this case, because something that high
is well clear of the atmosphere. And that means it will orbit according to very simple
mathematics.
On the ground all GPS receivers have an almanac programmed into their computers
that tells them where in the sky each satellite is, moment by moment.
64
The basic orbits are quite exact but just to make things perfect the GPS satellites are
constantly monitored by the Department of Defense.
They use very precise radar to check each satellite's exact altitude, position and speed.
The errors they're checking for are called "ephemeris errors" because they affect the
satellite's orbit or "ephemeris." These errors are caused by gravitational pulls from the
moon and sun and by the pressure of solar radiation on the satellites.
The errors are usually very slight but if you want great accuracy they must be taken into
account.
Once the Department of Defense has measured a satellite's exact position, they relay
that information back up to the satellite itself. The satellite then includes this new
corrected position information in the timing signals it's broadcasting.
So a GPS signal is more than just pseudo-random code for timing purposes. It also
contains a navigation message with ephemeris information as well.
1. The earth's ionosphere and atmosphere cause delays in the GPS signal that
translate into position errors.
2. Some errors can be factored out using mathematics and modeling.
3. The configuration of the satellites in the sky can magnify other errors.
4. Differential GPS can eliminate almost all error.
65
calculate distance to a satellite by multiplying a signal's travel time by the speed of
light. But the speed of light is only constant in a vacuum.
As a GPS signal passes through the charged particles of the ionosphere and
then through the water vapor in the troposphere it gets slowed down a bit, and this
creates the same kind of error as bad clocks.
Ionosphere
The ionosphere is the layer of the atmosphere ranging in altitude from 50 to 500
km.It consists largely of ionized particles which can exert a perturbing effect on GPS
signals.While much of the error induced by the ionosphere can be removed through
mathematical modeling, it is still one of the most significant error sources.
Troposphere
The troposphere is the lower part of the earth's atmosphere that encompasses
our weather.It's full of water vapor and varies in temperature and pressure.But as messy
as it is, it causes relatively little error.There are a couple of ways to minimize this kind
66
of error. For one thing we can predict what a typical delay might be on a typical day.
This is called modeling and it helps but, of course, atmospheric conditions are rarely
exactlytypical. Another way to get a handle on these atmosphere-induced errors is to
compare the relative speeds of two different signals. This "dual frequency"
measurement is very sophisticated and is only possible with advanced receivers.
Trouble for the GPS signal doesn't end when it gets down to the ground. The signal
may bounce off various local obstructions before it gets to our receiver.
This is called multi-path error and is similar to the ghosting you might see on a TV.
Good receivers use sophisticated signal rejection techniques to minimize thisproblem.
Trouble for the GPS signal doesn't end when it gets down to the ground. The signal
may bounce off various local obstructions before it gets to our receiver.
This is called multi-path error and is similar to the ghosting you might see on a TV.
Good receivers use sophisticated signal rejection techniques to minimize this problem.
Basic GPS is the most accurate radio-based navigation system ever developed. And for
many applications it's plenty accurate.
So some crafty engineers came up with "Differential GPS," a way to correct the various
inaccuracies in the GPS system, pushing its accuracy even farther. Differential GPS or
"DGPS" can yield measurements good to a couple of meters in moving applications and
even better in stationary situations.
That improved accuracy has a profound effect on the importance of GPS as a resource.
With it, GPS becomes more than just a system for navigating boats and planes around
the world. It becomes a universal measurement system capable of positioning things on
a very precise scale.
Differential GPS involves the cooperation of two receivers, one that's stationary and
another that's roving around making position measurements. The stationary receiver is
the key. It ties all the satellite measurements into a solid local reference.
67
So if two receivers are fairly close to each other, say within a few hundred kilometers,
the signals that reach both of them will have traveled through virtually the same slice of
atmosphere, and so will have virtually the same errors.
That's the idea behind differential GPS: We have one receiver measure the
timing errors and then provide correction information to the other receivers that are
roving around. That way virtually all errors can be eliminated from the system.Put the
reference receiver on a point that's been very accurately surveyed and keep it there.
This reference station receives the same GPS signals as the roving receiver but instead
of working like a normal GPS receiver it attacks the equations backwards.
Instead of using timing signals to calculate its position, it uses its known
position to calculate timing. It figures out what the travel time of the GPS signals
should be, and compares it with what they actually are. The difference is an "error
correction" factor. The receiver then transmits this error information to the roving
receiver so it can use it to correct its measurements.
Since the reference receiver has no way of knowing which of the many
available satellites a roving receiver might be using to calculate its position, the
reference receiver quickly runs through all the visible satellites and computes each of
their errors. Then it encodes this information into a standard format and transmits it to
the roving receivers.
68
The roving receivers get the complete list of errors and apply the corrections for
the particular satellites they're using.
CHAPTER 5
LIQUID CRYSTAL
DISPLAY
69
LIQUID CRYSTAL DISPLAY
As in recent years the LCD is finding widespread use replacing LED thesis due to the
following reasons:
70
The declining prices of LCD
Incorporation refreshing controller into the LCD, there by the easy relieving the
CPU of the task of refreshing the LCD. In contrast, the CPU, to keep the data
displaying, must refresh the LED.
5.2 FEATURES:
On-chip:
Generation
of LCD supply voltage (external supply also possible)
Generation
of intermediate LCD bias voltages
71
Oscillator
requires no external components (external clock also possible).
Mux rate: 48
72
Figure 5.1 Block Diagram of Graphical LCD
5.4.1 Oscillator
The on-chip oscillator provides the clock signal for the display system. No external
components are required and the OSC input must be connected to VDD. An external
clock signal, if used, is connected to this input.
73
5.4.2 Address Counter (AC)
The address counter assigns addresses to the display data RAM for writing. The X-
address X6 to X0 and the Y-address Y2 to Y0 are set separately. After a write
operation, the address counter is automatically incremented by 1, according to the V
flag.
74
Fig 5.2 Serial bus protocol – transmission of one byte
75
Fig 5.4 Chip Selection function
SYMBOL DESCRIPTION
R0 to R47 LCD ROW DRIVER OUTPUTS
C0 to C83 LCD COLUMN DRIVER OUTPUTS
76
VSS1,VSS2 GROUND
VDD1,VDD2 SUPPLY VOLTAGE
VLCD1,VLCD2 LCD SUPPLY VOLTAGE
T1 TEST 1 INPUT
T2 TEST2 OUTPUT
T3 TEST3 INPUT/OUTPUT
T4 TEST4 INPUT
SDIN SERIAL DATA INPUT
SCLK SERIAL CLOCK INPUT
D/C DATA/COMMAND
SCE CHIP ENABLE
OSC OSCILLATOR
RES EXTERNAL RESET INPUT
DUMMY1, 2,3,4 NOT CONNECTED
77
5.3.8 SCLK: SERIAL CLOCK LINE
Input for the clock signal: 0.0 to 4.0 Mbits/s.
5.3.9 D/C: MODE SELECT
Input to select either command/address or data input.
5.3.10 SCE: CHIP ENABLE
The enable pin allows data to be clocked in. The signal is
active LOW.
78
Figure 5.6 Application Diagram
79
Figure 5.6 Application Diagram
5.6 ADDRESSING
Data is downloaded in bytes into the 48 by 84 bits RAM data display matrix of
PCD8544, as indicated in Figs. 7.6, 7.7, 7.8 and 6. The address pointer addresses the
columns. The address ranges are: X 0 to 83 (1010011), Y 0 to 5 (101). Addresses
outside these ranges are not allowed. In the vertical addressing mode (V = 1), the Y
address increments after each byte (see Fig.5). After the last Y address (Y = 5), Y
wraps around to 0 and X increments to address the next column. In the horizontal
addressing mode (V = 0), the X address increments after each byte (see Fig.7..). After
80
the last X address (X = 83), X wraps around to 0 and Y increments to address the next
row. After the very last address (X = 83 and Y = 5), the address pointers wrap around to
address (X = 0 and Y = 0).
DATA STRUTURE
Fig 5.9 Sequence of writing data bytes into RAM with Vertical
addressing (V=1)
81
Fig 5.10 Sequence of writing data bytes into RAM with horizontal
addressing (V=0)
82
TABLE 5.2: INSTRUCTION SET
5.7.1 Initialization
Immediately following power-on, the contents of all internal registers and of the RAM
are undefined. A RES pulse must be applied. Attention should be paid to the possibility
that the device may be damaged if not properly reset.
All internal registers are by applying an external RES pulse (external low) at pad 31,
within the specified time. However, the RAM contents are still undefined. The state
after reset is described in section below
83
The RES input must be ≤0.3VDD when VDD reaches VDDmin (or higher) within a
maximum time of 100ms after VDD goes HIGH.
5.7.2 Reset Function
After reset, the LCD driver has the following state:
● Power-down mode (bit PD=1)
● Horizontal addressing (bit V=0) normal instruction set (bit H=0)
● Display blank (bit E=D=0)
● Address counter X5 to X0 = 0; Y2 to Y0 = 0
● Temperature control mode (TC1 TC0 = 0)
● Bias system (BS2 to BS1 = 0)
5.7.3a BIT PD
● All LCD outputs at Vss (display off)
● Bias generator and VLCD generator off, VLCD can be disconnected
● Oscillator off (external clock possible)
● Serial bus, command, etc. function
● Before entering power-down mode, the RAM needs to be filled with ‘0’s to
ensure the specified current consumption.
5.7.3b BIT V
When V=0, the horizontal addressing is selected. the data is written into the
DDRAM as shown in Fig.6. When V=1, the vertical addressing is selected. The
data is written into the DDRAM,
84
5.7.3c BIT H
When H=0 the commands ‘display control’, ‘set Y address’ and ‘set X address’
can be performed’, when H=1, the others can be executed. the ‘write data’ and
‘function set’ commands can be executed in both cases.
85
programmed by BS2 to BS0. For mux 1:48, the optimum bias value n, resulting in 1/8
bias, is given by:
n = root of 48-3 = 3.928= 4
APLLICATION INFORMATION
86
• The pinning is optimized for single plane writing e.g. for chip-on-glass modules.
Display size 48by 84 pixels.
• The required minimum value for the external capacitors is: Cext = 1.0uf
• Higher capacitor values are recommended for ripple reduction.
87
CHAPTER 6
APPLICATION
88
APPLICATIONS
Basically, GPS is usable everywhere except where it's impossible to receive the signal
such as inside most buildings, in caves and other subterranean locations, and
underwater. The most common airborne applications are for navigation by general
aviation and commercial aircraft. At sea, GPS is also typically used for navigation by
recreational boaters, commercial fishermen, and professional mariners. Land-based
applications are more diverse. The scientific community uses GPS for its precision
timing capability and position information.
Surveyors use GPS for an increasing portion of their work. GPS offers cost savings by
drastically reducing setup time at the survey site and providing incredible accuracy.
Basic survey units, costing thousands of dollars, can offer accuracies down to one
meter. More expensive systems are available that can provide accuracies to within a
centimeter.
Recreationa and sports i.e. hikers, hunters, snowmobilers, mountain bikers, and cross-
country skiers, just to name a few. And some other like
89
Science :
Archaeology
Atmospheric Science
Environmental
Oceanography
Transportation:
Aviation
Marine
Space
Military:
Navigation
Industry:
Public Safety
Surveying
Telecommunications
90
CHAPTER 7
FLOW
CHART,SCHEMATICS
& PICTURES OF THE
MODEL
91
7.1 FLOW CHART FOR GPS / GSM VEHICLE NAVIGATION
Start
Initialise LCD
Display Names
No
Is it Time
Reaches 2
Min?
Yes
92
Fig 7.1 Microcontroller Schematic 1
93
Fig 7.2 Microcontroller Schematic 2
94
7.3 PICTURES OF THE MODEL
95
Fig 7.3Receiving Signal from GPS satellites
OUTPUT
96
Fig 7.4 Output of the project
97
Fig 7.5 Real view of the kit
98
CHAPTER 8
PROJECT CODE
99
#include<regxag3.sfr>
#define prescaler 4
#define bus_d8a20 0x02 // bcr value for 8-bit data, 20-bit address bus.
100
_sfrbit LCD_SDIN _at(0x386); //P0.6
char d[60];
void check(void);
_bitbyte gpsdata;
void LCD_INIT(void);
void LCD_GOTOXY(uc,uc);
void LCD_PUTS(char);
void LCD_CMND(char);
void LCD_DATA(char);
void LCD_CLEAR(void);
101
void DELAYMS(unsigned int);
void SER_CHAR(char );
void display(void);
void display1(void);
unsigned int i;
char b[40];
void GSM_INIT(void);
uc _rom LTab[96][5]=
102
{ 0x08, 0x08, 0x3E, 0x08, 0x08 }, // +
103
{ 0x7F, 0x49, 0x49, 0x49, 0x36 }, // B
104
{ 0x07, 0x08, 0x70, 0x08, 0x07 }, // Y
105
{ 0x7C, 0x14, 0x14, 0x14, 0x08 }, // p
};
void main(void)
WFEED1 = 0xA5;
WFEED2 = 0x5A;
SCR = 0; //prescalar = 4
106
BCR = waiten+busen+bus_d8a20; //8bit data & 20bit address(0x12)
BTRH = bus_slow_h;
BTRL = bus_slow_l;
/*---------------------------------------------------------------*/
TR1 = 1;
/*-------------------------------GPS-------------------------------*/
S0CON = 0X72;
ERI0 = 1;
/*-----------------------------GSM-------------------------------*/
LCD_CLEAR();
LCD_INIT();
LCD_GOTOXY(0x40,0x80);
107
LCD_STRING("VEHICLE NAVIGATION SYSTEM");
DELAYMS(500);
DELAYMS(500);
LCD_CLEAR ();
LCD_GOTOXY(0x40,0x80);
EA=1;
while(1)
if(disp==1)
EA=0;
disp=0;
DELAY1SEC(100);
LCD_CLEAR();
LCD_GOTOXY(0x40,0x80);
LCD_STRING("TIME:");
LCD_GOTOXY(0x40,0x9e); //hrs
for(k=5;k<=6;k++)
LCD_PUTS(d[k]);
LCD_GOTOXY(0x40,0xaa);
108
LCD_STRING(":");
LCD_GOTOXY(0x40,0xb0); //min
for(k=7;k<=8;k++)
LCD_PUTS(d[k]);
LCD_GOTOXY(0x40,0xbc);
LCD_STRING(":");
LCD_GOTOXY(0x40,0xc2); //sec
for(k=9;k<=10;k++)
LCD_PUTS(d[k]);
LCD_GOTOXY(0x41,0x80);
LCD_STRING("LATITUDE:");
LCD_GOTOXY(0x41,0xb6);
for(k=17;k<=27;k++)
LCD_PUTS(d[k]);
LCD_GOTOXY(0x43,0x80);
LCD_STRING("LONGITUDE:");
LCD_GOTOXY(0x43,0xbc);
109
for(k=29;k<=40;k++)
LCD_PUTS(d[k]);
LCD_GOTOXY(0x45,0x80);
LCD_STRING("SPEED:");
LCD_GOTOXY(0x45,0xA4);
for(k=42;k<=45;k++)
LCD_PUTS(d[k]);
DELAYGSM(100);
if(cnt==50)
cnt=0;
GSM_INIT();
k=0;
EA=1;
/*---------------GSM INITIALIZATION------------------------*/
110
void GSM_INIT(void)
LCD_CLEAR();
LCD_GOTOXY(0x41,0x80);
LCD_STRING("MSG SENDING..");
DELAYMS(50);
LCD_STRING(".");
DELAYMS(50);
LCD_STRING(".");
DELAYMS(50);
LCD_STRING(".");
DELAYMS(50);
LCD_STRING(".");
DELAYMS(50);
CMND_SEND("AT");
SER_CHAR(0x0D);
DELAYMS(500);
DELAYMS(500);
LCD_STRING(".");
DELAYMS(500);
DELAYMS(500);
CMND_SEND("AT+CMGS=");
111
SER_CHAR('"');
LCD_STRING(".");
CMND_SEND("+919966425597");
SER_CHAR('"');
SER_CHAR(0x0D);
CMND_SEND("TIME:");
//hrs
for(k=5;k<=6;k++)
SER_CHAR(d[k]);
SER_CHAR(0x3a); //min
for(k=7;k<=8;k++)
SER_CHAR(d[k]);
SER_CHAR(0x3a); //sec
for(k=9;k<=10;k++)
SER_CHAR(d[k]);
112
SER_CHAR(0X0D);
CMND_SEND("LONGITUDE:");
SER_CHAR(0X0D);
for(k=17;k<=27;k++)
SER_CHAR(d[k]);
SER_CHAR(0X0D);
CMND_SEND("LATITUDE:");
SER_CHAR(0X0D);
for(k=29;k<=40;k++)
SER_CHAR(d[k]);
SER_CHAR(0X0D);
CMND_SEND("SPEED(in Knots):");
SER_CHAR(0X0D);
for(k=42;k<=45;k++)
SER_CHAR(d[k]);
113
SER_CHAR(0x1A);
LCD_CLEAR();
LCD_STRING("MSG SENT");
DELAYMS(100);
while(*letter)
S0BUF = *letter;
DELAYMS(100);
letter++;
/*................................................................................*/
void SER_CHAR(char z)
S0BUF = z;
DELAYMS(138);
DELAYMS(138);
114
TI_0 = 0;
_interrupt(40) _using(0x8f00)
void rcv_gsm(void)
while(TI_0!=0)
while(RI_0!=0)
b[i]=S0BUF;
i++;
/*--------------------------------------------------------------------*/
_interrupt(42) _using(0x8f00)
115
void rcv_gps(void)
while(TI_1!=0)
TI_1=0;
while(RI_1!=0)
RI_1=0;
temp1=S1BUF;
check();
if(rmcok==1)
d[k]=temp1;
k++;
if(k==60)
rmcok=0;
disp=1;
}}
116
/*----------------------------------------------------------------------*/
void check(void)
if (temp1=='R')
d[k]=temp1;
k++;
d[k]=temp1;
k++;
if((d[0]=='R')&(d[1]=='M')& (temp1=='C'))
d[k]=temp1;
k++;
rmcok=1;
117
void LCD_INIT()
LCD_RESET = 1;
#pragma asm
nop
nop
#pragma endasm
LCD_RESET = 0;
#pragma asm
nop
nop
#pragma endasm
LCD_RESET = 1;
LCD_CMND(0x21);
LCD_CMND(0x06);
LCD_CMND(0x13);
LCD_CMND(0xC8);
LCD_CMND(0x20);
LCD_CMND(0x0C);
LCD_CMND(0x80);
LCD_CMND(0x40);
118
void LCD_STRING(char *ptr)
while(*ptr)
LCD_PUTS(*ptr);
ptr++;
/*..........................................................................................*/
unsigned int i;
POS = str-0x20;
for(i=0;i<5;i++)
LCD_DATA(LTab[POS][i]);
LCD_DATA(0x00);
119
void LCD_CMND(char temp)
unsigned char i;
LCD_SCLK = 0;
LCD_SCE = 0;
LCD_D_C = 0;
for(i=0;i<8;i++)
LCD_SDIN = temp&0x80?1:0;
temp=temp << 1;
LCD_SCLK = 1;
#pragma asm
nop
nop
#pragma endasm
LCD_SCLK = 0;
120
void LCD_DATA(char temp)
unsigned char i;
LCD_SCLK = 0;
LCD_SCE = 0;
LCD_D_C = 1;
// P3=temp;
for(i=0;i<8;i++)
LCD_SDIN = temp&0x80?1:0;
temp=temp << 1;
LCD_SCLK = 1;
#pragma asm
nop
nop
#pragma endasm
LCD_SCLK = 0;
121
void LCD_GOTOXY(uc x,uc y)
LCD_CMND(x);
LCD_CMND(y);
void LCD_CLEAR(void)
int i=0;
for(i=0;i<=0x1f8;i++)
LCD_DATA(0x00);
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
122
void DELAYMS(unsigned int itime)
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
cnt++;
123