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

0 Members and 1 Guest are viewing this topic.

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #325 on: November 15, 2019, 03:27:10 pm »
The internal ADC S&H consists of 1k-100k serial resistor and 14pF capacitor (the cap is connected to Vcc/2).
The 14pF capacitor takes over a small chunk of charge off the 1nF capacitor, therefore the voltage drops a little bit.
The drop is tiny, however, like 14/1000.
The 10k "source resistance" is recommended such the 14pF charges up within 1.5 ADC clock cycle fully.
The fact the 1nF discharges so fast indicated an issue, imho.

The voltage at the 1nF drops to 50% BEFORE the actual conversion starts (your last oscope picture).
That tells me there is something of aprox 10k hardwired to the ADC input.

It could be your schottky is shorted or damaged. The 4046 output goes LOW after the pulse lenght measurment stops, and it could be the 1nF capacitor discharges itself immediately through the diode and 3k9 into the 4046 output which is at gnd level at that time..

I still strongly believe the blue voltage must stay at that initial 1V level during the entire 118us long ADC conversion.

PS: Below is a simulation with worst case scenario with the S&H (red) starting acting 10us after end of 4046 pulse measurement, S&H is 30us long, where it charges the internal 14pF via 1k.
The green is the 1V voltage at 1nF capacitor you should see, afaik.
« Last Edit: November 15, 2019, 04:14:40 pm by imo »
 

Offline Dbldutch

  • Regular Contributor
  • *
  • Posts: 205
  • Country: nl
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #326 on: November 15, 2019, 04:14:32 pm »
imo,

You are absolutely correct. It is the Schottkey diode. I concocted another prototype and that worked as it should.
The diode I have been using seemed OK, but is not.

I feel like a totally dumb ass for missing this obvious problem.  :palm:

The discharge now looks pretty linear within the ADC read cycle.
Blue trace is ADC window.

I'l hide in disgrace for a while... |O
« Last Edit: November 15, 2019, 04:16:26 pm by Dbldutch »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #327 on: November 15, 2019, 04:20:03 pm »
Now it looks better, sure :)
But best you will see your yellow 1V voltage such noise free as it is my green voltage in my simulation above..  :P
 

Offline metrologist

  • Super Contributor
  • ***
  • Posts: 2213
  • Country: 00
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #328 on: November 15, 2019, 06:30:53 pm »
That seems like a lot of noise. But I'm glad that is sorted because I was about to dust mine off and take some measurements. I like all the ideas and further insights, though. So a worthy discussion. :-+
 

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 #329 on: November 15, 2019, 07:32:49 pm »
It might make sense but your measurements don't support this theory. The charge drained into the sampling capacitor should cause a downwards step in the voltage at the start of the sampling time. Before and after the curve should be nearly flat. There must be something else going on. For example, schottky diodes have a significant leakage current. Or the pin might have a pull down enabled.

Of course the circuit works, but it is not to spec. The leaked charge causes a significant loss of dynamic range, iow, the tic resolution is far from the claimed 1ns.

PS: It really takes a lot of time to write a reply on the phone. By the time I finished, three other people responded to the same issue  :palm:
« Last Edit: November 15, 2019, 08:27:05 pm by thinkfat »
Everybody likes gadgets. Until they try to make them.
 
The following users thanked this post: iMo

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #330 on: November 15, 2019, 07:39:10 pm »
The noise could be induced by the probe (gnd lead?), as the input of the ADC is an HighZ circuit (10Meg). You would need a fet probe or something like that. Doublecheck the wiring, grounding in a single point (star scheme), short wires, good decoupling (ceramic 100nF capacitors at each chip's Vcc and Gnd, etc.).
The next step is to return all that firmware coefficients back to normal values and test the stuff again..

PS: the voltage drop (as you can see in the above simulation with 1k internal resistor) is rather small, and could be less visible when the internal resistor is at the higher side of the spec (100k) and the drop slope will be slower. Also the 14pF capacitor is connected internally to Vcc/2, my simulation is "worst case" therefore the 14pF is wired to gnd and the "drop is higher". Moreover his voltage drop is covered by noise, which p-p is 30% of the ADC range :)
« Last Edit: November 15, 2019, 07:49:02 pm by imo »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #331 on: November 15, 2019, 08:14:21 pm »
Of course the circuit works, but it is not to spec. The leaked charge causes a significant loss of dynamic range, iow, the tic resolution is far from the claimed 1ns.
Well, if I were a conservative diy maker I would claim 1ns rms..
 

Offline Dbldutch

  • Regular Contributor
  • *
  • Posts: 205
  • Country: nl
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #332 on: November 16, 2019, 01:38:32 pm »
Now that my circuit is finally working as intended, I continued to make the discharge modification.

On the scope shot with the number ending in 3248, you can see the normal operation.
The blue trace is the "probed" ISR surrounding the ADC read cycle.
You can see that the capacitor slowly discharges during the sampling period. This means that due to the almost 200 ns jitter caused by the interrupt latency, there will be differences in the value read by the ADC. Not much, but we're dealing with ppb sensitivity, and I simply assume that every bit helps. Obviously, the discharge is higher than normal because I used a x10 scope probe to see the voltage level.

I modified the ISR a bit further with my proposed solution, and by using a digital port to discharge the capacitor at a planned point, while keeping the voltage level flat during the sampling period. Flat meaning that there will still be some discharge due to leakage and loading but this is as far as we can go with this solution. I used a free port, D10 and connected that through a 1K resistor directly to A0. The 10M resistor is removed from the circuit.

The code changes are as follows:

At the very beginning of the code, I added this:

// add a decharge for C1 after the ADC read cycle
const int decharge = 10; // Decharge pin for C1. Port is toggled between hi-0Z input and output driven low
const int probe = 12; // create a probing signal within the ISR

In setup(), I added this:

  pinMode(decharge,INPUT); // setup the port that will decharge C1
  pinMode(probe,OUTPUT);   // setup the port to allow a probe inside de ISR

Here is the modified ISR:

// Timer1 capture interrupt routine - this runs at rising edge of 1PPS on D8

ISR (TIMER1_CAPT_vect)
{
  timer1CounterValue = ICR1;  // read the captured timer1 200ns counter value
  digitalWrite(probe, 1);     // create a signal to probe the scope
  TIC_Value = analogRead(A0); // ns value
  digitalWrite(probe, 0);     // stop the probe
  pinMode(decharge,OUTPUT);   // change port from hi-Z to output
  digitalWrite(decharge, 0);  // force it to ground to decharge C1
  PPS_ReadFlag = true;        // gives the decharge cycle some time as well
  pinMode(decharge,INPUT);    // revert the port back to hi-Z

}

The "probes" are not there forever, when you're done, you can comment them out.

The next scope shot, ending with 4047, shows the C1 voltage level with the blue trace, and the probe around the ADC cycle in yellow. (channels are reversed from the previous picture) The voltage level is now very flat throughout, even though I still have my x10 probe connected.

Right after the ADC cycle ended, the voltage is forced to ground getting the hardware prepared for the next cycle. The timing works out very well, the discharge during one instruction and with 1K in series only takes a few micro seconds to complete. The 1K is only there because I don't like shortening capacitors, even though the stored energy in this case is minute.

My Isotemp replacement for the Bliley OCXO finally arrived, so I can start the full testing procedure again. Up until now, I had been using my modified FY6600 Waveform Generator as a replacement. You can set the frequency down in the micro Hz to make tuning by hand to the 1PPS possible.

Enjoy,

Paul




 

Offline Miti

  • Super Contributor
  • ***
  • Posts: 1324
  • Country: ca
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #333 on: November 16, 2019, 01:57:32 pm »
Take a look at the yellow trace right before charging the capacitor. It doesn’t start at zero. I think if you don’t hold it low until shortly before the pulse, it will recover a bit and you introduce more errors than you tried to correct.
Fear does not stop death, it stops life.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #334 on: November 16, 2019, 05:48:21 pm »
You have to discharge the 1nF via 1k for a bit longer than 1us.
Below the simulation - green is the 1nF voltage, blue is the 4046, red is the internal ADC's S&H and turquoise is your reset pulse 1us long.
I think based on the ISR source your pulse is even a bit shorter.
The green voltage will not go to zero based on the simulation.
« Last Edit: November 16, 2019, 06:01:04 pm by imo »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #335 on: November 16, 2019, 05:55:49 pm »
10us long reset via 1k will do.
Mind there could be some recharging of the 1nF through the reset pin (needs to be investigated)..
 

Offline Dbldutch

  • Regular Contributor
  • *
  • Posts: 205
  • Country: nl
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #336 on: November 16, 2019, 08:37:13 pm »
Miti, the yellow trace you refer to is the probe signal.
The blue trace is the 1nF cap voltage. The little marker at the very left side of this trace shows the ground level. I didn’t see a residual voltage, even with higher sensitivity settings.

Imo, I do take the simulation serious. Thanks for the effort.
Obviously, I can do two things. One is to lower the 1K to say 470 Ohm or even 100 Ohm or add a few dummy instructions in the ISR code, or do both. I’ll try that tomorrow and report back.

Thank you all for contributing to this nice project.
Sad that Lars is no longer with us to witness the continued activity of his brain child.

Paul
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #337 on: November 16, 2019, 08:49:41 pm »
Fyi- the peak current via 100ohm resistor will be up to 9mA with 1V at 1nF. So I would rather use the 1k and longer reset pulse (10-20us). You are not in hurry, you can afford that delay, imho :)
PPS: ok, this is atmega :), handling the pins takes with digitalwrite() around 3us people say, the pinmode() maybe the same, so you are somewhere around 8-10us with your reset pulse..
« Last Edit: November 16, 2019, 09:41:09 pm by imo »
 

Offline Miti

  • Super Contributor
  • ***
  • Posts: 1324
  • Country: ca
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #338 on: November 16, 2019, 11:25:40 pm »
Aaah, my bad.  :palm:
Can’t you leave the pin as output until all the processing is done?
Fear does not stop death, it stops life.
 

Offline Dbldutch

  • Regular Contributor
  • *
  • Posts: 205
  • Country: nl
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #339 on: November 17, 2019, 08:36:59 am »
I took the easy way, and just added a small delay after the digitalWrite:

delayMicroseconds(10);

I know, you're not supposed to put delays inside ISR's, but in this case it's OK.

As a result, I see no visual change of any charge residuals on the scope, but better be safe than sorry.

Now back to adding my replacement (used) Isotemp 143-141 OCXO.
BTW, this one also has a flaw, there is no V-ref output.
Out of 4 tries, I'm still not very lucky with any of them. 
As it takes about 6 weeks each for delivery, buyer beware.

Enjoy!

Paul
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #340 on: November 17, 2019, 09:03:51 am »
In simulation I see a residual voltage at the 1nF (before TIC measurement starts)
10Meg reset   4mV
1k       reset   9mV

Voltage drop from max voltage till end of S&H on the 1nF with 1k reset
100ns     2.3mV
500ns     8mV
900ns    13.2mV

And the TIC linearity with 1k reset (input pulse width vs. 1nF voltage at the end of S&H)
100ns   129.3mV
200ns   233.2mV
300ns   334.5mV
400ns   433.6mV
500ns   530.5mV
600ns   624.9mV
700ns   717.3mV
800ns   807.5mV
900ns   895.5mV
« Last Edit: November 17, 2019, 09:38:58 am by imo »
 

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 #341 on: November 17, 2019, 09:21:21 am »
In simulation I see a residual voltage at the 1nF (before TIC measurement starts)
10Meg reset   4mV
1k       reset   9mV

Not that it actually matters. As long as the voltage is well below the interesting center zone of around 500mV before the 1PPS pulse arrives, you're good. This is where the software should steer the loop towards anyway.
Everybody likes gadgets. Until they try to make them.
 

Offline Dbldutch

  • Regular Contributor
  • *
  • Posts: 205
  • Country: nl
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #342 on: November 17, 2019, 03:19:25 pm »
imo,

Good job.
I can see a residual of a few mV in reality as well, but it is well hidden in the noise and is dwarfed by the voltage level of the pulse that is used to make the ADC measurement. I have not gone back to measure the condition with the 10M present with this sensitivity.

I concur with thinkfat that this tiny amount will not upset the PI loop much. As a minimum, it's very stable and repeatable, so we could even compensate the ADC value with this residual amount. That's easy to do, but does it make practical sense?

The original task was to remove random jitter effects caused by the interrupt latency in combination with the dis-charge caused by the 10M. I believe that has been fixed now.

BTW, my Isotemp based setup is working (with the above modification), and I got a lock within 10 minutes. Two hours later it's still locked and looking fine.


 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #343 on: November 17, 2019, 05:15:29 pm »
The original task was to remove random jitter effects caused by the interrupt latency in combination with the dis-charge caused by the 10M. I believe that has been fixed now.
You had there something like 200ns p-p. Could you show how it is now?
Picture ending 4416.
The thermal noise of that reset 10Meg @20Hz BW (RC) and 25Celsius is 1.8uV rms (12uV p-p).
The ADC noise I would expect is something like 6LSB p-p, or 6mV p-p, or 6ns p-p.
The source of the 200ns jitter is the interrupt latency, it seems.
Also there is the NEO 1PPS jitter, easily up to 50ns p-p.

PS: the 1nF voltage difference for 500ns input pulse and S&H start jitter of 200ns p-p is 80uV.
« Last Edit: November 17, 2019, 06:14:52 pm by imo »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #344 on: November 17, 2019, 07:30:32 pm »
I've taken Miti's .csv file (replay #286), and calculated the standard deviation of the second column, for the situation when locked properly (1783 of data).
The standard deviation is 7.133ns, or 47.1ns p-p (6.6x).
« Last Edit: November 17, 2019, 08:19:07 pm by imo »
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #345 on: November 17, 2019, 07:40:59 pm »
Just found this nice PCB
https://github.com/Qw3rtzuiop/Lars-GPSDO-PCB

The pict(s) are for the rev1 pcb , not the rev2.

I just ordered a few on JLCPCB

/Bingo

I got my PCB's today ... Now what to use for 1nF cap ??
I don't think i have anything "good" , just some cermic
And maybe i got some Vima Red.

/Bingo
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4790
  • Country: pm
  • It's important to try new things..
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #346 on: November 17, 2019, 08:26:40 pm »
NP0/CG0 ceramic 1nF, people say the TDK are best (see above posts).
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #347 on: November 17, 2019, 08:45:42 pm »
The

C2012C0G1H102J - is not available
Nor is this one : FA28C0G2E102JNU00

And i'll have to do a $50 order @Mouser to get free shipping  :(

Someone have a few ?

Or ... I have some "China" 1nF ceramic disk (The orange ones) , might try one of these for now

Edit: Got some NPO from here
https://www.ebay.com/itm/122455243378


/Bingo
« Last Edit: November 17, 2019, 09:28:11 pm by bingo600 »
 

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 #348 on: November 17, 2019, 08:51:14 pm »
For my own experiments I've now settled on using an actual DAC instead of PWM+filter, mainly for two reasons:

* using a DAC with embedded voltage reference will make the output less dependent on the supply voltage.
* The response of an integrated DAC is way faster than the PWM+filter. I've calculated that, using e.g. the STM32F030's timers to output a PWM, for 16bit resolution I'd end up with a PWM frequency of around 700 Hz and with a low-pass filter with a 0.1Hz cut-off frequency to reach <1mV ripple, while at the same time I'd see a settling time of close to 4 seconds. That's not going to be very responsive.

The structure is going to be similar to what has been suggested already, 10MHz into an HC390 which outputs 500kHz to a TDC7200, which also connects to the 1PPS output from the GPS and uses the 10MHz as reference clock. An STM32F030 to control everything, including an ADS5693R DAC. I decided to add an TLC2272 opamp as a buffer to the output of the DAC, I'll run it in 2.5V output mode and use the opamp to reach the voltage range of the VCO. Which will be, eventually, one of my LPRO-101 Rb standards. I've not yet decided if I'll add a NEO-M8T directly on the PCB or if I'm just going to provide a 1PPS input to the controller.
Everybody likes gadgets. Until they try to make them.
 

Offline Dbldutch

  • Regular Contributor
  • *
  • Posts: 205
  • Country: nl
Re: Lars DIY GPSDO with Arduino and 1ns resolution TIC
« Reply #349 on: November 17, 2019, 09:03:41 pm »
Imo,
I’m currently running a first 24hrs test run for my new oscillator, and I need to activate the probes in the ISR again before I can run the ISR latency measurement again. I’ll do it tomorrow when I have the data collected.

You are obviously more adept and experienced with this, why do you think the latency could be different now? It is based on the 1PPS pulse and the start of the ISR. Nothing changed as far as I can tell. Even though we know that the 1PPS has jitter, that will not show up with this measurement, right?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf