Program 1
‘Dios NEMA Proccessor
func main()
clear
hsersetup baud,HBAUD4800,start,txon,clear
and populates the global variables
shown in Table 2 when the appropriate command is received.
When a command is received, the
variable NEMAcmd will be set to 1, 2,
or 3, depending on the command
received as shown next.
print “Mode Lat Long Alt Speed Dir”
print “—— ——- ——— ——- ——- ——-”
loop:
procNEMA()
printNEMA(9)
if NEMAcmd = 3 then ‘GGA
if NEMAfix > 0 then
print NEMAfix,”:”,NEMAsats,” “,{-6.0} NEMAlatmin,” “,NEMAlongmin;
print “ “,{6.1} NEMAaltitude,” “,{4.1} NEMAspeed,” “,NEMAdir
else
print “No Fix “,NEMAfix,”:”,NEMAsats
endif
endif
• 0: No command received
• 1: Non RMC or GGA command
received
• 2: RMC command received
• 3: GGA command received
goto loop
endfunc
include \lib\DiosNEMA.lib
Wire the module according to
the previous section and program the
appropriate program into the DiosPro
using the Dios compiler. Once the GPS
module locks on to three
satellites, the program
will start to display the
positional data shown in
Figure 13.
FIGURE 13
DiosNEMA
Library
The Dios Compiler has
a NEMA library built in
called DiosNEMA. This
library processes both the
GGA and RMC commands
FIGURE 14
In most cases, I don’t do any
processing unless the NEMAcmd is set
to a value of 3 (GGA). Once I have a
valid NEMA command, I then check
the NEMAfix variable to see if the
module has a valid fix on at least three
satellites. If it does not, then all the
remaining variables are invalid.
There are a few other considerations you need to keep in mind
when using the library. First, you
must set up the UART using the
hsersetup command shown in
Program 1. In the case of the
EM-406, we have set the baud rate
to 4800. The UART handler built
into the DiosPro is interrupt driven
so data is automatically placed into
a 256 byte buffer for you. It is
important that you call the
procNEMA() frequently, enough to
keep this buffer from filling up.
The Dios NEMA library also has a
command called printNEMA. This
command will allow you to send the
current NEMA text to the debug
window. You pass a single argument
to the function with
the following results:
FIGURE 15
• 0: Display current
value for NEMA text
string
• 1: Display all
processed NEMA
commands
• 2: Display RMC and
GGA NEMA
commands only
• 3: Display GGA
NEMA command only
46 SERVO 01.2008