Very accurate timer implementation
Very accurate timer implementation
Hi,
I'm trying to detect some fast events.
I have two signals from two sensors. The signal looks like this :HIGH 60-130 microseconds (us), LOW 0-2700 microseconds (us), HIGH 0-20 microseconds (us). I need to measure the length of each event as accurate as possible.
What is the best approach?
Thank you!
I'm trying to detect some fast events.
I have two signals from two sensors. The signal looks like this :HIGH 60-130 microseconds (us), LOW 0-2700 microseconds (us), HIGH 0-20 microseconds (us). I need to measure the length of each event as accurate as possible.
What is the best approach?
Thank you!
- Attachments
-
- signal.png (24.51 KiB) Viewed 11837 times
Re: Very accurate timer implementation
My gut is saying I would look at the RMT peripheral functions. This appears to be able to record pulse transitions down to 12.5 nanoseconds (1/80Mhz). See:
http://esp-idf.readthedocs.io/en/latest ... s/rmt.html
http://esp-idf.readthedocs.io/en/latest ... s/rmt.html
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Very accurate timer implementation
Hi kolban,
Thanks you for answering my question.
I will go with your call and get back with the results. I had some trouble with timer intrerupts given minimum prescaler value of 2 (80/2).
Do you think using the I2s infrastructure DMA capable to read this signal would be another viable alternative?
Thanks
Thanks you for answering my question.
I will go with your call and get back with the results. I had some trouble with timer intrerupts given minimum prescaler value of 2 (80/2).
Do you think using the I2s infrastructure DMA capable to read this signal would be another viable alternative?
Thanks
Re: Very accurate timer implementation
You could probably hack something up by injecting a dummy reference clock for I2S to sample against.holopaul wrote: Do you think using the I2s infrastructure DMA capable to read this signal would be another viable alternative?
The RMT peripheral is significantly better suited to this, though - I can't think of any way that I2S could be made to outperform it.
RMT is designed to solve almost the exact problem you have, and it's also based on DMA-like functionality so measurement accuracy is not limited by interrupt latency - the pulse timings are written to a memory block, and then an interrupt fires so you can retrieve them.
Re: Very accurate timer implementation
Gentlemen thank you for your time. This approach looks very promising and seems like i have some reading and testing to do.
Re: Very accurate timer implementation
Hello,
I did some reading about RMT and it looked too good to be true. And if i'm not mistaking, it is exactly that way.
The main problem is the 16 (or 15) bit resolution. My signal train is exactly 8.3 ms(120 Hz) long. I really need the 12.5 ns (80MHz) granularity because the timebase of my signal is 20.9 ns / tick (48MHz). But at this speed i can't measure the whole train. I need to measure as accurate as possible only t0 and t1. Is there another option to measure this? Thank you
I did some reading about RMT and it looked too good to be true. And if i'm not mistaking, it is exactly that way.
The main problem is the 16 (or 15) bit resolution. My signal train is exactly 8.3 ms(120 Hz) long. I really need the 12.5 ns (80MHz) granularity because the timebase of my signal is 20.9 ns / tick (48MHz). But at this speed i can't measure the whole train. I need to measure as accurate as possible only t0 and t1. Is there another option to measure this? Thank you
- Attachments
-
- ir-signals-timing.jpg (9.46 KiB) Viewed 11593 times
Re: Very accurate timer implementation
If you have 12.5ns and 32767 samples per entry so max 409us per entry so your total signal should use max 20 entries
Re: Very accurate timer implementation
@WiFive, I'm afraid I don't quite follow you. Please explain. Also RMT is in RX mode. I cannot modify the signal. thanks
Re: Very accurate timer implementation
Oh I see you are saying the idle threshold can't be more than 819us.
What about mcpwm capture?
What about mcpwm capture?
Re: Very accurate timer implementation
Okay, i didn't know about this one, thanks. I'll give it a try. But isn't this based on regular intrerupts? The good thing is that the timer is 80Mhz. Have you tried it for capturing signals?
Who is online
Users browsing this forum: No registered users and 76 guests