RMT for accurate timing measurement

okebbeko
Posts: 1
Joined: Wed Jan 03, 2018 6:07 pm

RMT for accurate timing measurement

Postby okebbeko » Wed Jan 03, 2018 7:38 pm

Hi,

I have to measure accurately a square wave signal (30-100Hz) frequency. Ideally I need to measure in a continuous way. At the moment I am using the RMT module in input measurement mode in the following way:
-setup to measure input pulses with threshold higher than maximum measured pulse length, so it will never detect idle
-start measurement
-wait around 10 full period
-stop measurement
-read out measured data and average low and high pulse times to calculate frequency

My issue is that the code in a standalone way works most of the time, but sometimes stops and no matter what I do with the peripheral (start again,..) it will not measure again, stops at some point then the measurement values are not updated.
If I use the code as part of the main application it never measures continuously, stops after the first cycle or so.

Init code:

Code: Select all

void nec_rx_init()
{
   rmt_config_t rmt_rx;
    rmt_rx.channel = RMT_RX_CHANNEL;
    rmt_rx.gpio_num = RMT_RX_GPIO_NUM;
    rmt_rx.clk_div = RMT_CLK_DIV;
    rmt_rx.mem_block_num = 1;
    rmt_rx.rmt_mode = RMT_MODE_RX;
    rmt_rx.rx_config.filter_en = false;
    rmt_rx.rx_config.filter_ticks_thresh = 100;
    rmt_rx.rx_config.idle_threshold = 0xFFFF;
    rmt_config(&rmt_rx);
    rmt_driver_install(rmt_rx.channel, 10, 0);
}
Loop measurement code:

Code: Select all

	rmt_rx_start(RMT_RX_CHANNEL, 1);
	delay(250);
	rmt_rx_stop(RMT_RX_CHANNEL);
	rmt_get_status(RMT_RX_CHANNEL, &stat);
I also read out the status of the RMT, which is:
-if it works I get 0x300000C or 0x3000000D status
-once it stops working I get 0x4000000

There is no description of the status data in any documentation neither all of the registers for the RMT.
Does anybody know how I can measure accurately periods?
What is the issue with the code or the driver? Is there any proper full register description?

Thanks

ESPpeter
Posts: 4
Joined: Mon Dec 04, 2017 12:49 pm

Re: RMT for accurate timing measurement

Postby ESPpeter » Sun Feb 25, 2018 3:29 pm

"Is there any proper full register description?"
Here:
http://arduinouser.hu/esp32/ESP32_RMT_R ... ummary.pdf

Who is online

Users browsing this forum: No registered users and 137 guests