I needs help on writing a C Program that keeps track of the total amount of pulse a meter goes high. When the pulse goes high the count should start.
Pulse = 0 = P when pulse goes high value changes to 1
At first K=P then when another pulse comes in K=1 with the first pulse. The when the second pulse goes high P =1 and the following formula would be used to finr the new total amount of pulses.
K = K + P (2 = 1 + 1)
Now K = 2 this is now the total amount of pulses
Another pulse comes in
K = K + P (3= 2 + 1)
This should be an infinite loop.
Then I would compare K to another value R (R is another pulse that will go high) If the value of R goes high it will save the value of K and keep record of the final pulse. But the pulse count should not stop.
If( R =1;
K= total pulse
Else continue)
Please help me. I have the idea but I’m not 100 percent sure if this will work.