“In recent years, GPS (Global Positioning System) has been widely used. GPS not only provides positioning information, but also provides high-precision time signals. In seismic observation systems, data acquisition devices have extremely high requirements for time. At present, GPS synchronization and local clock timekeeping are commonly used to obtain time information.
Source: Author: Zhu Zuyang, Xue Bing
In recent years, GPS (Global Positioning System) has been widely used. GPS not only provides positioning information, but also provides high-precision time signals. In seismic observation systems, data acquisition devices have extremely high requirements for time. At present, GPS synchronization and local clock timekeeping are commonly used to obtain time information. Each device has its own GPS receiver for synchronizing timing. This means that even in an area within a range of several hundred meters, due to the different locations of each device and the performance of each receiver can not be completely consistent, there is still a certain error in the time information between each other. If in a small area, several data collectors simultaneously use a GPS receiver to synchronize the timing, the above-mentioned errors can be eliminated, and the time unity and reliability can be further improved. IRIG code is an international standard time transmission code. It not only contains the second symbol information, but also contains absolute time information. It has been widely used in the interface standard between the time system device and the user receiving device, which improves the consistency and reliability of the sender and receiver’s time.
1 IRIG code format specification
IRIG (Inter Range Instrumentation Group) code, called “American Range Instrumentation Group Code”, encodes the received GPS time and transmits it to equipment distributed in different places to achieve clock synchronization between the equipment. This code is widely used in time-system equipment such as missiles, aerospace, telemetry, etc., with high implementation accuracy and strong stability.
The IRIG code contains 100 symbols, and each symbol has 3 code types: binary 0, 1 and position identifier. Divided into 3 fields to code: the first field is the year time (day, hour, minute, second), the second field is the control function field, and the third field is the day and time directly represented by the binary second symbol. Cycle once every 24 hours.
IRIG serial codes mainly have six time formats: A, B, D, E, G, and H. The main difference is the time coding accuracy, the symbol rate and the number of bits of the binary time information. The A and B codes are actually commonly used. The frame period of A code is 0.1 s, and the frame period of B code is 1 s.
In this design, IRIGA serial time code encoding is used. IRIG codes are divided into direct current (DC) codes and alternating current (AC) codes. The symbol period of the DC code and the AC code is 1 ms. The DC code uses the pulse width to represent the code element, a pulse width of 0.2 ms represents a binary 0, a pulse width of 0.5 ms represents a binary 1, and a pulse width of 0.8 ms represents a position identifier or reference symbol. The AC code uses the number of high-amplitude and low-amplitude sine waves with a period of 0.1 ms to represent the symbol, the reference symbol or position identifier is represented by 8 high-amplitude and 2 low-amplitude, and binary 1 uses 5 high-amplitude sums. 5 low amplitudes are represented, and binary 0 is represented by 2 high amplitudes and 8 low amplitudes.
2 IRIGA coding design
The LPC2132 microcontroller has one 8-channel 10-bit A/D converter and one 10-bit D/A converter, two 32-bit timers/counters (with 4 capture and 4 comparison channels), and a PWM unit ( 6 outputs) and watchdog, 9 edge or level trigger external interrupt pins. The on-chip crystal oscillator circuit supports a frequency of 1 “30 MHz. The operating frequency of the microcontroller up to 60 MHz can be achieved through the on-chip PLL. The stabilization time of the PLL is 100 μs.
In this design, LPC2132 and LEA4H GPS receivers are used to form the transmitter of a timing device. The GPS receiver sends data to the microcontroller once a second through the UART port, and the 1PPS pulse signal is connected to the microcontroller’s external interrupt EINT0. The temperature sensor TCN75 collects the ambient temperature and transmits the temperature data to the microcontroller via the I2C bus. The second-order low-pass filter circuit reshapes the waveform output by the D/A converter. The microcontroller maintains a local clock count, generates time in milliseconds, seconds, minutes, hours, and days, and encodes the time information in the format of IRIGA codes at the same time. The block diagram of GPS clock circuit is shown as in Fig. 1.
Figure 1 GPS clock circuit block diagram
The microcontroller continuously detects the frequency of the local crystal oscillator according to the 1PPS signal, and controls the matching value of the matching register according to the detection result. The internal 32-bit timer counter T0 of the microcontroller always counts the frequency of the local crystal oscillator, and the capture register CR0 is loaded with the current count value triggered by the 1PPS signal; the matching register MR0 is used to set the edge of the IRIG DC code waveform and the IRIG AC code sampling At one point, the matching register MR1 is used to set the time unit signal. The software coding design block diagram is shown as in Fig. 2.
2.1 Crystal frequency measurement
The 32-bit counter T0 counts continuously all the time. When the 1PPS signal arrives, an interrupt is generated, and the capture register CR0 is loaded with the current count value CT1 of T0 and saved. When the PPS signal arrives, CR0 is loaded with the count value CT2 of T0, and the local crystal oscillator frequency is (CT2-CT1) or (CT1+232-CT2). The situation when T0 count overflows.
2.2 Time information generation
The microcontroller uses the count of the local clock to generate time information of milliseconds, seconds, minutes, hours, and days, and sets software counters for milliseconds, seconds, minutes, hours, and days. The match register MR1 sets the match value at the time of milliseconds according to the current frequency value of the crystal oscillator. When there is a match, the millisecond software counter value is incremented by 1. The millisecond counter counts the time of 0″1000 ms, and is cleared at the second moment; the second, minute, hour, and day counters mainly complete the timing of seconds, minutes, hours, and days. Since the GPS receiver sends data information once every 1 s, so The synchronization accuracy of the local clock is 1 s. Because errors may occur under a second, the microcontroller also needs to measure the clock difference and compare the local clock timing information with the GPS time information. The difference between the two is greater than 1 s, directly Modify the local time information. If the local time is fast, adjust the tick of the millisecond counter to a bit slower, that is, the matching value at MR1 millisecond is set too large; otherwise, adjust the tick faster until the error is minimized.
Figure 2 Block diagram of software coding design
2.3 DC code encoding output
The matching register MR0 controls the inversion of the DC code waveform. Since the relationship between the 32-bit counter T0 and 1PPS is known, the count value at the time of the transition can be determined according to the pulse width of the output symbol. In fact, as long as the extracted time information is converted into the format of IRIGA, the count value of the transition edge of the pulse width of a frame symbol can be determined according to formula (1). In order to make the output symbols timely and accurate, you can write the count value of the next transition edge to the matching register in advance, that is, preset the CTY value when the CTX value matches, as shown in Figure 3. Counter value CTX corresponding to TX moment:
In the formula, the unit of TX is μs.
Figure 3 Schematic diagram of IRIGA code generation
2.4 AC code encoding output
Each sine wave of the AC code samples 16 points, and the sampling time interval between adjacent points is equal, and the sampling time interval between the first point and the 17th point is 1 ms. The AC code is expressed by the number of high and low amplitude sine waves (the sampling time of the high amplitude and low amplitude sine waves is the same, and the corresponding time amplitude is 3 times that of the former), and the sine wave sampling points are stored in the table. Table 1 stores high-amplitude sine wave data, and Table 2 stores low-amplitude sine wave data. In the internal memory, the entry addresses of Table 1 and Table 2 are different, and the local addresses are exactly the same. As long as you jump to the corresponding entry address when addressing, the following table look-up methods are completely the same. The look-up time is controlled by the matching register, and the data is sent to the D/A converter during the look-up, as shown in Figure 4. At the output end of the D/A converter, connect a DC blocking capacitor and a low-pass filter to shape the output. At the same time, the matching value of the matching register must be continuously adjusted according to the measured frequency.
Figure 4 Schematic diagram of IRIG-A AC code generation
The software design process is shown in Figure 5 and Figure 6.
Figure 5 Reference time generation process
Figure 6 IRIG-A DC and AC code generation program flow
If the GPS is out of sync, the 1PPS signal will not be used to measure the crystal frequency. The crystal is affected by various factors such as temperature, frequency characteristics and aging, and will have short-term or long-term frequency drift. In order to make the output IRIGA code still have high accuracy, the solution is to build a temperature frequency table internally, and determine the current crystal frequency through real-time look-up table. When GPS is synchronized, the microcontroller uses the 1PPS signal to continuously adjust the count values CT1 and CT2, and at the same time uses the temperature sensor to collect the current operating temperature T, and a[T; CT2CT1]temperature frequency table can be listed in a temperature step difference of 0.5°. As long as the GPS is synchronized, this temperature and frequency table is constantly updated to ensure that the table is available in real time; once the GPS is out of synchronization, the microcontroller can look up the table to find the current frequency value f, which is determined by equation (1) The counter value CTX corresponding to the TX time and the look-up time to determine the AC code to ensure the continuity and high accuracy of the IRIGA code output.
This design realizes the coding output of IRIGA DC code and AC code, and the two codes can be selected and used according to actual needs. The DC code and AC code are mainly completed by software. During the programming process, the microcontroller continuously detects the frequency of the local crystal oscillator. When GPS is synchronized, 1PPS signal is used to calculate the frequency value. The obtained frequency value is very accurate, and the table is stored according to the temperature address; when the GPS is out of synchronization, the microcontroller can check the temperature and frequency table, and the frequency with a certain degree of accuracy can also be obtained. value. According to the local crystal oscillator frequency, the output of the IRIG code can be accurately controlled. The actual circuit of this design is small in size and low in power consumption. It has high output accuracy when GPS is synchronized, reaching the order of μs, and the output also has high accuracy when GPS is out of step. At the same time, it can choose to use DC code and AC code output has high application value.
The Links: LP104V1 SEMIX703GB126V1 LCD-PANEL