Author Topic: Lars DIY GPSDO with Arduino and 1ns resolution TIC  (Read 288382 times)

0 Members and 1 Guest are viewing this topic.

Offline thinkfat

  • Supporter
  • ****
  • Posts: 2152
  • Country: de
  • This is just a hobby I spend too much time on.
    • Matthias' Hackerstübchen
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1225 on: February 17, 2024, 11:19:33 am »
Johnny, I will be interested in hearing how much improvement a Sparkfun ZED9T makes over an M8T. My own Lars build (Murray Greenman, ZL1BPU, display variant), is at the limits of what I can measure in terms of short term stability.

If you're interested in short-term stability of oscillators, you can do a lot with the "tinypfa". For cheap.

https://www.tinydevices.org/wiki/pmwiki.php?n=TinyPFA.Homepage

Everybody likes gadgets. Until they try to make them.
 
The following users thanked this post: Solder_Junkie, Johnny B Good

Offline Johnny B Good

  • Frequent Contributor
  • **
  • Posts: 818
  • Country: gb
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1226 on: February 17, 2024, 01:32:54 pm »
@Solder_Junkie

 Whilst I'd love to answer your questions in detail and the information is relevant to any design of DIY gpsdo project, I think it would be better to start a separate topic thread rather than completely hijack this one (I can post a link here for anyone interested), However, as a 'teaser', assuming you haven't already seen this YouTube video, have a look here

@thinkfat

 Thanks for the links to the TinyPFA. ISTR Solder_Junkie mentioning this gadget a month or two back. I checked it out but being the cheapskate that I am (says he who blew 250 smackers on that Sparkfun module some 14 months ago :o) I was looking for the cheapest option and gave up on making sure of getting the exact right version to convert. However, money isn't everything so, for the sake of my much put upon SDS1202X-E, I'll pick one of those sources in the list whether pre-loaded or not with the SW. I've been hankering after a means to record the data for a while now anyway (you know how it is - not enough round tuits).

John
 
The following users thanked this post: Solder_Junkie

Offline iMo

  • Super Contributor
  • ***
  • Posts: 4803
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1227 on: February 17, 2024, 01:45:45 pm »
..
I haven't experimented with increasing the smoothing caps on the oscillator Voltage control line, I note that Murray used 22uF caps against Lars using 4.7uF. I use 10uF. If you refer back to the James Miller "Simple" GPSDO, James uses a 160K resistor and 100uF cap to smooth the control Voltage line and achieves around +/-5 parts in 10^11 over a 10 second period. Maybe a larger capacitor would work just as well as going to a more expensive GPS module?..

The precise finetuning of the filter is not an easy task, imho. I made an excel tool, trying to ease the filter design for Miller's XOR based GPSDO in past, posted here.
https://www.eevblog.com/forum/projects/gpsdo-with-xor-phase-comparator-control-loop-filter-design/msg3458070/#msg3458070
 

Offline Johnny B Good

  • Frequent Contributor
  • **
  • Posts: 818
  • Country: gb
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1228 on: February 17, 2024, 03:23:13 pm »
Johnny, I will be interested in hearing how much improvement a Sparkfun ZED9T makes over an M8T. My own Lars build (Murray Greenman, ZL1BPU, display variant), is at the limits of what I can measure in terms of short term stability.

If you're interested in short-term stability of oscillators, you can do a lot with the "tinypfa". For cheap.

https://www.tinydevices.org/wiki/pmwiki.php?n=TinyPFA.Homepage

 I've just ordered one from Mirfield Electronics in the UK. :)
John
 

Offline Solder_Junkie

  • Frequent Contributor
  • **
  • Posts: 338
  • Country: gb
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1229 on: February 17, 2024, 03:26:52 pm »
Martin (G3ZXZ) of Mirfield is really good to deal with.
 
The following users thanked this post: Johnny B Good

Offline bogdanbrudiu

  • Newbie
  • Posts: 2
  • Country: ro
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1230 on: April 29, 2024, 04:01:45 pm »
Can you please help me? I am stuck and don't know what I did wrong...
If I disconnect the TIC from ADC0 and measure the TIC output it looks like this
2151925-0
If I connect it to ADC0 the entire signal goes up 1V and looks like this
2151931-1

When connected the ADC0 reading is 1023 if I disconnect it the reading is ~200 and the console shows 10MHz?

Type f1 <enter> to get help+info
time    ns      dac     temp    status  diff_ns filtX10 tc      filt    timer1  temp1
1       Missing 10MHz?  32768   25.8    WarmUp  1013    10230   32      1       46291   239     Five minute averages: TIC+DAC+temp
1       Missing 10MHz?  32768   25.9    WarmUp  0       10230   32      1       41521   238     Now acquiring value: 0
1       Missing 10MHz?  32768   25.9    WarmUp  0       10230   32      1       6677    237
1       Missing 10MHz?  32768   25.8    WarmUp  0       10230   32      1       41333   240     0       0       0       0.0
1       Missing 10MHz?  32768   25.7    WarmUp  0       10230   32      1       34487   240     1       0       0       0.0
1       Missing 10MHz?  32768   25.9    WarmUp  0       10230   32      1       6018    239     2       0       0       0.0
1       Missing 10MHz?  32768   25.7    WarmUp  0       10230   32      1       27025   241     3       0       0       0.0
1       Missing 10MHz?  32768   25.8    WarmUp  0       10230   32      1       40620   238     4       0       0       0.0


Is this the way the signal should look like? somehow I would expect it would slowly charge and based on how much it charged you know the delta... And since the TIC offset is between 200 and 1020ns I would expect the slope would be over this period....
« Last Edit: April 29, 2024, 06:37:25 pm by bogdanbrudiu »
 

Offline Solder_Junkie

  • Frequent Contributor
  • **
  • Posts: 338
  • Country: gb
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1231 on: May 01, 2024, 07:39:28 am »
Check that you have connected the TIC (4046) correctly, I think one of the diagrams I saw had the pins wrongly marked.

See, including the "as built" pdf: https://www.qsl.net/g4aon/gpsdo/

SJ
 

Offline Miti

  • Super Contributor
  • ***
  • Posts: 1331
  • Country: ca
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1232 on: May 01, 2024, 03:14:07 pm »
Check your ground, see my posts starting at reply #44, I had a similar issue. Check the offset voltage at the ADC input. My first logs are very similar to yours.

Cheers,
Miti
Fear does not stop death, it stops life.
 

Offline Solder_Junkie

  • Frequent Contributor
  • **
  • Posts: 338
  • Country: gb
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1233 on: May 01, 2024, 03:19:22 pm »
As per the reply from Miti, I added a braid from the Arduino ground to the TIC ground. I cannot remember if it made a difference or not.

SJ
 

Offline Clemgill

  • Contributor
  • Posts: 11
  • Country: fr
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1234 on: May 17, 2024, 05:12:56 pm »
Hi,

I am trying to understand Lars's code and needs confirmation of my findings related to the TIC measurement section.

The code says that conversion ADC acquisition starts at rise of PPS:
  ISR (TIMER1_CAPT_vect)
{
  timer1CounterValue = ICR1;        // read the captured timer1 200ns counter value
  TIC_Value = analogRead(A0);        // ns value
  PPS_ReadFlag = true;
}

Time needs to be given for the voltage to build-up on the 1nf capacitance. at least 500ns and max 1000ns
The RC time constant is 3,9E3*1E-9 = 3,8E-6s = 3,6 microseconds (= time to reach to 63% of the maximum of 5volts)
Lars limits the full range to 1,1volts (22% of 5volt), so roughly consistent with the 1000ns max ?

According top the ATmega328P datasheet :
The interrupt execution response for all the enabled AVR® interrupts is four clock cycles minimum. After four clock cycles the program vector address for the actual interrupt handling routine is executed. During this four clock cycle period, the program counter is pushed onto the stack. The vector is normally a jump to the interrupt routine, and this jump takes three clock cycles

Which sums up to 7 cycles before starting to execute the Interrupt vector code (when acquisition of the timer1CounterValue takes place).
ADC measurement start after 9 cycles from PPS (two more read cycle to capture timer1).
With a clock at 16Mhz (62,5ns) the corresponding latency would be 562ns => Not enough...
The ADC conversion time is said to take 13 conversion cycles (Table 23-1.), but the sample and hold takes place only after the first two conversion cycles (Figure 23-6).
With an ADC clock of 200kHz, one conversion cycle = 500ns... so time lag to charge the capacitance is mostly found in the conversion process.

Does that make sense ?
Thx,
Gilles.



« Last Edit: May 17, 2024, 06:29:30 pm by Clemgill »
 

Online PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1591
  • Country: au
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1235 on: May 17, 2024, 09:57:37 pm »

According top the ATmega328P datasheet :
The interrupt execution response for all the enabled AVR® interrupts is four clock cycles minimum. After four clock cycles the program vector address for the actual interrupt handling routine is executed. During this four clock cycle period, the program counter is pushed onto the stack. The vector is normally a jump to the interrupt routine, and this jump takes three clock cycles

Which sums up to 7 cycles before starting to execute the Interrupt vector code (when acquisition of the timer1CounterValue takes place).
ADC measurement start after 9 cycles from PPS (two more read cycle to capture timer1).
With a clock at 16Mhz (62,5ns) the corresponding latency would be 562ns => Not enough...
The ADC conversion time is said to take 13 conversion cycles (Table 23-1.), but the sample and hold takes place only after the first two conversion cycles (Figure 23-6).
With an ADC clock of 200kHz, one conversion cycle = 500ns... so time lag to charge the capacitance is mostly found in the conversion process.
You would need to check the assembler to get the exact timing. There could be calls and parameter loads and possible register saves in the interrupt preamble.
If you wanted to check you could toggle a pin right at the analog-start line.
 

Offline MIS42N

  • Frequent Contributor
  • **
  • Posts: 512
  • Country: au
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1236 on: May 18, 2024, 05:43:13 am »
With an ADC clock of 200kHz, one conversion cycle = 500ns... so time lag to charge the capacitance is mostly found in the conversion process.

Does that make sense ?
Thx,
Gilles.
The ADC has very little to do with the charging of the 1nF capacitor. It starts charging when the 1PPS edge triggers the HC4046 on and finishes charging when the 1MHz from HC390 turns it off. So the charging time is all hardware controlled. It then slowly discharges through the 10M resistor until the next 1PPS. I am working from the circuit posted at the start of the thread. I haven't looked further, I'm assuming this is still the circuit people use.

It is only required that the ADC starts after the 1nF charging, and not long after so very little discharge has occurred. The start time is estimated as you outlined, except with a 200kHz ADC clock the sample and hold will take place a minimum of 5µs after requested, not 500ns.

So the delay in the interrupt routine is not a worry.

FYI the time to acknowledge an interrupt is 4 to 7 CPU cycles (unless there are other interrupts being processed in which case it will take longer). The reason is the CPU will complete whatever instruction is in progress. Many instructions complete in 1 cycle so the delay is 4 cycles. Some instructions (call, return for example) take 4 cycles so dependent on what part of the instruction the CPU is working on, the delay can be 4 to 7 cycles.
 
The following users thanked this post: thinkfat

Offline Clemgill

  • Contributor
  • Posts: 11
  • Country: fr
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1237 on: May 18, 2024, 08:44:06 pm »
Thanks PCB.Wiz and PIS42N for your answers,

Sorry for the mistake with wrighting 500ns, I meant 5000ns. The conversion time is indeed dominating.
Moreover I converted the compiled HEX file to assembly code and found the start of the interrupt vector  (TIMER1_CAPT_vect)
There are many instruction taking place before the actual "analogRead(A0)" (including 15 "push", and other 2 cycles instructions) summing up to 45 cycles = 2812ns..... even before taking into account the conversion clocks.
 

Offline Clemgill

  • Contributor
  • Posts: 11
  • Country: fr
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1238 on: Yesterday at 07:37:30 am »

Another question regarding the "TIC_value" moving average filter.
from the code :
TIC_ValueFiltered = TIC_ValueFiltered + ((timer_us*1000 + TIC_Value) * filterConst - TIC_ValueFiltered + (filterConst/2)) / filterConst; 
I understand that this is setting the "TIC_ValueFiltered" to  the mean of "TIC_Value * filterConst" (when timer_us = 0)
But why is the term (filterConst/2) added ?

 

Offline Clemgill

  • Contributor
  • Posts: 11
  • Country: fr
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #1239 on: Yesterday at 05:37:59 pm »
But why is the term (filterConst/2) added ?

I guess I found the answer to my question: this is to enhance the rounding
Integer computation rounds by cutting the fractional part of the result (INT function in excel)
Better rounding can be achieved by rounding to the closest integer.
This is what adding 0,5K does :
A   A+0,5   INT(A)   INT(A+0,5)
2,4       2,9       2            2
2,6       3,1       2            3
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf