circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

August 2004, Issue 169

Ham Radio Repeater Locator


by Glen Worstell

GPS DATA

Most small GPS receivers have an output in NMEA-0183 format, which is an asynchronous serial datastream of ASCII characters sent at 4,800 bps (start bit, 8 data bits, 1 stop bit). The signal is nominally 0 V for a mark condition and 5 V for a space condition. Connecting a terminal or terminal emulator can monitor the GPS output. Most computers with an RS-232 input will work correctly even though these levels are not RS-232 standard.

I used a Garmin GPSMAP 295 for this project, but almost any GPS receiver should work. It may be necessary to look at the output format of your receiver and modify the parsing routines for different formats. The routine to parse the GPS’s latitude and longitude output was written for easy modification. 

CIRCUIT SPECIFICS

The system is intended for mobile use, so power comes from your vehicle’s 12-V battery. A 5-V regulator supplies the LCD module, and a 3.3-V regulator (driven by the output of the 5-V regulator) is used to drive the Zilog microcomputer. Because the microcomputer outputs are 5-V tolerant, they can be used to drive the display directly.

A 10-MHz crystal supplies the system clock. The crystal frequency is not important, but if a different crystal is used, the UART clock division must be changed accordingly.

A single transistor interfaces the GPS NMEA-0183 output, which varies between 0 and 5 V, to the 3.3-V UART input of the microcontroller. The transistor also provides the necessary phase inversion.

A normally open switch is used to signal the microcontroller to select the next station for frequency and tone display. Another switch is used to toggle the sticky bit for the selected station.

As an aid to debugging, and to let you know that all is well, a red LED is connected to one of the microcontroller’s I/O lines. It is often useful to have such an indicator during the initial stages of hardware and software development. As I said earlier, the LED blinks once per second.

An interface circuit is provided so the HRRL can automatically program your ham radio transceiver. The one shown in Figure 3 is designed for use with the Icom 746-PRO “CIV” bus. A different circuit may be needed for other transceiver brands.

As you can see in Photo 2, there are three ministereo audio connectors on the back of the HRRL that are used for serial interfaces: the Zilog debug interface, the output to program the 2-m radio (CIV), and a connector for a serial interface to a PC (not currently used). A future version of the program will use this interface for programming the database. (The current version requires a recompile of the software to update the database followed by a download of the new code through the debug port.) 

(Click here to enlarge)

Photo 2—Moving from left to right, the rear panel has wires to 12 VDC (to a cigarette lighter socket), the power switch, three ministereo jacks that connect to a PC serial port for programming, a PC serial port running a terminal emulator (currently not used), and the Icom IC-746PRO programming bus. The wires on the right go to the GPS receiver.

SOFTWARE OPERATION

The system is interrupt-driven because it is necessary to be able to take care of inputs that come asynchronously. A background process takes care of the major function—calculating the distance to all the stations in the database.

There are two interrupt routines: GPS character received and timer 10-ms interrupt. The background routine cycles through the database of repeaters and calculates the distance to each one. A global variable gives the current latitude and longitude values. Because this is can be changed by the GPS receiver, the background disables interrupts before copying the latitude and longitude information to a local variable, which is then used throughout the main loop.

The GPS receiver sends characters at 4,800 bps. A line of characters giving latitude, longitude, and time is sent twice per second.

A state machine guides the parsing of the GPS data with a simple string defining the parse operations. The state of the parse is an index into the parse string. When a new character comes along, it is handled according to the definition in the parse string. This scheme makes it extremely easy to change the parsing according to your needs. For example, it’s easy to add a checksum calculation. Information about signal strength, date, and altitude can be extracted from the GPS datastream.

A timer interrupt occurs every 10 ms. A number of different things happen in response to a timer interrupt: a counter is incremented to determine if valid GPS information hasn’t arrived for several seconds; the station-select switch is polled to see if you want to display information for a different station, and switch debounce is also handled; the sticky-bit switch is serviced; the LED is turned on and off at a 1-s rate; and a new character is sent to the LCD if it needs service.

Commonly used LCD modules don’t have a signal to indicate that they’re ready for the next character to be displayed. They will not accept characters at the rate that the microcontroller could send them. Therefore, it’s necessary either to poll the display to see if it’s ready for another character or wait for a specified time (often approximately 40 µs) before sending the next character.

In order to avoid the loss of CPU cycles required by the polling method, the software uses the delay approach. A new character is sent every 10 ms to the LCD (if there are characters remaining to be sent) in response to a timer interrupt. This is much slower than possible, but it’s faster than what’s necessary for this application.

A buffer of the LCD characters is kept in the lcdBuf array. Although it isn’t strictly necessary to buffer the LCD information, the microcontroller is blessed with plenty of RAM. This approach makes the code clean and straightforward.

Whenever a routine finishes writing to the buffer, it increments a line-to-be-written byte (ltbw) that indicates to the interrupt routine that the corresponding line of characters should be written to the display.