How to calculate thresholds of RMT demodulator?

User avatar
nvtby_espf
Posts: 15
Joined: Wed Mar 03, 2021 1:11 pm
Location: Belarus
Contact:

How to calculate thresholds of RMT demodulator?

Postby nvtby_espf » Sun Apr 25, 2021 11:43 pm

Hi,
There's a question (not a problem) about ESP32-S2 RMT demodulator. I have created a learning example for it, it works well, but I met with a difficulty to explain two parameters. Their values were found experimentally because I have no guess how they work.
Parameters are located in RMT_CHn_RX_CARRIER_RM_REG register and named as RMT_CARRIER_LOW_THRES_CHn and RMT_CARRIER_HIGH_THRES_CHn. Maybe somebody has a picture how do these parameters work.
My example isn't trivial but simple. One RMT channel generates single modulated series. Next channel reads it and decodes. Also a PCNT channel counts pulses on same pin just to make sure everything works as expected.
Parameters:
APB clock in use, divider 16 makes 80/16=5 MHz 200 ns pulses.
Transmitter modulates with narrow peaks. Carrier: Low=96 (12.5*96=1200 ns) High=32 (12.5*32=400 ns), modulation at V=1, data only, idle output with V=0.
Sequence (index=hex): 0=8030 1=0010 2=8040 3=0000 (see attached picture from scope, similar encycled series). It makes a 200*48=9600 ns high signal, modulated as 9600/1600=6 pulses. Then 200*16=3200 ns low signal, as placeholder of 3200/1600=2 pulses. Terminating high signal is 200*64=12800 ns long, made of 12800/1600=8 pulses.
Receiver is able to work at next parameters:
RMT_CARRIER_LOW_THRES_CHn = 9, valid range 8-9
RMT_CARRIER_HIGH_THRES_CHn = 10, valid range 10-99
Result sequence (index=hex): 0=8032 1=0010 2=8040 3=0000
PCNT Unit 0: status=0x00 counter=+14
As you can see result is almost perfect. First "high" was found two units longer, ,not a primary question here. The question is, how can I calculate RMT_CARRIER_*_THRES_CHn parameters based on transmitter parameters? I really got stuck.
BTW, when modulator and demodulator were turned off, output sequence was full match to input sequence.
Thank you for reading long story.
IMG_20210426_012439-C.jpg
IMG_20210426_012439-C.jpg (1.09 MiB) Viewed 1721 times

Who is online

Users browsing this forum: No registered users and 35 guests