Page 1 of 1

pulse counter ncrement decrement two channels

Posted: Sat Jul 21, 2018 12:17 pm
by heiterkiter
Hi There,

i am having some problems understanding the pulse counters in the esp32

i am reading from the refernce at https://esp-idf.readthedocs.io/en/lates ... /pcnt.html

"Each pulse counter unit has a 16-bit signed counter register and two channels that can be configured to either increment or decrement the counter"

i am in need for a counter that can count the pulses from two flowmeters - one between the tank and injection pump of a diesel engine and one on the flowback to the tank. i want to count the difference between the two flowmeters as the consumption of the diesel engine.

so far all the examples i have seen used a pulse pin and a control pin which sets the direction of the counting, which does not help me at all

is there a way to attach the two flowmeters (which will pulse at a different rate due to consumption of diesel) on to two pins and one is increasing the counter and one is decreasing it?

thanks
heiterkiter from hamburg, germany

Re: pulse counter ncrement decrement two channels

Posted: Sun Aug 12, 2018 4:35 am
by kolban
From my reading ... yes we can do this. At the highest level, pick one of the 8 pulse counter units available to us. We will then find that the single unit has two channels. Each channel has a data pin. For channel 0 indicate that a pulse on the data pin should increment the unit counter while for channel 1 indicate that a pulse on the data pin should decrement the unit counter. At this point, the pulse counter should be incrementing for pulses on channel 0 and decrementing for pulses on channel 1.