pulse counter ncrement decrement two channels

heiterkiter
Posts: 1
Joined: Sat Jul 21, 2018 12:08 pm

pulse counter ncrement decrement two channels

Postby heiterkiter » Sat Jul 21, 2018 12:17 pm

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

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: pulse counter ncrement decrement two channels

Postby kolban » Sun Aug 12, 2018 4:35 am

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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Available for ESP32 consulting.

Who is online

Users browsing this forum: No registered users and 2 guests