MEL PICBASIC Forum - Using a 16F628A to indicate reliability of a 10MHz reference

  • Using a 16F628A to indicate reliability of a 10MHz reference

    Amateurs using digital modes of communication or those requiring high stability at UHF frequencies require high stability for all oscillators.

    One way of achieving this is to use a PLL system based on a GPS derived 10MHz signal. Due to the vagaries of weather and satellite availability the signal from the satellites does vary and sometimes a perfect 3D lock is not available. It is critical that the operator knows when he/she has lost sync.

    This project taps into the NMEA stream and provides both a visual display with an LCD and also LED indicators and a sounder.

    The LCD outputs include "3D Lock", "2D Lock" and "NO Lock" while the UTC time is also displayed to screen.

    Three digital ouptuts of the 16F628A provide switching though small NPN transistors to operate the indicator LEDs or sounder. A green LED is labelled "3DLock", an orange LED labelled "2D Lock" and a red LED and sounder are labelled "NO Lock".
    The LCD output is to a single line LCD. The 16 character LCD I used is one of those that treats the single line as two lines of 8 characters. The first 8 characters are printed from 1,1 while the second half of the line is printed to 2,1 resulting in one line of 16 characters. It just requires a little more thought when constructing the print statements.

    The LCD is shown indicating current UTC time with an indication that a full 3D decode is taking place.
    A 3D decode confirms that the 10 MHz output is GPS locked and reliable.
    Here is a typical $GPGSA string showing quality as 3, it is the second item.

    The quality data has a value from 1-3. A value of 1 indicates zero lock, a value of 2 implies a 2D condition (acceptable but not ideal) while a value of 3 implies a full 3D lock and therefore the best result available.Note that in the code I also allocate a value to ValueA. This byte variable is used to remove the first bit of data in the GSA string so that the PIC can access the second item which is the quality value. ValueA is never used.
    Derivation of the time is obtained from the $GPGGA string and is the first item in the GGA list. In this example string it is 123519 which would be printed as 12:35:19.

    $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545. 4,M,46.9,M,,*47
    Using the DEC modifier to allocate it to a DWORD variable this number is then worked on using modulus and integer divide to extract the seconds, minutes and hours. The print statement tests for values of less than 10 (one digit) and adds a zero if necessary to maintain the printed string length.
    Most GPS are either locked to 4800 baud output or may be enabled for 4800 baud. The USART in the PIC is set for 4800 baud receive using asynchronous 8 data bits, no parity and 1 stop bit. Note that once the receive port has been set (PortB.1) the transmit port (PortB.2) is no longer available for general IO.

    Although not shown, the PIC is a 16F628A. The transistors can be any general purpose NPN type. The crystal is an 8MHz type, although any frequency would work providing you match the crystal definition in the basic program.
    If an operator wants an audible indication of loss of lock a piezo sounder could be connected between 12V and the collector of the transistor driving the RED LED.

    If your GPS has a TTL output rather than RS232, remove all the components connected to pin 7 (RX) and replace with a single 10K resistor between pin 7 and the output of your GPS engine. The function of the transistor in the input to the RX of the PIC is to invert the sense of the data and provide some protection from the negative going RS232 data - neither of these are needed if you use a TTL input.
    The Proton PIC Basic source code is in my files page as GPSchecker.bas

    by John Drew