# Is there a way to space out two consecutive pump commands?

**URL:** <https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90>\
**Category:** Data Processing Unit\
**Created:** [May 3, 2019, 4:39pm UTC](https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90 "2019-05-03T16:39:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgalardini](https://yyz1.discourse-cdn.com/flex035/user_avatar/www.evolver.bio/mgalardini/32/106_2.png) [@mgalardini](https://www.evolver.bio/u/mgalardini)\
**Post date:** [May 3, 2019, 4:39pm UTC](https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90/1 "2019-05-03T16:39:19Z")

</div>

I am thinking of ways to implement a morbidostat-like mode; essentially there are two inputs to a vial, one regular media, and one regular media + drug. To avoid the efflux line sucking up the drug before it gets a chance of mixing up well I was thinking it might be a good idea to pump media in, wait a few seconds and then pump media out. Is there a way to do that without adding a `time.sleep(2)` in the custom script, which might mess up things? @cmancuso suggested doing the influx at once and then divide the efflux into repeated small chunks using the `times_to_repeat` parameter. Any other ideas?

---

<div class="post-metadata">

**Author:** ![bgwong](https://yyz1.discourse-cdn.com/flex035/user_avatar/www.evolver.bio/bgwong/32/262_2.png) [@bgwong](https://www.evolver.bio/u/bgwong)\
**Post date:** [May 3, 2019, 4:58pm UTC](https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90/2 "2019-05-03T16:58:05Z")

</div>

Another idea is adding more functionality to the Arduino code. You can add a morbidostat specific program, similar to the way we have a mode for turbidostat and a mode for chemostat. The way you send commands could be very similar to what typically happens, but instead it might get sent to a queue with a timer tagged on it.

See the Arduino code on [Github](https://github.com/FYNCH-BIO/evolver-arduino/blob/master/SAMD21/Rev%20A/RS485_FLUIDICS/RS485_FLUIDICS.ino), for adding extra “fluid mode”:

```auto
  // Update all the pumps
  for (int i = 0; i < numPumps; i++) {
    if (fluid_mode == "o") {
      pumps[i].turnOff();
    }
    else {
      pumps[i].update(); 
    }
  }

```

It really depends on how much more functionalities you might need. For example, if you plan on utilizing some millifluidic devices, might make more sense to start creating your own morbidostat Arduino code. What Chris suggested is great for a simple fix to try out, with the only fear that if it somehow misses an efflux command the media levels aren’t what you expect it to be. Just be extra careful with being a bit more redundant about the efflux commands that get sent later.

Overall, I would recommend what Chris suggested, since its the simplest.

---

<div class="post-metadata">

**Author:** ![mgalardini](https://yyz1.discourse-cdn.com/flex035/user_avatar/www.evolver.bio/mgalardini/32/106_2.png) [@mgalardini](https://www.evolver.bio/u/mgalardini)\
**Post date:** [May 3, 2019, 5:08pm UTC](https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90/3 "2019-05-03T17:08:56Z")

</div>

I am indeed thinking of using a millifluidic device to handle the second influx, but I’ll stick to Chris’ suggestion for these initial tests. Thanks for the heads up!

---

<div class="post-metadata">

**Author:** ![bgwong](https://yyz1.discourse-cdn.com/flex035/user_avatar/www.evolver.bio/bgwong/32/262_2.png) [@bgwong](https://www.evolver.bio/u/bgwong)\
**Post date:** [May 3, 2019, 5:11pm UTC](https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90/4 "2019-05-03T17:11:48Z")

</div>

One more comment, if you were to implement changes to the DPU. What I would recommend is changing the [custom\_script.py](https://github.com/FYNCH-BIO/dpu/blob/master/experiment/template/custom_script.py):

Adding some script similar to this chunk, where it looks at the last pump event and it will trigger it with a given amount of time after the event.

```python
                save_path = os.path.dirname(os.path.realpath( __file__ ))
                file_name = "vial{0}_pump_log.txt".format(x)
                file_path = os.path.join(save_path,exp_name,'pump_log',file_name)
                data = np.genfromtxt(file_path, delimiter=',')
                last_pump = data[len(data)-1][0];
                if (last_pump - current_time > target_delay):            
                     ## ADD EFFLUX PUMP EVENT HERE

```

Note: Dont take this code directly, just quickly threw something together as an example.

---

<div class="post-metadata">

**Author:** ![mgalardini](https://yyz1.discourse-cdn.com/flex035/user_avatar/www.evolver.bio/mgalardini/32/106_2.png) [@mgalardini](https://www.evolver.bio/u/mgalardini)\
**Post date:** [May 3, 2019, 5:14pm UTC](https://www.evolver.bio/t/is-there-a-way-to-space-out-two-consecutive-pump-commands/90/5 "2019-05-03T17:14:47Z")

</div>

This would work too, yes! Only worry is that the delay might be greater than a handful of seconds, so maybe the “repeated” efflux events seem more attractive. I’ll experiment a bit and report back
