Hi,
For my frequency calculation application, ranging from 0.1Hz to 50KHz, running on ESP32, I am using a PCNT(Pulse counter) module to accumulate pulse and a 1-millisecond software timer to monitor the sampling period.
Complication : I am capturing the time stamp and start sampling period at the start of first-falling edge of pulse-train and upon elapse of sampling-period, flagged by s/w timer of 1ms, and then calculating frequency. However the pcnt_get_counter st some instances give +/-x counts where x -ranges from 5-50ish. To which there is error in calculate frequency.
P.S. : For frequency below 5KHz the mentioned complication is not observed
Till now I have confirmed that the s/w timer 95% of times is accurate but most of the time pcnt counts retrieved from API are not correct
I am planning to use high resolution esp_timer in place of software timer
Welcome your help !
PCNT module for esp32
Re: PCNT module for esp32
I would do the pulse "gating" completely in hardware to avoid the unpredictable delays and jitter of interrupt code. I haven't used the PCNT peripheral, but isn't it possible to enable/disable the counting using the CTRL input - maybe you could generate a 1 ms long pulse using a timer / PWM / SPI / whatever and loop it back to the CTRL input and then read the counter value after the pulse has occurred?
Who is online
Users browsing this forum: Baidu [Spider] and 174 guests