I am using the below code to capture the pulses and count pulses for a specified interval but the output not as what i expected. For every pulse it is giving uncertain value.
The pulse i want to count is from a motor that will generate one pulse per rotation.
I am using Proximity Sensor for counting rotations.
CODE
import time
import pigpio
WIND_GPIO=4
pi = pigpio.pi()
pi.set_mode(WIND_GPIO, pigpio.INPUT)
pi.set_pull_up_down(WIND_GPIO, pigpio.PUD_UP)
wind_cb = pi.callback(WIND_GPIO, pigpio.FALLING_EDGE)
old_count = 0
while True:
time.sleep(5)
count = wind_cb.tally()
print("counted {} pulses".format(count - old_count))
old_count = count
pigpio.stop()
I found this code on https://www.raspberrypi.org/forums/viewtopic.php?p=507103
I want to count pulses for two conditions:
(i) One for all rotations from the beginning to End of program
(ii) Count Pulse based on other Pin Status Condition for example start counting if PIN A is HIGH.
How to achieve above mentioned condition using PIGPIO module
pigs pigpv
report? – joan Aug 26 '19 at 9:02