PIC-based circuit example from Westford MicroSystems repeater for GPS data and battery voltage monitor

23,624

Circuit Image

If a page name is not selected by pressing the button, the previously selected page name continues to be used. The value is stored in EEPROM and may be changed at any time. When the unit is first powered on, and any time the Position page is displayed, the current magnetic variation is saved and used to convert all heading and bearing information to magnetic degrees. The repeater checks the $GPRMC data sentence once every 10 minutes to update the magnetic variation. If the GPS sends a "satellite warning flag," a message is displayed. This occurs if satellites are not being received (e.g., GPS indoors) or if the satellites are broadcasting a warning. If the baud rate received from the GPS is other than 4800, a message is displayed. This may happen, for example, if the NMEA-0182 protocol (1200 baud) is selected or during Garmin protocol (9600 baud) uploads/downloads. A Windows software application allows the creation of several virtual COM ports from one incoming GPS, providing a simulated NMEA-0183 data stream for demonstration or testing, along with other interesting features. Other GPS and serial tools are also available. The adjustment of Pots R1, R2, and R3 is necessary to display correct battery voltages. Calibration is performed by applying 13.98 volts and adjusting the potentiometer to display the correct voltage. Voltages of 14.99 volts and higher are indicated simply as "14.99." A diode on the 12V power supply input provides reverse current protection and isolates the repeater from 12V collapse during engine starting. Any LCD display with an industry-standard HD44780 compatible controller may be used. "Supertwist" displays offer wider viewing angles than others. The main loop code selects the NMEA-0183 data sentence, such as $GPRMC, to be monitored in the GPS data stream. The hardware UART receives the serial stream, serviced by the RDA serial interrupt. After identifying the beginning of the sentence, the remainder is stored in RAM. Upon receiving the end of the sentence, the main loop invokes the parsing routine to extract specific data fields for display. The display updates at the rate at which the GPS transmits data streams (every two seconds for the GARMIN-38). The data sentence is identified in the code. During this time, the serial interrupt activates whenever a character is received from the GPS. The serial interrupt is positioned near the top of the code. It utilizes a switch-case statement that first searches for a "$" (case 0), then reads the next five characters (cases 1-5). Each character is exclusive ORed with the previous ones, leading to a decision on whether the data sentence is the desired one (GPRMC). Exclusive ORing the five characters in "GPRMC" results in 75. Thus, if the fifth character yields 75, it confirms the GPRMC sentence, and the characters continue to be saved. If not, the state resets to 0, searching again for the "$". The code can be recompiled for clock frequencies between 4 and 20 MHz, with the crystal frequency defined at the beginning of the code. Two time constants are automatically adjusted in the code to accommodate frequency changes. The data sentence stream transmitted from the Garmin 38 every two seconds at 4800 baud includes RMC and RMB sentences, which are essential for full utilization of the repeater's functions.

The electronic schematic for this system involves several key components and their interconnections to facilitate the described functionality. The EEPROM is utilized for storing the previously selected page name and the current magnetic variation, allowing for persistent data retention. The microcontroller interfaces with the GPS module to receive NMEA-0183 data sentences, specifically focusing on the $GPRMC and $GPRMB sentences. This data is processed in real-time using an interrupt-driven architecture, where the UART handles incoming serial data, ensuring efficient data capture and processing.

The system's power management incorporates a diode for reverse current protection, ensuring that the repeater remains operational during transient voltage conditions, such as engine start-up. The LCD display, compatible with the HD44780 controller, serves as the user interface, providing visual feedback of the current magnetic heading and battery voltage levels. The adjustment pots (R1, R2, R3) are connected to an analog input of the microcontroller, allowing for calibration of battery voltage readings.

Moreover, the software implementation includes a calibration routine triggered by applying specific voltages to ensure accurate battery voltage displays. The system also incorporates a mechanism to handle baud rate discrepancies, displaying appropriate messages if the GPS output does not match the expected 4800 baud. The overall design emphasizes reliability and user interaction, making it suitable for applications requiring precise navigation data processing in varying operational environments.If a page name is not selected by pressing the button, the previously selected page name continues to be used. The value is stored in EEPROM and may be changed at any time. When the unit is first powered on, and any time the Position page is displayed, the current magnetic variation is saved and used to convert all heading and bearing informationto magnetic degrees.

The repeater checks the $GPRMC data sentence once every 10 minutes to update the magnetic variation. If the GPS sends a "satellite warning flag", the following message is displayed. This would occur if satellites aren`t being received (GPS indoors ) or if the satellites are broadcasting some sort of warning. If the baud rate received from the GPS is other than 4800, the following message is displayed. This would occur, for instance, if NMEA-0182 protocol (1200 baud) is selected or during Garmin protocol (9600 baud) uploads/downloads.

A rather nice piece of Windows software provides the ability to create several virtual COM ports from one incoming GPS, and provides a simulated NMEA-0183 data stream for demo or testing, and has a number of other intesting features. There are other GPS and Serial tools as well. Refer to GpsGate at Franson Technology AB Pots R1, R2, R3 are adjusted to display correct battery voltages.

To calibrate, apply 13. 98 volts and adjust the pot to display correctly. 14. 99 volts and higher simply displays as "14. 99". The diode on the 12V power supply input provides reverse current protection. More importantly, it isolates the repeater from 12V collapse (during engine starting, for instance. ) Any LCD display that has an industry-standard HD44780 compatible controller may be used. "Supertwist" displays have wider viewing angles than others. Two examples of LED backlight supertwist displays are: Basic sequence: The main loop code selects the NMEA-0183 data sentence, such as $GPRMC. that will be looked for in the data stream from the GPS. The serial stream is received by the hardware UART and serviced by the RDA serial interrupt. After the beginning of the sentence is identified, the remainder of the sentence is saved in RAM. When the end of the sentence is received, the main loop calls the parsing routine to extract certain data fields for display.

The display is updated at the rate at which the GPS sends it`s data streams out (every two seconds in the case of the GARMIN-38. ) I identify the data sentence by the following in my code: During this time the serial interrupt has been interrupting anytime a character is received from the GPS.

The serial interrupt is near the top of my code (I usually put interrupt code first. ) It`s called: In that interrupt I use a switch-case statement that first looks for a "$" (case 0), then reads in the next five characters (cases 1-5) and after each of those characters exclusive ORs the character into the previous ones, and then makes a decision whether it`s the data sentence I want (GPRMC). When you exclusive OR the five characters in "GPRMC" together, you get 75. So, if after the fifth character I have 75, then I know it`s a GPRMC sentence, and I keep going, saving the characters.

Otherwise I go back to state 0, which is to again search for the "$". The code may be recompiled for any clock frequency between 4 and 20MHz. The crystal frequency is defined at the top of the code. Note that two of the time constants are automatically changed in code to accommodate changes in frequency. Below is the data sentence stream that is transmitted from my Garmin 38 every two seconds at 4800 baud.

The RMC and RMB sentences are the only ones the repeater uses. This is similar to what you should see from your GPS if you look at the data stream with HyperTerm or Procomm or similar terminal emulators. At the very least, there should be RMC and RMB sentences for full utilization of the repeaters functions.

$GPGLL, 4400. 000, N, 07143. 125, W, 020822, A*35 $PGRMZ, 5 🔗 External reference