Flow Meter Sample C...
 
Notifications

Flow Meter Sample Code  

  RSS

not_5
(@not_5)
Active Member
Joined: 12 months ago
Posts: 11
23/02/2019 11:03 pm  

Does any one have any experience using a flow meter with a raspberry pi and would be willing to share the snippet of code you use to control a solenoid or pump?


Quote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 100
23/02/2019 11:20 pm  

I don't have any flow meters but my understanding is you could use the RPM Input and determine the flow rate based on the RPM. This can be used with a Conditional Function to open/close a solenoid or valve, either via on/off-open/closed or PWM to adjust the opening based on the flow range (e.g. 5 <= flow_rpm <= 10, do this, 10 <= flow_rpm <= 15, do that) . A PID could also be used with the flow RPM Input to adjust a PWM signal that adjusts a valve's opening.

This post was modified 12 months ago by Kyle Gabriel

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 12 months ago
Posts: 11
23/02/2019 11:27 pm  

Makes a lot of sense. Good thought.

Thanks Kyle! Good idea opening a forum. Definitely nice to have a place to discuss mycodo and related projects.


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 100
24/02/2019 12:01 am  

Furthermore, you can create a conversion at Configure -> Measurements -> Add Conversion, for example, RPM to water speed (liters per hour), with the conversion x*10. Then in the RPM Input, you can set the conversion from measured RPM to liters per hour. This would allow for convenient measurement storage as the exact flow and makes programming downstream easier.

This post was modified 12 months ago by Kyle Gabriel

Mycodo Developer


ReplyQuote
carboncycle
(@carboncycle)
Active Member
Joined: 3 months ago
Posts: 8
19/12/2019 11:25 pm  

Hmm.  I have a use for this ( monitor flow from a sub-pump ) and I think enough parts to give this a go.


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 12 months ago
Posts: 11
27/12/2019 5:13 pm  

Following up on this thread from a while ago-- I'm trying using a flow meter to dispense specific volumes of liquid through a trigger

Example: a button triggers a relay that turns on a pump. The pump stays on until a specific volume of liquid flows through the flow meter.

 

A few questions:

  • Is there a way to pass parameters to mycodo as part of the trigger? I'm thinking of having another python application calling the trigger.
  • I think I can use the conversion feature of mycodo to convert pulses to mL, but is there a way to calibrate this through mycodo-client python parameters?
  • If I have two sensors with different pulse to mL conversions, is there a better way to distinguish between the conversions than just giving them different names?
  • Is there a way to store other variables/data in the influx database that mycodo uses?
    • I want to be able to have a variable that I can read externally that contains the volume of liquid last dispensed. This will be important for a manual dispensing mode (the variable continuously increments as liquid is dispensed and would be reset to 0 on trigger event).
    • I did think of using the sum function from start and stop timestamps
This post was modified 2 months ago by not_5

ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 100
27/12/2019 7:11 pm  

There are a lot of ways to accomplish dispensing a specific amount of liquid using a solenoid and flow meter. But there are a few things I'd need to understand to be able to configure Mycodo to do so.

1. What will determine when fluid needs to be dispensed?

2. What will determine how much needs to be dispensed?

Also, any numeric data can be both stored in and retrieved from influxdb.

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 12 months ago
Posts: 11
27/12/2019 9:26 pm  

@kylegabriel

The two use cases that I'm currently working on is a button press (software or hardware) that dispenses a predetermined volume of water (eg: button A dispenses 30mL; button B dispenses 100mL, etc) and a button press that turns dispenses an amount of water that is not predetermined (manual mode). In the not predetermined case, I want to be able to represent the volume of water, while it is being dispensed, as sort of a ticker. This would be for something like filling up a container for which you don't know its volume.

 

The best real world analogy that I can relate this to is those water bottle filling stations. I'll have a preset button (fill my 16oz bottle) and I'll have a manual fill button. For this manual fill button, as you're filling the bottle it would tick up from 0 fl oz to the total volume as you fill.

 

Overall, the main thing that I want to keep track of is the volume of water that was just dispensed (real-time, if possible).

This post was modified 2 months ago 2 times by not_5

ReplyQuote
not_5
(@not_5)
Active Member
Joined: 12 months ago
Posts: 11
06/01/2020 3:23 pm  

Sorry to bump- Thinking about this further, I'm not sure if trying to do all of the above in mycodo is the best method. I'm thinking maybe I should track the individual session event's pulses via the initiating python script.

Per the above, is there an API for the using/modifying the unit conversions that are in mycodo?


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 100
08/01/2020 4:17 pm  

I'm having a difficult time thinking of a good solution to your desired effect. There are Atlas Scientific peristaltic pumps that I recently integrated into Mycodo that can pump specific volumes and would work wonderfully for this application. However, what you want to accomplish is a bit more complex, as you will need to poll the sensor very quickly to get an accurate assessment of how fast the fluid is flowing and when to start/stop the flow. I'm leaning toward some custom script that Mycodo basically can call with a parameter such as --time_seconds 10 or --volume_ml 50 to initiate a dispense.

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 12 months ago
Posts: 11
08/01/2020 5:49 pm  

The flow meter is an edge sensor. Since each pulse will be a specific volume of liquid, once the number of edge detection are recorded the GPIO pin controlling the pump and solenoid can be triggered off.

Example:

  • Command --volume_ml 50
    • Begin counting edge detection of flow meter at time stamp 17:39:01.31.
    • While count < 50 * pulse_to_ml_conversion GPIO pump & solenoid 1 HIGH
    • Result log: 50 ml targeted, 51 ml dispensed [pulses * pulse_to_ml_conversion]

Again, not sure how much of this makes sense to be done in mycodo vs an external python script... I think for mycodo I'd really like to be able to use the unit conversion functions through parameters (query what conversion and modify the conversion). Additionally, is there a way to use the SUM function with timestamps?

This post was modified 1 month ago 2 times by not_5

ReplyQuote