Easy GPS Disciplined 10MHz Reference makes use of Twin PWMs

0
1

c032

c032
c032 c032 c032 c032 c032

c032 I used to be just c032 lately engaged on an experiment c032 for a brand new design c032 and was utilizing a operate c032 generator. Though new operate turbines c032 have fairly good frequency tolerance c032 specs, I wanted one thing c032 with extra accuracy and precision. c032 The way in which to c032 get extra accuracy in frequency c032 turbines, arbitrary waveform turbines, and c032 frequency counters is to make c032 use of the ten MHz c032 reference enter supplied on many c032 of those check devices. Not c032 having such a reference, and c032 having been just lately enjoying c032 with the Arduino Nano, I c032 made a decision it could c032 be fascinating to see if c032 one might be constructed across c032 the Nano.

c032

c032 Determine 1 c032 exhibits the primary elements c032 of this straightforward and cheap, c032 “no calibration required” design. The c032 frequency is generated by a c032 ten MHz voltage-controlled crystal oscillator c032 (VCXO). This oscillator generates a c032 frequency round 10 MHz with c032 affordable tolerance but in addition c032 has a frequency regulate pin c032 that enables for an adjustment c032 up or down. The trick c032 to getting a extra exact c032 and correct 10 MHz sign c032 is to seek out the c032 correct adjustment for the VCXO c032 and to readjust it because c032 the VCXO drifts attributable to c032 numerous elements.  Let’s check out c032 the way in which to c032 perform this.

c032

c032 Determine 1 c032 The principle elements of c032 a easy frequency generator with c032 no calibration required.

c032

c032 A GPS module can ship c032 a really correct 1 pulse-per-second c032 sign (1PPS). This pulse appears c032 to be like like a c032 ~100 ms pulse each second.  c032 Even in cheap modules, this c032 sign is often correct within c032 the vary of some tens c032 of nanoseconds. That is the c032 design’s exterior reference for the c032 era of an correct 10 c032 MHz sign. The 1PPS sign c032 is linked to the Arduino c032 Nano at an I/O line c032 able to producing an interrupt. c032 The design additionally has a c032 32-bit counter that may be c032 learn and reset by the c032 Nano. The 32-bit counter is c032 linked to the output of c032 the VCXO, so it counts c032 the variety of VCXO cycles c032 since its final reset. The c032 final main piece is to c032 that is how we regulate c032 the VCXO.

c032

c032 The Nano doesn’t have a c032 DAC however because it seems, c032 one of many easy capabilities c032 of the Nano is controlling c032 its pulse-width modulation (PWM) traces c032 that are meant for use c032 as an adjustable DC output c032 voltage (after filtering). A easy c032 set of calls will output c032 a 5V PWM sign at c032 a hard and fast frequency.  c032 The PWMs have an 8-bit c032 adjustment vary, so if you c032 need a 2.5V output, you’d c032 set the PWM to 128 c032 (50% obligation cycle). (Be aware, c032 for this set of calls, c032 the Nano makes use of c032 a frequency of round 500 c032 Hz, though that is solely c032 essential to the filter design.) c032 So, the primary thought is c032 to make use of a c032 PWM output from the Nano, c032 filter it to get a c032 comparatively ripple free DC stage, c032 and apply this to the c032 VCXO’s regulate pin. This is c032 able to work, however the c032 problem is that we might c032 solely have 255 discrete ranges c032 that it might be set c032 to which will not be c032 sufficient. Let’s take a deeper c032 have a look at this.

c032

c032 The VCXO I selected for c032 the undertaking is a Taitien c032 TSEAACSANF-10.000000. It has an preliminary c032 frequency tolerance of two ppm c032 and a most adjustment vary, c032 known as “pull vary”, of c032 roughly ±12 ppm utilizing 0.5 c032 to 2.5 volts on the c032 regulate pin. So, if we c032 used the total 255 steps c032 of the PWM, we might c032 be capable to regulate the c032 VCXO with a decision of c032 about (2*12/255 ≈ 0.1 ppm).  c032 This didn’t appear to be c032 a lot of an enchancment c032 in ppm accuracy, so I c032 got here up with the c032 concept of utilizing two PWMs: c032 one for coarse regulate and c032 one for fantastic regulate. To c032 maintain the design easy, I c032 opted to make use of c032 resistors solely and no op c032 amps. This portion of the c032 circuit could be seen in c032 c032 Determine 2 c032 (there are additionally 2 c032 filter caps proven which we c032 are going to talk about c032 later). 

c032

c032

c032 Determine 2 c032 Course and fantastic adjustment c032 to the PWM traces which c032 are meant for use as c032 an adjustable DC output voltage.

c032

c032 Basically what you see is c032 an averaging circuit with 2 c032 kΩ of resistance within the c032 coarse portion of the circuit c032 and 270 kΩ within the c032 fantastic portion.  The ultimate 2 c032 kΩ resistor is used to c032 divide the voltage down because c032 the adjustment pin, as a c032 reminder, this takes 2.5V max. c032 The VCXO adjustment voltage could c032 also be solved simply utilizing c032 superposition and is roughly equal c032 to Equation 1.

c032

c032 VCXO adjustment voltage = 9.76×10 c032 -3 c032 x PWM c032 COARSE c032 + 144×10 c032 -6 c032 x PWM c032 FINE c032 (Eq. 1)

c032

c032 The place PWM c032 COARSE c032 and PWM c032 FINE c032 can vary in worth c032 from 0 to 255. This c032 circuit is typically known as c032 a passive averaging circuit, as c032 described by Millman’s theorem. Now, c032 making the output voltage to c032 the VCXO regulate pin monotonic c032 utilizing each PWMs is impractical c032 because the precision of the c032 resistors would have to be c032 very excessive. That is solved c032 by selecting resistor values that c032 permit for a fantastic PWM c032 adjustment to regulate with a c032 spread overlapping the next coarse c032 vary. 

c032

c032 Let me give an instance: c032 the resistor values proven in c032 Determine 2 permit for the c032 coarse PWM sign to maneuver c032 about 9.8 mV with every c032 step. The fantastic PWM sign c032 strikes about 0.14 mV per c032 step or roughly 36 mV c032 over its full vary. Due c032 to this fact, because the c032 fantastic adjustment vary is bigger c032 than the coarse adjustment step c032 measurement, there may be all c032 the time loads of overlap. 

c032

c032 Determine 3 c032 exhibits a few the c032 coarse ranges and the way c032 the fantastic worth overlaps are c032 configured. Within the later dialogue c032 of the adjustment algorithm, I’ll c032 clarify how this overlap is c032 used.  (Be aware, the 2 c032 100uF caps in Determine 2 c032 had the values chosen to c032 maintain the ripple from the c032 PWM waveform under the 0.14 c032 mV fantastic step measurement. To c032 assist within the filtering, the c032 code will increase the PWM c032 frequency to roughly 31 kHz.)

c032

c032

c032 Determine 3 c032 Diagram illustrating fantastic adjustment c032 vary and coarse adjustment step c032 measurement overlaps.

c032

c032 Placing all this collectively, the c032 operation goes one thing like c032 this: after power-up, the Arduino c032 Nano units the coarse and c032 fantastic PWMs to an preliminary c032 worth (someplace within the center), c032 after which waits till it c032 senses the 1PPS sign coming c032 in from the GPS module. c032 Then, on the interrupt of c032 the following 1PPS sign, the c032 Nano resets the 32-bit counter. c032 The counter then begins counting c032 the cycles from the VCXO. c032 Upon receiving the next 1PPS c032 interrupt, the Nano captures and c032 reads the 32-bit counter, which c032 needs to be a depend c032 of 10,000,000. If the depend c032 is lower than 10,000,000, it c032 adjusts the fantastic PWM worth c032 up. If the fantastic PWM c032 worth is at 255 earlier c032 than adjustment, the coarse PWM c032 worth is incremented and the c032 fantastic PWM worth is ready c032 to 127 (within the center). c032 If the depend is larger c032 than 10,000,000, it adjusts the c032 fantastic PWM worth down.  If c032 the fantastic PWM worth is c032 at 0 earlier than adjustment, c032 the coarse PWM worth is c032 decremented and the fantastic PWM c032 worth is ready to 127 c032 (within the center). You possibly c032 can see that the overlap c032 of the fantastic changes with c032 multiple coarse worth makes this c032 algorithm secure from looking for c032 an applicable worth, albeit considerably c032 inefficient by way of search c032 pace. 

c032

c032 That is really the primary c032 stage of adjustment. If we c032 solely measured one second of c032 counts, we couldn’t get greater c032 than 0.1 ppm accuracy.  So, c032 the second stage of code c032 permits the 32-bit counter to c032 build up for 10 seconds c032 by ready till it has c032 seen 10 interrupts. Now the c032 depend can go as much c032 as 100,000,000 and we are c032 able to regulate to stand c032 up to the 0.01 ppm c032 vary (or 10 ppb). These c032 first two levels are used c032 to shut in on the c032 goal 10 MHz a bit c032 sooner. A 3rd, and steady c032 working stage, counts for 100 c032 seconds, ready for 100 interrupts, c032 earlier than studying the counter. c032 This will get us to c032 an anticipated depend of 1,000,000,000 c032 which permits for an adjustment c032 to 1 ppb. However what c032 can the PWMs really regulate c032 to? As said earlier than, c032 the fantastic PWM strikes by c032 roughly 0.14 mV per step c032 and the VCXO regulate by c032 about +/-12 ppm over 0.5 c032 to 2.5 V.  Due to c032 this fact, every fantastic step c032 strikes the frequency by round c032 (2*12 ppm*(0.14mv/2.0V) ) ≈ 0.0017 c032 ppm or, 1.7 ppb. So, c032 it seems we have now c032 sufficient adjustment to get about c032 ±1 ppb.  There may be c032 extra to this as could c032 be seen within the code, c032 however that is the essence c032 of the hunt for a c032 exact and correct 10 MHz. c032 (It needs to be famous c032 at this level, the Arduino c032 Nano really has a 16 c032 bit PWM however the most c032 frequency is so low that c032 the required filter would have c032 a really lengthy settling time; c032 too lengthy for this utility.)

c032

c032 As for efficiency, the Nano c032 outputs numerous statistics on the c032 LCD and I sometimes have c032 a imply frequency of 10,000,000.00, c032 a imply error of 0.01 c032 Hz, and an ordinary deviation c032 of this imply of 0.1 c032 ppb. So, it holds the c032 frequency shut to some elements c032 per billion. That is about c032 two orders of magnitude higher c032 than my operate generator can c032 obtain with an exterior reference.

c032

c032 Now turning to the schematic. c032 The PWM averaging circuit could c032 be seen feeding the adjustment c032 voltage to the VCXO (which c032 is the one machine powered c032 by the three.3V supply of c032 the Nano). The circuit after c032 the VCXO is used to c032 sq. up the clipped sine c032 wave of the VCXO output. c032 This squared up, and buffered, c032 sign is the ten MHz c032 sq. wave going not solely c032 to the counter however, to c032 the exterior BNC connectors.  Two c032 of the BNC connectors provide c032 a TTL sign. One other c032 is configured with 2 inverter c032 gates and a 33Ω resistor c032 to create a roughly 50Ω c032 output. A fourth BNC connector c032 provides a buffered 1PPS sign c032 to be used by exterior c032 units.

c032

c032 Beneath the Nano is the c032 GPS module. These could be c032 discovered on the net for c032 round $10 to $12 for c032 the module and antenna. The c032 PCB is proven in c032 Determine 4 c032 and c032 Determine 5 c032 .

c032

c032

c032 Determine 4 c032 PCB of GPS disciplined c032 10 MHz supply.

c032

c032

c032 Determine 5 c032 Picture of GPS disciplined c032 oscillator PCB linked in bundle.

c032

c032 In the course of the c032 schematic is the 32-bit counter c032 (Determine 1). This 74LV8154 (~$1) c032 really has two 16-bit counters c032 that may be configured to c032 a 32-bit counter. The counter c032 design permits for studying the c032 32 bits of counter in c032 4 particular person bytes by c032 addressing the bytes. This requires c032 4 tackle traces and I c032 ran quick on I/O on c032 the Nano so a 74LS139 c032 is used to translate 2 c032 traces from the Nano into c032 the 4 traces wanted on c032 the counter.

c032

c032 The LCD proven in c032 Determine 6 c032  is an ordinary I c032 2 c032 C, 20 character by 4 c032 line LCD. On the backside c032 of the schematic is an c032 easy linear energy provide utilizing c032 a 12V AC/DC adapter and c032 regulating to 8V to energy c032 the Nano and 5V for c032 numerous elements of the circuitry. c032 I used a linear provide c032 to guarantee a quiet Vcc c032 airplane. Lastly, there are 2 c032 LEDs.  One inexperienced LED shows c032 the 1PPS sign. A second, c032 bi-color LED that’s inexperienced when c032 the system has locked tightly c032 to the specified 10 MHz, c032 crimson if not locked but, c032 and alternating crimson/inexperienced if the c032 system is in holdover. Holdover c032 is a state wherein present c032 settings are maintained throughout lack c032 of the 1PPS sign. To c032 detect lack of the 1PPS c032 sign, I enlisted the watchdog c032 timer (WDT).  As a substitute c032 of utilizing the WDT to c032 detect unhealthy executing code points, c032 I set the WDT timeout c032 to 2 seconds and pet c032 (reset) it contained in the c032 1PPS interrupt routine. If the c032 system doesn’t get a 1PPS c032 interrupt, the WDT is just c032 not petted.

c032

c032

c032 Determine 6 c032  Accomplished GPS disciplined oscillator in c032 bundle with LCD.

c032

c032 The code for the Nano c032 was written in C utilizing c032 the Arduino IDE. The code c032 is basically pushed by the c032 1PPS interrupt which rapidly responds c032 by locking within the 32-bit c032 counter worth (a operate of c032 the 74LV8154), clearing the counter, c032 and setting a reset flag. c032 You might have found out c032 that we’re lacking some a c032 part of the following depend c032 as a result of we’re c032 capturing the counter register after c032 which clearing it, permitting it c032 to begin counting from 0 c032 once more. (There may be c032 some finite time between the c032 seize and the clear.) That c032 is true, so the firmware c032 compensates for this latency by c032 including an offset worth to c032 the uncooked counter worth. It c032 turns on the market are c032 16 lacking counts. This has c032 been verified two methods: first, c032 by measuring the time between c032 the seize register sign and c032 the clear register sign on c032 an oscilloscope. Second, I ran c032 a lot of checks with c032 out adjusting the VCXO, utilizing c032 1 second and 100 second c032 captures which had been adjusted c032 by a latency offset worth. c032 The 1 second captures had c032 been repeated 100 instances and c032 added up. If the latency c032 offset is appropriate, the summed c032 up 1 second values (which c032 now comprise 100 latency offsets), c032 ought to equal the 100 c032 second captured studying (which accommodates c032 1 latency offset). Within the c032 working code, the lacking 16 c032 depend is added again in c032 on each learn of the c032 counter.

c032

c032 The principle loop within the c032 code (the Arduino growth system c032 all the time runs the c032 traditional C “Predominant” as a c032 loop) waits for an interrupt c032 flag to be set and c032 when set, it reads the c032 worth of the locked in c032 registers of the 74LV8154. Subsequent, c032 it checks to see if c032 it’s a “affordable” studying and c032 never corrupted (differing from 10 c032 MHz by greater than 12 c032 ppm). Whether it is unhealthy c032 it’s tossed. Whether it is c032 good, it processes the worth c032 in a small boxcar averager. c032 This common is then used c032 to regulate the PWM’s up c032 or down as described above. c032 It then decides what stage c032 it’s in. The primary stage c032 runs 1 second counts and c032 adjusts the VCXO. This rapidly c032 will get us within the c032 ballpark for PWM settings.  This c032 stage runs for 20 seconds. c032 The second stage takes 10 c032 second readings of the depend c032 to fine-tune the PWM settings. c032 That is set to run c032 for five passes or, 50 c032 seconds.  The final stage runs c032 100 second readings and is c032 run repeatedly thereafter, making continuous c032 changes to carry the frequency c032 as temperature or different parameters c032 change the frequency.

c032

c032 Within the final stage, LEDs c032 are set as wanted and c032 statistics are taken after every c032 studying. These statistics could be c032 considered on the LCD and c032 a number of pages ( c032 Determine 7 c032 ) are viewable utilizing the c032 circuit’s pushbutton which is debounced c032 in the primary loop. Statistics c032 embrace instantaneous frequency, common frequency, c032 present ppb error, ppb common c032 error, ppb error commonplace deviation, c032 variety of good readings, variety c032 of unhealthy readings, time of c032 steady lock, max frequency seen, c032 minimal frequency seen, and PWM c032 coarse and fantastic settings.

c032

c032

c032 Determine 7 c032 Statistics on LCD taken after c032 every studying.

c032

c032 Full undertaking info for this c032 may be discovered at, the c032 open-source web site:  c032 https: https://www.thingiverse.com/factor:5188330 c032  (or you may search thingiverse.com c032 for “DamianB2”).

c032

c032 Venture info consists of full c032 KiCad undertaking with schematic, PCB, c032 and PCBA BOM.  Additionally included c032 is a full meeting BOM, c032 Arduino supply code, 3D print c032 information for the enclosure, hyperlink c032 to 3D print information for c032 the GPS module enclosure, art c032 work for the nameplates, numerous c032 notes, and so on.

c032

c032 A final thought: a few c032 of you will have observed c032 that, whereas designing the GPS c032 disciplined oscillator (GPSDO), we have c032 now inadvertently created the essence c032 of a reasonably good frequency c032 counter. We’ll examine this within c032 the subsequent installment.

c032

c032 Damian Bonicatto is an skilled c032 hands-on design engineer with in c032 depth background in analysis, growth, c032 design, implementation and testing of c032 progressive {hardware} and firmware throughout c032 a number of industries. 

c032

c032 Associated Content material

c032

c032  

c032
c032

c032

LEAVE A REPLY

Please enter your comment!
Please enter your name here