I would not mimic Lars' code with your design. You may do all in double precision to be on the safe side with math. Also Lars is using a low pass in the DAC with much lower BW (yours DAC low pass is 147Hz, btw). Start with a PI regulator off a standard library and tune it for your system. It could be you have to smooth the TIC measurements first, and then pass the result to the PI loop (with say 10-100secs period). With average 40ps/sec drift of your rubidium the DAC's value changes should be rather smallish too.
PS: As I wrote above your NEO outputs data at 10Hz afaik, with 10Hz 1PPS you may achieve better statistics, imho.
That's exactly what I'm doing now. For the first test I have just taken Lars' PI loop and also the averaging filters, but I noticed quickly that there are e.g. terms in the averaging filter that didn't seem to have much merit, and then I looked at the PI loop computation itself and it seemed a little odd and it was a bit hard to match it with what you get from control theory textbooks. Frankly, I didn't understand it and since Lars' is no longer with us I cannot ask. Not a good starting point for experiments.
Now I've implemented a "textbook" PID control loop, using this formula from the wikipedia page:
It's nice because I get to set the time constant for the integrator (T
i) directly in seconds. Now I need to figure out a proper gain and boundaries for the anti wind-up of the integrator. This type of controller needs a bias term, which I have set to the middle of the DAC range for now, and the integrator is what adjust for frequency offset. So the anti wind-up has to be chosen with some sense to not have a huge overshoot if you start from a large phase error and at the same time deal with LPRO's that are not well calibrated. My own one I have carefully set to 10MHz with the C-Field bias pot, looks like I'm still a little off from center position but it's not a huge amount and the integrator is coping with it.
I've also switched to using "double" instead of "float" and the "remainder" trick.
PS: if the DAC range is too coarse, I can solve that in the analog output stage. I have a second OP that I could use to create a virtual ground to bias the output amplifier. I've meanwhile checked the pull range of the LPRO, it's indeed 4ppb rather than the 3ppb advertised in the user manual.
PPS: DAC low-pass filter - there's a 100
/ 10nF RC low-pass at the OP output. That matches with the 147Hz.