How to Create a Water Flow Meter

Introduction: How to Create a Water Flow Meter

About: Dialog Semiconductor provides a development platform based on an easy-to-use hardware and software GUI that allows users to easily create custom ICs. We provide design files and application notes that allow ...

An accurate, small, and low-cost liquid flow meter can be easily made using GreenPAK™ components. In this Instructable we present a water flow meter that continuously measures the water flow and displays it on three 7-segment displays. The flow sensor measurement range is from 1 to 30 liters per minute. The output of the sensor is a digital PWM signal with a frequency proportional to the water flow rate.

Three GreenPAK Programmable Mixed-signal Matrix SLG46533 CMICs count the number of pulses within a base time T. This base time is calculated such that the number of pulses is equal to the flow rate in that period, then this calculated number is displayed on the 7-segment displays. The resolution is 0.1 liters/min.

The output of the sensor is connected to a digital input with Schmitt trigger of a first Mixed-signal Matrix that counts the fractional number. The chips are cascaded together via a digital output, which is connected to a digital input of a proceeding Mixed-signal Matrix. Each device is connected to a 7segment common cathode display through 7 outputs.

Using a GreenPAK Programmable Mixed-signal Matrix is preferable to many other solutions such as microcontrollers and discrete components. Compared to a microcontroller, a GreenPAK is lower cost, smaller, and easier to program. Compared to a discrete logic integrated circuits design, it is also lower cost, easier to build, and smaller.

To make this solution commercially viable, the system must be as small as possible and be enclosed inside a waterproof, hard enclosure to be resistant to water, dust, steam, and other factors so that it may operate in various conditions.

To test the design a simple PCB was built. The GreenPAK devices are plugged on this PCB using 20 pins double rows female header connectors.

Tests are made first time using pulses generated by an Arduino and in a second time water flow rate of a home water source was measured. The system has shown an accuracy of 99%.

Discover all the steps needed understand how the GreenPAK chip has been programmed to control Water Flow Meter. However, if you just want to get the result of programming, download GreenPAK software to view the already completed GreenPAK Design File. Plug the GreenPAK Development Kit to your computer and hit the program to create the custom IC to control your Water Flow Meter. Follow the steps described below if you are interested in understanding how the circuit works.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Overall Description of the System

One of the most common ways to measure liquid flow rate is exactly like the principle of measuring the speed of wind by an anemometer: the speed of wind is proportional to the rotation speed of the anemometer. The main part of this type of flow sensor is a sort of a pinwheel, whose speed is proportional to the liquid flow rate passing through it.

We used the water flow sensor YF-S201 from the firm URUK shown in Figure 1. In this sensor, a Hall Effect sensor mounted on the pinwheel outputs a pulse with every revolution. The output signal frequency is presented in Formula 1, where Q is water flow rate in liters/minute.

For example, if the measured flow rate is 1 liter/minute the output signal frequency is 7.5 Hz. In order to display the real value of the flow in the format 1.0 liter/minute, we have to count pulses for a time of 1.333 seconds. In the 1.0 liter/minute example, the counted result will be 10, which will be displayed as 01.0 on the seven-segment displays. Two tasks are addressed in this application: the first is counting pulses and the second is displaying the number when counting task is complete. Each task lasts 1.333 seconds.

Step 2: GreenPAK Designer Implementation

The SLG46533 has many versatile combination function macrocells and they can be configured as Look up Tables, counters or D-Flip-Flops. This modularity is what makes GreenPAK suitable for the application.

The program has 3 stages: stage (1) generates a periodic digital signal to switch between the 2 tasks of the system, stage (2) counts flow sensor pulses and stage (3) displays the fractional number.

Step 3: First Stage: Counting/Displaying Switching

A digital output “COUNT/DISP-OUT” that changes the state between high and low every 1.333 seconds is required. When high, the system counts pulses and when low it displays the counted result. This can be achieved using DFF0, CNT1 and OSC0 wired like shown in Figure 2.

The frequency of OSC0 is 25 kHz. CNT1/DLY1/FSM1 is configured as a counter, and its clock input is connected to CLK/4 so that CNT1’s input clock frequency is 6.25 kHz. For the first clock period that lasts as shown in Equation 1, CNT1 output is high and from the next clock’s signal rising edge, counter output is low and CNT1 starts decrementing from 8332. When CNT1 data reaches 0, a new pulse on CNT1 output is generated. On each rising edge of CNT1 output, DFF0 output changes the state, if low it switches to high and vice versa.

DFF0’s output polarity should be configured as inverted. CNT1 is set to 8332 because count/display time T equals as shown in Equation 2.

Step 4: Second Stage: Counting Input Pulses

A 4-bit counter is made using DFF3/4/5/6, as shown in Figure 4. This counter increments on each pulse only when “COUNT/DISP-IN”, which is PIN 9, is high. The AND gate 2-L2 inputs are "COUNT/DISP-IN" and the PWM input. The counter is reset when it reaches 10 or when the counting phase starts. The 4-bit counter is reset when DFFs RESET pins, which are connected to the same network “RESET”, are low.

4-bit LUT2 is used to reset the counter when it reaches 10. Since DFF outputs are inverted, numbers are defined by inverting all the bits of their binary representations: swapping 0s for 1s and vice versa. This representation is called 1’s complement of binary number. 4-bit LUT2 inputs IN0, IN1, IN2 and IN3 are connected to a0, a1, a2, a3 and a3 respectively. The truth table for 4-LUT2 is shown in Table 1.

When 10 pulses are registered, the output of 4-LUT0 switches from high to low. At this point the output of CNT6/DLY6, configured to work in one shot mode, switches to low for a period of 90 ns then turns on again. Likewise, when “COUNT/DISP-IN” switches from low to high, that is. the system starts counting pulses. The output of CNT5/DLY5, configured to work in one shot mode, switches too low for a period of 90 ns then turns on again. It is crucial to maintain the RESET button at a low level for a while and turn it on again using CNT5 and CNT6 to give time for all DFFs to reset. A delay of 90 ns has no impact on the system accuracy since the maximum frequency of the PWM signal is 225 Hz. CNT5 and CNT6 outputs are connected to inputs of the AND gate that outputs the RESET signal.

The output of 4-LUT2 is also connected to Pin 4, labeled "F/10-OUT", which will be connected to the PWM input of the next chip’s counting stage. For example, if "PWM-IN" of the fractional counting device is connected to the PWM output of the sensor, and its "F/10-OUT" is connected to the "PWM-IN" of the units counting device and the "F/10-OUT" of the latter is connected to the "PWM-IN" of the tens counting device and so on. "COUNT/DISP-IN" of all these stages should be connected to the same "COUNT/DISP-OUT" of any of the 3 devices for the fractional counting device.

Figure 5 explains in detail how this stage works by showing how to measure a flow rate of 1.5 liters/minute.

Step 5: Third Stage: Displaying Measured Value

This stage has as inputs: a0, a1, a2 and a3 (reversed), and will output to the pins connected to the 7-segment display. Each segment has a logical function to be made by available LUTs. 4-bit LUTs can do the job very easily but unfortunately only 1 is available. 4-bit LUT0 is used for segment G, but for the other segments we used a pair of 3-bits LUTs as shown in Figure 6. The leftmost 3-bit LUTs have a2/a1/a0 connected to their inputs, while the rightmost 3-bit LUTs have a3 connected to their inputs.

All look up tables can be deduced from the 7-segment decoder truth table shown in Table 2. They are presented in Table 3, Table 4, Table 5, Table 6, Table 7, Table 8, Table 9.

Control pins of GPIOs that control the 7-segment display are connected to "COUNT/DISP-IN" through an inverter as outputs when "COUNT/DISP-IN" is low, which means the display is changed only during the display task. Therefore, during the counting task, displays are OFF and during displaying task they display the counted pulses.

A decimal point indicator may be needed somewhere within the 7-segment display. For this reason, PIN5, labeled "DP-OUT", is connected to the reversed "COUNT/DISP" network and we connect it to the DP of the corresponding display. In our application we need to display the decimal point of the units counting device to show numbers in the format "xx.x", then we will connect "DP-OUT" of the unit counting device to the DP input of the unit’s 7-segment display and we leave the others unconnected.

Step 6: Hardware Implementation

Figure 7 shows the interconnection between the 3 GreenPAK chips and connections of each chip to its corresponding display. The decimal point output of the GreenPAK is connected the DP input of the 7-segment display to show flow rate in its correct format, with a resolution of 0.1 liters / minute. The PWM input of the LSB chip is connected to the PWM output of the waterflow sensor. The F/10 outputs of the circuits are connected to the PWM inputs of the following chip. For sensors with higher flow rates and/or greater accuracy, more chips can be cascaded to append more digits.

Step 7: Results

To test the system, we built a simple PCB which has connectors to plug in GreenPAK sockets using 20 pin double-row female headers. The schematic and layout of this PCB as well as photos are presented in the Appendix.

The system was tested first with an Arduino that simulates a flow rate sensor and a water source with a constant, known flow rate by generating pulses at 225 Hz which corresponds to a flow rate of 30 liters/minute respectively. Result of the measurement was equal 29.7 liters/minute, error is about 1 %.

The Second test was made with the water flow rate sensor and a home water source. Measurement at different flow rates were 4.5 and 12.4.

Conclusion

This Instructable demonstrates how to build a small, low cost, and accurate flow meter using a Dialog SLG46533. Thanks to GreenPAK, this design is smaller, simpler, and easier to create than comparable solutions.

Our system can measure a flow rate up to 30 liters / minute with a resolution of 0.1 liters, but we can use more GreenPAKs to measure higher flow rates with higher accuracy depending on the flow sensor. A Dialog GreenPAK-based system can work with a wide range of turbine flow meters.

The suggested solution was designed to measure the flow rate of water, but it can be adapted to be used with any sensor that outputs a PWM signal, like a gas flow rate sensor.

Be the First to Share

    Recommendations

    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest
    • Fix It Contest

      Fix It Contest

    Discussions