Quantcast
Viewing all articles
Browse latest Browse all 4883

Automation, sensing and robotics • Flow Meter Not Reading

Hello,
I am having trouble getting a reading from one of my flow meters. I have 2 flow meters, one is .5" diameter, and the other is 1.5" diameter. The wiring connection is the same for both, positive, negative and signal. The power requirements are the same as well. My code is pretty straightforward, as the propeller in the flow meter rotates, a counter is incremented in my code and the count is printed to the terminal. When running my flow code directly, I am able to successfully get a reading from BOTH flow meters without any issue. However, when I call my flow code from another script, I am only able to get a reading when the .5" flow meter is connected, not the 1.5" flow meter.

The fact that I can read both successfully from the flow code seems to rule out a hardware issue.
The fact that I can get a reading from the calling code when the .5" flow meter seems to rule out a software issue.

I am completely stumped, thanks for the help.

Flow Meter Code:

Code:

import RPi.GPIO as GPIOFLOW_SENSOR_GPIO = 26GPIO.setmode(GPIO.BCM)GPIO.setup(FLOW_SENSOR_GPIO, GPIO.IN, pull_up_down = GPIO.PUD_UP)global cumulative_flow_pulse_countcumulative_flow_pulse_count = 0 def pulse_detected():   global cumulative_flow_pulse_count   cumulative_flow_pulse_count += 1   print(cumulative_flow_pulse_count)GPIO.add_event_detect(FLOW_SENSOR_GPIO, GPIO.FALLING, callback=pulse_detected)def get_cumulative_flow_pulse_count():    global cumulative_flow_pulse_count    return cumulative_flow_pulse_count def start_collection():    global cumulative_flow_pulse_count    cumulative_flow_pulse_count = 0if __name__ == '__main__':    start_collection()
Calling Code:

Code:

def message_handler(message):    global run_id    global is_running    message_object = json.loads(message.data)    message_parameters = message_object['Parameters']    command = message_object['Command']    if(command == "Start"):        Helpers.run_async(start_run, [message_object['Parameters']], "Start-Thread")def start_run(start_parameters):    is_running = True     Flow.start_collection()    # Other code omitted    while(is_running):        cumulative_flow_pulse_count = Flow.get_cumulative_flow_pulse_count()        # write value to SQLite database        time.sleep(5)        def run_async(target, args, name):    t = Thread(target = target, args = args, name=name)    t.start()    return t    

Statistics: Posted by Ziggy1982 — Sun Jun 16, 2024 7:58 am



Viewing all articles
Browse latest Browse all 4883

Trending Articles