[time-nuts] Input filter for data logger

Tom Van Baak tvb at LeapSecond.com
Sun Nov 19 17:52:34 EST 2017

Hi Vlad,

> However, the logger measure it TWICE ! I think its because of that 
> signal form. Here is the output (in microseconds):

Assuming the STM32 is set to trigger on the rising edge, a 2x output will occur if there is bounce from a falling edge. Normally this is not desirable, but there are cases where measuring both rising and falling edge improves resolution. For example I have a version of the picPET that timestamps both edges (this gives you pulse width and duty cycle information). The CNT-91 counter also does this in raw timestamp mode.

> 26.5837255
> 26.23559295
> 26.5941842

> However, it is some "spikes" in the data flow (see above the number 
> "26.23559295", which suppose to be something as "26.58..."). I can't 
> understand the reason for that.

That's a software problem for sure. Do you use interrupts? Or some library code for formatting and output?

> I would assume, some improvement needs to be done for the data logger 
> input. I am using 2N5485 and 74AC04 elements there. Any advises will be 
> appreciated ! Thanks !

It sounds like you have two problems: 1) h/w signal conditioning before the STM32, and 2) a s/w timing issue in your code or in how you use the USART. To separate them, try a clean square wave directly into the STM32 over a range of frequencies from slow to fast to faster than the STM32 can keep up.

BTW, the good news is that your time stamping output looks like the picPET -- http://leapsecond.com/pic -- which means that you can use TimeLab to directly capture and/or display all your data (phase, frequency, adev, etc.).

Note the picPET outputs a h/w event counter along with the timestamp. This can be ignored but the counter helps identify noisy inputs, allows one to distinguish between fast and too-fast inputs, and was very useful during development to validate the accuracy of the device.

As an example, the old PIC I'm using is limited to 125 samples per second (mostly due to RS232 transmit time at 19,200 baud), but with an 8-bit event count you can directly measure frequencies up to 256 times greater (32 kHz). With a 16-bit event counter that number climbs to 8 MHz. All this without a pre-scaler.


More information about the time-nuts mailing list