The sample rate depends on how much work I want to do to optimize the code. It also depends on if we're talking about maximum continuous sample rate, i.e. streaming data back to the PC, vs maximum burst sample rate where the samples are just being buffered in RAM and transferred to the PC after the experiment is over. (It's interesting to note that in going through the documentation of my CNT-90 yesterday, it appears only to support the latter, which surprised me.)
For burst sample rate, the code I've written today has a dead time in between samples of probably about 500 nanoseconds (i.e. a sample rate of about 2mhz), which is the time it takes for the interrupt handler to fire and run a couple lines of code to copy the current counter value from the capture register into RAM. However, with some tricks such as using DMA to have the hardware transfer the timestamp value, the dead time between samples could probably be reduced even further, maybe 3x? The stm32g4 devices have 128K of RAM which suggests about 16kilosamples can be buffered in burst mode. The comparatively slow part is transferring the data out to the host. Right now, the code's fast-path just writes timestamps to a RAM buffer, and then a relatively slow process comes behind every 50ms and drains that buffer out to the serial port. This is limited by, at least, the speed of the serial port, which I'm currently running at 1Mbps. There are various ways to improve this (e.g. transfer binary samples instead of ASCII text) but it's all a tradeoff of performance vs ease of use. I like emitting ASCII because it's trivial for anyone on any host OS to read the output without needing any special software. But, this limits the transfer rate both by increasing the amount of serial data transferred and increasing the load on the microcontroller for doing math conversions and ascii text formatting. Right now my prototype code is sort of a hybrid; it handles bursts by buffering, and continuously (but more slowly) drains the buffer out to the PC over serial. So it means you could, for example, have a burst of 1,000 events in a millisecond, followed by a couple seconds of dead time, then repeat - and it would stream all those events back to do you all day long. -Jeremy On Wed, Feb 17, 2021 at 7:44 AM Dan Kemppainen <[email protected]> wrote: > Hi, > > I'm curious how this turns out. Please keep us updated on your progress. > So, what is the maximum sample rate you can record at? > > One thought to look for a lower frequency with less jitter than a signal > generator is TVB's PicDiv dividers. You could easily take the RB down to > something lower that you is within your sample rate. > http://www.leapsecond.com/pic/picdiv.htm > > If you ask nice, he has other source code for different divide ratios > posted on his site. In my case, I needed to take 10Mhz down to 250Khz > for testing a time stamping counter. It worked very well for this > purpose, and was cheap and easy. > > Dan > > > > > On 2/17/2021 4:59 AM, [email protected] wrote: > > Date: Tue, 16 Feb 2021 23:48:12 -0800 > > From: Jeremy Elson<[email protected]> > > To: Discussion of precise time and frequency measurement > > <[email protected]> > > Subject: Re: [time-nuts] The amazing $5 timestamper with 6ns > > resolution (next stop: 184ps) > > Message-ID: > > <CAKufN8UdmWh9oTE4pZ=EY57+sxh2JSc4oD7gSw3w7Mt6FS= > [email protected]> > > Content-Type: text/plain; charset="UTF-8" > > > > I've used jlcpcb before, but I have to admit I'm more of a pcbway guy. > I've > > had a lot of good experiences with them, and their assembly special ($30 > > for qty 10) plus LCSC parts is very cheap, I"ve had good luck with them. > > > > You're right - the test I did conflated more than one thing. It was not a > > pure test of my timestamper so my next attempt once I get some time will > be > > to use my Rb xo to run both the clock on my timestamper and a signal > > generator and then see really how much jitter there is. Of course, there > > will be some question if the jitter is coming from the timestamper or the > > signal generator, but I suppose the best case is that there is not jitter > > in either one! I'll keep the list updated as I do more experiments. > > > > Cheers! > > > > -Jeremy > > _______________________________________________ > time-nuts mailing list -- [email protected] > To unsubscribe, go to > http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com > and follow the instructions there. > _______________________________________________ time-nuts mailing list -- [email protected] To unsubscribe, go to http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com and follow the instructions there.
