Clock tolerance IMP003?

I want IMP003 to measure the time between two rising edges, approximately 1 ms after each other. How do I measure the time and what is the expected error?

Bit more info needed; when do these arrive? Are there only two, or you need to measure time between any two in a stream? What’s the range of times between edges that you need to capture?

Short version: there is no API to do this in hardware, so doing this in squirrel will not produce consistent answers (eg: if a network packet arrives between pulses, you likely won’t get an accurate answer as the CPU is doing other things).

You can work around this by using things like SPI or the sampler, but the sample rate (and memory required) are dependent on the exact characteristics of the data you’re sampling and what your required accuracy is.

We use an accelerometer that has +/-10% clock tolerance. As a result the actual sample rate may be 10% off and we have a 10% error in the frequency that we try to measure. I want to program the accel so that it creates a 50us pulse on it’s interrupt pin every time a new sample is ready (at 800Hz data rate). I want to connect this pin to an IMP input. This way I can check what the actual sample rate is and correct for it in our cloud based application. I would like IMP to measure the time between two rising edges (about 1.25ms apart). What do you recommend?

An option may be to use pin.configure(PULSE_COUNTER, float, integer). In IMP003 what pins support this function?

PinM supports pulse counting on imp003. We’ll get that added to the pin mux page.

Thanks. How accurate is pulse count? How does it work internally?

The pulse counter is very accurate (well, the imp003 internal clock is 10ppm, and the counting is done in hardware so is essentially tied to the accuracy of the 26MHz internal xtal).

The biggest source of inaccuracy may just be the sampling window. The longer you sample to get the count, the less this will affect things. Give it a try.

Sounds like a great plan!