I have an application where I need to capture just the time between low-going pulses on a GPIO. The pulses come from a sensor that is proportional to the event it is monitoring. The pulse width can range from 2.000us to 20.000us, and has a 25ns resolution.
It seems that the RMT peripheral should be able to capture up to a 12.5ns resolution with CLK_DIV=1 (2 would be 25ns), but the number of samples is limited to some buffer that is built into the periphera (64 x 32 for each block)l. I need to capture 300,000 samples at a time (and will need to play those back, but I will leave that for later). There is 2MB of PSRAM in the ESP32S2 that I am using, which is plenty of space to hold the samples.
Is it wrong to believe that it should be possible to start a capture and then copy the 32 bit capture times into the PSRAM? I don't see a hardware based ping-pong where it would generate an interrupt after every buffer switch. I only see an interrupt for every single pulse capture. I know that the PSRAM is theoretically capable of storing the data fast enough, but is 2us too short of a period for handling the interrupt every single capture (even if using assembly code)?
Is there a better solution for this than the RMT?
I would appreciate any feedback on this. Thanks!
Capturing long stream of pulses with RMT?
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Capturing long stream of pulses with RMT?
From memory, the ESP32 cannot do that, but later chips (at least the S3 and C3/C6) have the capability to do ping-pong and the S3 has the capability to DMA directly from RMT to memory.
Re: Capturing long stream of pulses with RMT?
Ok, is it possible to either use the RMT driver or install your own ISR that can move data fast enough to local memory and then to PSRAM? I also need to have some way to know when the buffer is full or maybe move each byte in the ISR?
I might be able to use a ESP32S3 if there are enough GPIOs. I just need a solution that will be able to capture the sensor stream fast enough, and capture a few seconds worth of data.
I might be able to use a ESP32S3 if there are enough GPIOs. I just need a solution that will be able to capture the sensor stream fast enough, and capture a few seconds worth of data.
Re: Capturing long stream of pulses with RMT?
Is there any more details (and examples) on the RMT for the ESP32-S3?
It seems that you can choose between storing to a 'block of memory' and DMA'ing to memory.
Is the driver just doing it's own ping-pong and storing to any memory? Can that memory be the PSRAM memory?
It seems that the latest RMT driver for the ESP32-S3 breaks virtually everything in the previous driver structures. Is the new driver more efficient? I know that the RMT transmit (for any ESP32 version) can easily handle sub-microsecond output pulses (RGB LEDs are a good example of this). Can the receive handle pulses as short as 1.000us? My input signal has a 1.000us high-low-high pulse, with the next pulse occurring sometime later that represents the actual sensor time (ie. a 4.250us sensor time would be a 1.000us high-low-high pulse followed by 3.250us duration of high until the next pulse).
Maybe RMT is not the way to do this? I just need to measure the time between every low going pulse and store those times, really as a 16 bit value since I will never see anything larger than 20.000us.
It seems that you can choose between storing to a 'block of memory' and DMA'ing to memory.
Is the driver just doing it's own ping-pong and storing to any memory? Can that memory be the PSRAM memory?
It seems that the latest RMT driver for the ESP32-S3 breaks virtually everything in the previous driver structures. Is the new driver more efficient? I know that the RMT transmit (for any ESP32 version) can easily handle sub-microsecond output pulses (RGB LEDs are a good example of this). Can the receive handle pulses as short as 1.000us? My input signal has a 1.000us high-low-high pulse, with the next pulse occurring sometime later that represents the actual sensor time (ie. a 4.250us sensor time would be a 1.000us high-low-high pulse followed by 3.250us duration of high until the next pulse).
Maybe RMT is not the way to do this? I just need to measure the time between every low going pulse and store those times, really as a 16 bit value since I will never see anything larger than 20.000us.
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Capturing long stream of pulses with RMT?
Examples are available within ESP-IDF. The new driver is indeed quite different from the old one, but this needed to happen in order to support things like DMA; I don't know if the old driver supports that. Resolution of RMT Rx is the same as RMT Tx; with an 80MHz APB bus, you should be able to capture pulses down to 12 ns if you configure the hardware to do so.
Re: Capturing long stream of pulses with RMT?
Yeah, it seems that the hardware has a max resolution of 12.5ns which is double of what I actually need. I don't really need DMA, and I doubt that will work for storing directly into PSRAM anyways. I just need a simple way to measure the time between a lot (300K) fast low-going pulses and store those times. PSRAM is needed because of the shear number of samples that need to be stored.
Who is online
Users browsing this forum: Assasinsareus, Google [Bot] and 75 guests