Using PCNT to Measure Frequency on Two Inputs

MotoDan
Posts: 2
Joined: Fri Feb 18, 2022 3:41 am

Using PCNT to Measure Frequency on Two Inputs

Postby MotoDan » Wed Feb 23, 2022 7:24 pm

I am using the well established ESP32 Frequency Meter code (https://www.esp32.com/viewtopic.php?t=17018) as a base to modify for measuring the frequency of a second input, but am having some difficulty in processing the second channel. My approach is to use a separate PCNT unit for each input, share the 1 second timer control and accumulate the counts using two interrupts. I may not have the ISR handlers configured correctly. The sample code uses portMUX_TYPE timerMux for synchronizing. Not sure if I need two instances of this or not. I've proven that I can measure frequency on the two chosen inputs, just not together. I've tried using inputs as low as 1 kHz for testing even though the single channel counter will work up to 40 MHz.

heinzv
Posts: 7
Joined: Fri Sep 20, 2019 7:22 pm

Re: Using PCNT to Measure Frequency on Two Inputs

Postby heinzv » Fri Apr 07, 2023 7:39 am

I have the same use case/requirement and have taken also your example (as well as the original source of your example) and facing the same problem. Only the second input GPIO 12 is working.
I also have not yet understdood what need to be implemented twice to measure two frequencies.
I found this code which I think works with two counters and threshold) but not frequence measure, just counter and threshholds for counters.
Maybe this could lead us to a combined solution of dual PCT + frquency measurement?

https://github.com/mikegofton/ESP32PulseCounter

foryesp
Posts: 1
Joined: Mon Jan 15, 2024 8:16 pm

Re: Using PCNT to Measure Frequency on Two Inputs

Postby foryesp » Mon Jan 15, 2024 8:43 pm

Hi,
Has anyone been able to run 2 counters at frequencies higher than 10kHz?
For me, multPulses on the second unit is always 0?

Who is online

Users browsing this forum: Baidu [Spider] and 45 guests