Counting on digital inputs



  • I have two wattmeters exactly the same type. Both are reading consumption on the same power line. There is no electrical appliance between them. Wattmeters show the same consuption in total. I can see two LEDs on Unipi board blinking in the same frequency. One by one. Therefore I expect to get the same counter value from both devices. Unfortunatelly it differs very significantly. One of them count 26000 pulses. The second one 17000. Do you have any explanation or suggestion what to change in order to get the expected result?

    BTW what is the difference between falling and rising counter mode? Both are increasing when getting pulses.



  • I have two wattmeters exactly the same type. Both are reading consumption on the same power line. There is no electrical appliance between them. Wattmeters show the same consuption in total. I can see two LEDs on Unipi board blinking in the same frequency. One by one. Therefore I expect to get the same counter value from both devices. Unfortunatelly it differs very significantly. One of them count 26000 pulses. The second one 17000. Do you have any explanation or suggestion what to change in order to get the expected result?

    BTW what is the difference between falling and rising counter mode? Both are increasing when getting pulses.



  • Could you provide more infrmation? E.g. how often they blink, how many impulse per kwh the wattmeters give, what is the estimated constumption on the power line, what is your debounce time in evok,…

    The difference between rising and falling edge counting is in the behavior of when the impulse is evaulated as valid.

    If the mode is rising, then to be considered as valid, the pulse must stay high for the debounce_time, if it is set to rising, then the pulse must stay low for the debounce_time.



  • Frequency of blinking depends on consuption of course. There are LEDs directly on the wattmeter. They blink simultaneously with LEDs on Unipi. Therefore Unipi is getting pulses well. Normaly the consumption is 180-200Wh. Wattmeters provide 2000 pulses per kWh. The lenght of one puls is 80ms according to manufacturer. The frequency of blinking is around 5-6 seconds. It corresponds well to consumption I think. Unfortunately only DI_1 shows adequate number of pulses. DI_2 provides approx.1.5 less pulses. The debounce time is default. It means 0. If I change the debounce parameter to whatever, the counter remains still 0. Is the debounce time in seconds or miliseconds?



  • Interresting, it seems that the RPi cannot sample each GPIO with same frequency. Have you tried different DI than 2 and 1?

    The debounce time is in miliseconds.



  • No, I haven't. But it is exactly my plan. I will let you know the result.



  • Could you also try setting the debounce to 0? This should disable the debounce at all.



  • Yes, I'll try over the weekend.



  • Resolved but not fully. The situation now is following. I have two devices connected to DI_2 and D_3. They show the same value as expected as they measure the same power line. Nevertheles DI_1 increasing the value as well even without connected device. Its value is aproximately a half of the DI_2 and DI_3. I made no changes on debounce time. Possibly bug in evok?