Measuring water flow with UniPi
-
Hello,
I need advice which REXYGEN system function block to use for water flow measurement. The sensor is connected to my UniPi v1.1 and gives me input 200-400Hz (according to the flow). I need to measure the flow every second. I tried using the COUNT block, but no success. Illustrative image is attached.
Thank you in advance for your help.
Karel -
Hi Karel,
the COUNT function block is definitely a good choice, however you should be aware of project timing because of quite high input frequency. I recommend you to have a look at example "0120-23 Frequency of Pulses". Change the project timing so the "tick" parameter is 0.001 s (within the EXEC function block) and "ntick0" according to your needs.
It means that Quick Task will be executed every 1 ms and task on Level0 every 0.001*ntick0 [s].Note that the period of 1ms is quite challenging for Raspberry Pi. I would recommend to use Raspberry Pi 3B+ and watch diagnostics.
Hope it helps.
Regards, Tomas
-
I just had to solve this problem myself. I did some back-of-the-envelope calculations and decided a Pi was just too slow to count pulses this fast AND do all the other work I wanted it to do. So I created a small printed-circuit board with the MCP23017 connected to a SN74LV8154 dual counter after searching fruitlessly for a Pi HAT that included a counter. The counter counts the pulses, the MCP23017 interfaces the parallel outputs of the counter to the I2C bus, and I modified the Rexygen-supplied MCP23017 driver to return the count values and multiply them by calibration constants. Another possibility would be to use a separate microcontroller like the STM32 to count the pulses and return the sum by I2C, but I didn't want to learn the entire software environment of the microcontroller just for that one task.
This solution is working very well, however it required electrical engineering knowledge and learning a PC board design tool (kicad).
If you only care about flow rate, another option is to build a RC filter circuit to transform the pulses into a voltage, and use a ADC card to read in the voltage. This doesn't work well for total fluid volume calculations because again, the Pi would be required to integrate the voltages at a high speed.
-
@enovikoff said in Measuring water flow with UniPi:
after searching fruitlessly for a Pi HAT that included a counter
What about the Monarco HAT? It has 2 high-speed counters onboard...
Jaroslav