Hello,
I have been trying to come up with a good clean way to measure PWM input to my device. I need both Frequency and Pulse width.
On the normal ESP32 I was able to use MCPWM but on the C3 and S2 the MCPWM does not exist. I have tried to experiment with RMT and it hasn't went as well as I expected.
I input a PWM signal into my device that never stops. It will vary in frequency and pulse width and that is it.
I have a frequency and Pulse with range that is accepted as normal and anything above or below that needs to be flagged as error so that user can be notified that the input is out of specs.
I have done some digging around trying to find a way to do this with a peripheral so I could avoid the old, Edge Detection Timer tick combo that will be firing interrupt all the time.
Any help would be appreciated, I know someone has found a good solution.
Does anyone have a good solution for measuring a continues PWM signal?
-
- Posts: 20
- Joined: Wed Nov 10, 2021 7:13 pm
Re: Does anyone have a good solution for measuring a continues PWM signal?
I haven't tried with PWM, but I did use RMT peripheral on the ESP32 to receive a multi-channel PPM signal from an RC receiver. I guess with PWM it should be even easier. Can you describe the issues you ran to when trying to use RMT to receive PWM?
-
- Posts: 20
- Joined: Wed Nov 10, 2021 7:13 pm
Re: Does anyone have a good solution for measuring a continues PWM signal?
Thank you for taking time to respond.
I have gotten things working to the point that I can get Pulse Width and calculate Frequency based on period and these are accurate enough.
I have been playing with what is offered in the ESP32s2 RMT peripheral to attempt to get a solid PWM capture unit.
I have came across something that I can't seem to figure out the answer to, here is the scenario
If I have RMT in Receive State and its receiving PWM once the memory is full the FSM State changes to Wait. Once in Wait state I reset the memory index using rmt_rx_memory_reset(RMT_CHANNEL_0) when I check the RMT_CHnSTATUS_REG and I can see that the flag for Memory full is gone.
Though the FSM is still in the Wait state. I can't find anyway to get it out of the wait state. If I change the PWM signal being fed into the device to something that triggers the RMT_CH0_RX_END_INT_ST ISR I can see the FSM in RMT_CHnSTATUS_REG change from Wait to Idle state.
Hope this make sense.
My Orginal idea was to have RMT just running and when I wanted a sample I would just reset the memory index and read from the first Item from the memory on the next time through my Loop. I'm doing about 10 samples per second and averaging.
UPDATE:
Hey ESP_igrr this is the exact same thing I am dealing with
viewtopic.php?t=5168
They had issues with the RX buffer being full causing the RMT to go into Wait state and will not come out.
-
- Posts: 290
- Joined: Wed Sep 05, 2018 6:23 am
Re: Does anyone have a good solution for measuring a continues PWM signal?
rmt_rx_memory_reset(RMT_CHANNEL_0) will reset the whole RMT FIFO memory. It should only be called for once in the initialization stage.
Not sure what esp chips you're working with, ESP32S2? ESP32C3? But please note, ESP32-S2's RMT RX channel doesn't support ping-pong receive. The maximum RMT symbols you can receive for once is 4*64 words. And when it receives more data, I think an error interrupt will be raised. Reseting the pointer is not sufficient, you also need to clear the interrupt.
Check the driver code here: https://github.com/espressif/esp-idf/bl ... #L518-L529
Not sure what esp chips you're working with, ESP32S2? ESP32C3? But please note, ESP32-S2's RMT RX channel doesn't support ping-pong receive. The maximum RMT symbols you can receive for once is 4*64 words. And when it receives more data, I think an error interrupt will be raised. Reseting the pointer is not sufficient, you also need to clear the interrupt.
Check the driver code here: https://github.com/espressif/esp-idf/bl ... #L518-L529
Who is online
Users browsing this forum: No registered users and 203 guests