TelephoneBill
Well-known member
(https://forum.pjrc.com/threads/35397-Teensy3-1-as-a-precision-Frequency-Standard).
In the above post, I demonstrated a precision frequency standard based upon the 60 KHz time broadcast from the UK MSF transmitter. This new post is about a project similar to the previous one but uses a superior 100 KHz transmission from the UK LORAN (Long Range Navigation) transmitter situated on the same Anthorn site.
LORAN was developed post World War 2 from bomb aiming technology. It was active from the late 1940’s until fairly recent. Though many global stations have now closed down, there is a revival system called eLORAN (enhanced Loran) currently being tested. It aims to provide an alternative backup service to GPS. Trials are now taking place in the US, UK and South Korea.
The LORAN signal is superior to MSF because it is able to remove the unstable sky-wave reflection component from the more stable ground-wave. It does this by using a series of short fast rise-time pulses rather than a continuous carrier. These pulses are about 200 uSecs in length so each will carry at least 20 cycles of 100 KHz (10 uSec per cycle). A master LORAN station transmits a group of 8 consecutive pulses, spaced 1 milliSec apart (precisely), followed by a gap of 2 milliSecs and then a final ninth pulse. This sequence is repeated at a time period known as the GRI (Group Repetition Interval). For the UK Anthorn transmitter, the GRI is 67,310 uSecs. You can see a short video of this signal waveform here…
https://youtu.be/xws7mJvp3dQ.
To understand how this stability principle works, consider for example my own location which is 180 Km from the transmitter. This is the direct path that the ground-wave takes, and pulses will arrive some 600 uSecs after leaving the transmitter. The sky-wave, however, travels a little further because it needs to reach and reflect from the D-layer which is approximately 75 Km above ground. Trigonometry dictates that the corresponding sky-wave pulse will therefore travel a total of 234 Km before it reaches my location. This is 54 Km further in distance than the ground-wave, and will therefore arrive some 180 uSec later. So if my radio receiver can extract the first 10 or 15 cycles from any of the individual 100 KHz LORAN pulses, then this part of the signal will be free from any phase distortion caused by vector addition of the delayed sky-wave to the ground-wave component.
In this project, Teensy 3.1 operates in 120 MHz overclock mode, which gives a peripheral flextimer clock rate of 60 MHz. Flextimer FTM1 is used to generate a local 100 KHz square wave reference signal having its output on Channel 0. This reference is phase locked to some early 10 cycles of the LORAN signal. The radio signal is first received and amplified (in a similar way as for the previous MSF project) and then passed to a NOR gate biased to operate in its linear mode. The output of the NOR gate is a square wave whose transitions are then used as an edge trigger for Channel 1 of FTM1. The counter readings of Channel 1 will be directly proportional to the time difference between the LORAN signal cycle edges and the edges of the local Teensy 3.1 generated 100 KHz. This feature is used in the algorithm to obtain phase lock.
Precise phase lock is achieved by finely adjusting the Teensy 16 MHz crystal frequency using the on-chip digital load capacitors in register OSC_CR. By “dithering” between two specific (chosen) values, the crystal can be adjusted to be exactly 16 MHz. This will set the 100 KHz output of FTM1 to also be exactly 100 KHz and this can further be used to control the phase of the reference square wave in comparison with the LORAN cycles.
The phase locking algorithm only needs to make a comparison to those selected early 10 cycles of the LORAN signal when they are present. It needs to ignore the readings of Channel 1 at all other times. So to select the timing for those 10 LORAN cycles, a strobe signal is created on an output pin (digitalWriteFast) which is time referenced to the ISR routine that fires in response to the overflow signal (TOF) associated with FTM1 and the 100 KHz reference. The ISR will fire every time FTM1 makes an edge transition (positive or negative) so the ISR repeats its code every 5 uSecs (making 10 uSec for a complete cycle). There will - therefore - be 13,462 interrupts (and passes through the ISR routine) for one complete GRI interval of 67,310 uSecs – and then the procedure will repeat over again. By counting each ISR pass, it is fairly easy to create a strobe signal that can be time varied to pulse on/off repeatedly at any specific point in the GRI period. That same strobe time can be used internally in code to record the required readings from Channel 1.
The actual lock control code is outside the ISR in the program main loop. It is a very simple idea. All Channel 1 readings are measured for 10 LORAN square wave cycles. That makes 20 readings in total – one reading for each square edge (positive or negative). Then the average reading is calculated and compared to a value of “150”. If below this value, the 100 KHz reference is speeded up by increasing the dither ratio (of the digital load capacitors). If above this value, then it is slowed with a decrease in the ratio. It works delightfully and never fails to phase lock. In the aforementioned video, the second trace is the LORAN square wave, and the third trace is the Teensy 100 KHz generated reference. Notice how stable the Teensy signal is even though the LORAN signal is fairly wobbly.
At this moment in my project, I manually adjust the strobe signal (using a digital oscilloscope) in order to align it with the start of the selected 10 LORAN cycles. But I am currently working on an algorithm to identify the start of the LORAN master group of pulses, and thereby automatically adjust things to be self-aligning. The following picture shows a recording of the LORAN square wave as a series of binary digits for the period of the nine pulses. Each of the group pulses can be seen clearly in the pink highlighted portions. I record one digit of the signal on each pass of the ISR. Notice that pulse P1 and P2 are the same phase of ones and zeroes, but P3 and P4 are inverted phase. Then P5, P7 and P9 are non-inverted, whilst P6 and P8 are inverted. This is classic signal modulation for the first master LORAN pulse group. There are 200 bits between each pulse starting point (remember that each ISR pass is 5 uSecs), which reflect the 1 milliSec interval between each pulse. Naturally, some degree of signal noise can occasionally upset the sequences, but most pulses can be individually identified.
Here is a useful reference for the LORAN signal characteristics…
http://jproc.ca/hyperbolic/loran_c_sigchar.html
If readers of this project are interested in the code, and/or the design of the simple radio receiver, then I can add these on request. The radio uses a simple ferrite loopstick antenna so works well indoors without an external antenna.
Recently in the UK, the eLORAN transmission cycles have been adjusted to be synchronous with UTC. So when Teensy 3.1 is locked to them, then Teensy is phase locked to UTC. The 1 second BLINKY flashes seen in the video have to be some of the most accurate “Blinkies” produced !!
These eLORAN transmissions also have a low bit rate data channel encoded within them. Further work should enable this data channel to be demodulated (for more info, search the web for EUROFIX). The data channel is used to provide differential corrections to the LORAN pulse timing, and thereby increase the accuracy of this timing/navigation system. A number of permanent receiver stations are monitoring the signals to make local corrections. This is not unlike the corrections made to GPS to improve its overall accuracy. One of the benefits of eLORAN compared to GPS is that the transmitters are working at high power levels so are much more difficult to spoof.
In the above post, I demonstrated a precision frequency standard based upon the 60 KHz time broadcast from the UK MSF transmitter. This new post is about a project similar to the previous one but uses a superior 100 KHz transmission from the UK LORAN (Long Range Navigation) transmitter situated on the same Anthorn site.
LORAN was developed post World War 2 from bomb aiming technology. It was active from the late 1940’s until fairly recent. Though many global stations have now closed down, there is a revival system called eLORAN (enhanced Loran) currently being tested. It aims to provide an alternative backup service to GPS. Trials are now taking place in the US, UK and South Korea.
The LORAN signal is superior to MSF because it is able to remove the unstable sky-wave reflection component from the more stable ground-wave. It does this by using a series of short fast rise-time pulses rather than a continuous carrier. These pulses are about 200 uSecs in length so each will carry at least 20 cycles of 100 KHz (10 uSec per cycle). A master LORAN station transmits a group of 8 consecutive pulses, spaced 1 milliSec apart (precisely), followed by a gap of 2 milliSecs and then a final ninth pulse. This sequence is repeated at a time period known as the GRI (Group Repetition Interval). For the UK Anthorn transmitter, the GRI is 67,310 uSecs. You can see a short video of this signal waveform here…
https://youtu.be/xws7mJvp3dQ.
To understand how this stability principle works, consider for example my own location which is 180 Km from the transmitter. This is the direct path that the ground-wave takes, and pulses will arrive some 600 uSecs after leaving the transmitter. The sky-wave, however, travels a little further because it needs to reach and reflect from the D-layer which is approximately 75 Km above ground. Trigonometry dictates that the corresponding sky-wave pulse will therefore travel a total of 234 Km before it reaches my location. This is 54 Km further in distance than the ground-wave, and will therefore arrive some 180 uSec later. So if my radio receiver can extract the first 10 or 15 cycles from any of the individual 100 KHz LORAN pulses, then this part of the signal will be free from any phase distortion caused by vector addition of the delayed sky-wave to the ground-wave component.
In this project, Teensy 3.1 operates in 120 MHz overclock mode, which gives a peripheral flextimer clock rate of 60 MHz. Flextimer FTM1 is used to generate a local 100 KHz square wave reference signal having its output on Channel 0. This reference is phase locked to some early 10 cycles of the LORAN signal. The radio signal is first received and amplified (in a similar way as for the previous MSF project) and then passed to a NOR gate biased to operate in its linear mode. The output of the NOR gate is a square wave whose transitions are then used as an edge trigger for Channel 1 of FTM1. The counter readings of Channel 1 will be directly proportional to the time difference between the LORAN signal cycle edges and the edges of the local Teensy 3.1 generated 100 KHz. This feature is used in the algorithm to obtain phase lock.
Precise phase lock is achieved by finely adjusting the Teensy 16 MHz crystal frequency using the on-chip digital load capacitors in register OSC_CR. By “dithering” between two specific (chosen) values, the crystal can be adjusted to be exactly 16 MHz. This will set the 100 KHz output of FTM1 to also be exactly 100 KHz and this can further be used to control the phase of the reference square wave in comparison with the LORAN cycles.
The phase locking algorithm only needs to make a comparison to those selected early 10 cycles of the LORAN signal when they are present. It needs to ignore the readings of Channel 1 at all other times. So to select the timing for those 10 LORAN cycles, a strobe signal is created on an output pin (digitalWriteFast) which is time referenced to the ISR routine that fires in response to the overflow signal (TOF) associated with FTM1 and the 100 KHz reference. The ISR will fire every time FTM1 makes an edge transition (positive or negative) so the ISR repeats its code every 5 uSecs (making 10 uSec for a complete cycle). There will - therefore - be 13,462 interrupts (and passes through the ISR routine) for one complete GRI interval of 67,310 uSecs – and then the procedure will repeat over again. By counting each ISR pass, it is fairly easy to create a strobe signal that can be time varied to pulse on/off repeatedly at any specific point in the GRI period. That same strobe time can be used internally in code to record the required readings from Channel 1.
The actual lock control code is outside the ISR in the program main loop. It is a very simple idea. All Channel 1 readings are measured for 10 LORAN square wave cycles. That makes 20 readings in total – one reading for each square edge (positive or negative). Then the average reading is calculated and compared to a value of “150”. If below this value, the 100 KHz reference is speeded up by increasing the dither ratio (of the digital load capacitors). If above this value, then it is slowed with a decrease in the ratio. It works delightfully and never fails to phase lock. In the aforementioned video, the second trace is the LORAN square wave, and the third trace is the Teensy 100 KHz generated reference. Notice how stable the Teensy signal is even though the LORAN signal is fairly wobbly.
At this moment in my project, I manually adjust the strobe signal (using a digital oscilloscope) in order to align it with the start of the selected 10 LORAN cycles. But I am currently working on an algorithm to identify the start of the LORAN master group of pulses, and thereby automatically adjust things to be self-aligning. The following picture shows a recording of the LORAN square wave as a series of binary digits for the period of the nine pulses. Each of the group pulses can be seen clearly in the pink highlighted portions. I record one digit of the signal on each pass of the ISR. Notice that pulse P1 and P2 are the same phase of ones and zeroes, but P3 and P4 are inverted phase. Then P5, P7 and P9 are non-inverted, whilst P6 and P8 are inverted. This is classic signal modulation for the first master LORAN pulse group. There are 200 bits between each pulse starting point (remember that each ISR pass is 5 uSecs), which reflect the 1 milliSec interval between each pulse. Naturally, some degree of signal noise can occasionally upset the sequences, but most pulses can be individually identified.
Here is a useful reference for the LORAN signal characteristics…
http://jproc.ca/hyperbolic/loran_c_sigchar.html
If readers of this project are interested in the code, and/or the design of the simple radio receiver, then I can add these on request. The radio uses a simple ferrite loopstick antenna so works well indoors without an external antenna.
Recently in the UK, the eLORAN transmission cycles have been adjusted to be synchronous with UTC. So when Teensy 3.1 is locked to them, then Teensy is phase locked to UTC. The 1 second BLINKY flashes seen in the video have to be some of the most accurate “Blinkies” produced !!
These eLORAN transmissions also have a low bit rate data channel encoded within them. Further work should enable this data channel to be demodulated (for more info, search the web for EUROFIX). The data channel is used to provide differential corrections to the LORAN pulse timing, and thereby increase the accuracy of this timing/navigation system. A number of permanent receiver stations are monitoring the signals to make local corrections. This is not unlike the corrections made to GPS to improve its overall accuracy. One of the benefits of eLORAN compared to GPS is that the transmitters are working at high power levels so are much more difficult to spoof.