Home Forums Software Programming Pump 3 for additional media component

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1817
    bene
    Participant

    Hi,

    I´d like to reprogramm Pump 3 for an additional media component in the automated experiment.
    So far I can see the pump responds in the UI when I start the experiment, but the pump itself does not turn on. If I turn on the pump in the UI manually, it works normally.

    Here is the part of the code that I have changed:
    def pump3_on():
    # switch on Pump 3 with target 0.5
    sysData[‘M0’][‘Pump3’][‘target’] = 0.5
    sysData[‘M0’][‘Pump3’][‘ON’] = 1

    def pump3_off():
    # switch off Pump 3
    sysData[‘M0’][‘Pump3’][‘target’] = 0.0
    sysData[‘M0’][‘Pump3’][‘ON’] = 0

    def control_pump3():
    delay_time = 20
    on_time = 10
    interval_time = 30
    off_time = interval_time – on_time

    time.sleep(delay_time)

    while True:
    # switch on Pump
    pump3_on()
    time.sleep(on_time)

    # switch off Pump
    pump3_off()
    time.sleep(off_time)

    def start_pump3():
    # function to start the control of Pump 3
    threading.Thread(target=control_pump3).start()

    def runExperiment(M,placeholder):
    #Primary function for running an automated experiment.
    M=str(M)

    global sysData
    global sysItems
    global sysDevices

    sysData[M][‘Experiment’][‘threadCount’]=(sysData[M][‘Experiment’][‘threadCount’]+1)%100
    currentThread=sysData[M][‘Experiment’][‘threadCount’]

    # Get time running in seconds
    now=datetime.now()
    elapsedTime=now-sysData[M][‘Experiment’][‘startTimeRaw’]
    elapsedTimeSeconds=round(elapsedTime.total_seconds(),2)
    sysData[M][‘Experiment’][‘cycles’]=sysData[M][‘Experiment’][‘cycles’]+1
    addTerminal(M,’Cycle ‘ + str(sysData[M][‘Experiment’][‘cycles’]) + ‘ Started’)
    CycleTime=sysData[M][‘Experiment’][‘cycleTime’]

    start_pump3() # initialise Pump 3

    I also got the following message in PuTTY when I start the experiment:
    CSV_WRITER: mismatch between column num and header num

    I hope you can help me, because my skills in programming are limited. Thanks.

    #1818
    harrison
    Keymaster

    Hello,

    I am not sure about the CSV_WRiter error. It implies you have changed something w.r.t the data structures being written to CSV.
    If IN GENERAL your goal is to have the 3rd pump on at some rate during an experiment, what I would do is add it to the main runExperiment function. It will need to turn the pump on again every loop (i.e. put this around the line “LightActuation(M,1)”, so that the pumping happens after measurement. Otherwise, the problem may be that you are indeed turning the pump on manually with the GUI but given the automated experiment is running it will turn it OFF again every loop since it wants all pumping to be disabled to do measurements… Hope this makes sense!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log in/Register
Scroll to top