Example #1
0
    def __init__(self):

        self.v = VolCtl()
        self.b = BZBoard("/dev/ttyACM1")
        self.p = PumpsCtl('/dev/ttyACM0', self.v)
        self.rv = RecordVideo(60*30)

        # original recipe was 2.5, 20, 12.5, 18, 19 (fe, h2o, h2s, mal, k)
        # but because on average there's a 3 ml remain of theoretically clean water
        # I am reducing the quantity of water to 16 to consider remains
        self.waste =       {'pump':'P0', 'quantity':75, 'speedIn':40, 'speedOut':50}
        self.water =       {'pump':'P4', 'quantity':15,  'speedIn':60, 'speedOut':70}
        self.ferroin =     {'pump':'P1', 'quantity':2.5, 'speedIn':35, 'speedOut':35}
        self.h2so4 =       {'pump':'P2', 'quantity':12.5,'speedIn':60, 'speedOut':70}
        self.h2so4_clean = {'pump':'P2', 'quantity':5,   'speedIn':60, 'speedOut':70}
        self.kbro3 =       {'pump':'P5', 'quantity':19,  'speedIn':110,'speedOut':110}
        self.kbro3_clean = {'pump':'P5', 'quantity':12,  'speedIn':110,'speedOut':110}
        self.malonic =     {'pump':'P3', 'quantity':18,  'speedIn':60, 'speedOut':70}
        self.water_clean = {'pump':'P4', 'quantity':50,  'speedIn':60, 'speedOut':70} 
Example #2
0
class AutomatedPlatform():
    def __init__(self):

        self.v = VolCtl()
        self.b = BZBoard("/dev/ttyACM1")
        self.p = PumpsCtl('/dev/ttyACM0', self.v)
        self.rv = RecordVideo(30 * 60)

        # original recipe was 2.5, 20, 12.5, 18, 19 (fe, h2o, h2s, mal, k)
        # but because on average there's a 3 ml remain of theoretically clean water
        # I am reducing the quantity of water to 16 to consider remains
        self.waste = {
            'pump': 'P0',
            'quantity': 100,
            'speedIn': 40,
            'speedOut': 50
        }
        self.water = {
            'pump': 'P4',
            'quantity': 15,
            'speedIn': 60,
            'speedOut': 60
        }
        self.ferroin = {
            'pump': 'P1',
            'quantity': 2.5,
            'speedIn': 35,
            'speedOut': 35
        }
        self.h2so4 = {
            'pump': 'P2',
            'quantity': 12.5,
            'speedIn': 60,
            'speedOut': 60
        }
        self.h2so4_clean = {
            'pump': 'P2',
            'quantity': 5,
            'speedIn': 60,
            'speedOut': 60
        }
        self.kbro3 = {
            'pump': 'P5',
            'quantity': 19,
            'speedIn': 110,
            'speedOut': 110
        }
        self.kbro3_clean = {
            'pump': 'P5',
            'quantity': 15,
            'speedIn': 110,
            'speedOut': 110
        }
        self.malonic = {
            'pump': 'P3',
            'quantity': 18,
            'speedIn': 60,
            'speedOut': 60
        }
        self.water_clean = {
            'pump': 'P4',
            'quantity': 50,
            'speedIn': 60,
            'speedOut': 60
        }

    def fill_experiment(self,
                        water=15,
                        ferroin=2.5,
                        h2so4=12.5,
                        kbro3=19,
                        malonic=18):

        #set experiental parameters
        self.water['quantity'] = water
        self.ferroin['quantity'] = ferroin
        self.h2so4['quantity'] = h2so4
        self.kbro3['quantity'] = kbro3
        self.malonic['quantity'] = malonic

        #calc volume for one experiment including cleaning
        tot_water = self.water['quantity'] + 3 * self.water_clean['quantity']
        tot_ferroin = self.ferroin['quantity']
        tot_h2so4 = self.h2so4['quantity'] + 2 * self.h2so4_clean['quantity']
        tot_kbro3 = self.kbro3['quantity'] + 2 * self.kbro3_clean['quantity']
        tot_malonic = self.malonic['quantity']
        tot_waste = tot_water + tot_ferroin + tot_h2so4 + tot_kbro3 + tot_malonic
        #update required experiment volumes  (expvol) in volctl
        self.v.update_single_experiment_volumes(tot_water, tot_ferroin,
                                                tot_h2so4, tot_kbro3,
                                                tot_malonic, tot_waste)
        #call countdown and print how many experiments are left
        self.v.countdown_experiments_left()
        #check enough for whole experiment to run and direct to reset if not
        self.v.check_sufficent_volume()

        #dispense the BZ recipe into the arena
        self.p.pump_multiple(self.water, self.malonic, self.kbro3, self.h2so4,
                             self.ferroin)
        # activate all max speed for 30 second to mix
        self.b.activate_all(3000)
        time.sleep(60)
        self.b.disable_all()

        # wait for 10 minutes
        time.sleep(60 * 10)

    def clean_experiment(self):
        # start cleaning platform
        for i in range(2):
            self.p.pump_multiple(self.waste)  # send to waste
            self.p.pump_multiple(self.water_clean, self.h2so4_clean,
                                 self.kbro3_clean)  # clean system
            time.sleep(2 * 60)

        for i in range(1):
            self.p.pump_multiple(self.waste)
            self.p.pump_multiple(self.water_clean)

        for i in range(2):
            self.p.pump_multiple(self.waste)
Example #3
0
        if matrix[motor] == 0:
            matrix[motor] = 1
            board.activate_motor(motor)


# this matrix stores if the motors are enabled (1) or disabled (0)
# before writting to serial we check this to not sent writes not needed
matrix = { 
    "A1":0,"A2":0,"A3":0,"A4":0,"A5":0,
    "B1":0,"B2":0,"B3":0,"B4":0,"B5":0,
    "C1":0,"C2":0,"C3":0,"C4":0,"C5":0,
    "D1":0,"D2":0,"D3":0,"D4":0,"D5":0,
    "E1":0,"E2":0,"E3":0,"E4":0,"E5":0
    }

board = BZBoard('/dev/ttyACM0')
svm = test_svm.HSVHistogramBkgMem('img_proc/hsvhistmem.dat')

vc = cv2.VideoCapture(0)
vc.set(cv2.CAP_PROP_FRAME_WIDTH, 800)
vc.set(cv2.CAP_PROP_FRAME_HEIGHT, 600)

fourcc = cv2.VideoWriter_fourcc(*'XVID')
raw = cv2.VideoWriter('raw.avi',fourcc, 30.0, (800,600))
out = cv2.VideoWriter('svm.avi',fourcc, 30.0, (800,600))

click_grid = test_svm.GridClickData()    
# number of frame avg background we will keep
bkg_window = 3000
# where we keep the avg background colour
frame_color = deque(maxlen=bkg_window)
Example #4
0
class AutomatedPlatform():


    def __init__(self):

        self.v = VolCtl()
        self.b = BZBoard("/dev/ttyACM1")
        self.p = PumpsCtl('/dev/ttyACM0', self.v)
        self.rv = RecordVideo(60*30)

        # original recipe was 2.5, 20, 12.5, 18, 19 (fe, h2o, h2s, mal, k)
        # but because on average there's a 3 ml remain of theoretically clean water
        # I am reducing the quantity of water to 16 to consider remains
        self.waste =       {'pump':'P0', 'quantity':75, 'speedIn':40, 'speedOut':50}
        self.water =       {'pump':'P4', 'quantity':15,  'speedIn':60, 'speedOut':70}
        self.ferroin =     {'pump':'P1', 'quantity':2.5, 'speedIn':35, 'speedOut':35}
        self.h2so4 =       {'pump':'P2', 'quantity':12.5,'speedIn':60, 'speedOut':70}
        self.h2so4_clean = {'pump':'P2', 'quantity':5,   'speedIn':60, 'speedOut':70}
        self.kbro3 =       {'pump':'P5', 'quantity':19,  'speedIn':110,'speedOut':110}
        self.kbro3_clean = {'pump':'P5', 'quantity':12,  'speedIn':110,'speedOut':110}
        self.malonic =     {'pump':'P3', 'quantity':18,  'speedIn':60, 'speedOut':70}
        self.water_clean = {'pump':'P4', 'quantity':50,  'speedIn':60, 'speedOut':70} 


    def perform_experiment(self, water=15, ferroin=2.5, h2so4=12.5, kbro3=19, malonic=18):

        
        exp_time = datetime.now().strftime('%Y-%m-%d %H:%M')
        print("Starting time: "+exp_time)

        #set experiental parameters 
        self.water['quantity'] = water
        self.ferroin['quantity'] = ferroin
        self.h2so4['quantity'] = h2so4
        self.kbro3['quantity'] = kbro3
        self.malonic['quantity'] = malonic

        #calc volume for one experiment including cleaning
        tot_water =   self.water['quantity'] + 3*self.water_clean['quantity']
        tot_ferroin = self.ferroin['quantity'] 
        tot_h2so4 =   self.h2so4['quantity'] + 2*self.h2so4_clean['quantity']          
        tot_kbro3 =   self.kbro3['quantity'] + 2*self.kbro3_clean['quantity']
        tot_malonic = self.malonic['quantity']             
        tot_waste =   tot_water + tot_ferroin + tot_h2so4 + tot_kbro3 + tot_malonic
        #update required experiment volumes  (expvol) in volctl
        self.v.update_single_experiment_volumes(tot_water,tot_ferroin,tot_h2so4,tot_kbro3,tot_malonic,tot_waste)
        #call countdown and print how many experiments are left
        self.v.countdown_experiments_left()
        #check enough for whole experiment to run and direct to reset if not
        self.v.check_sufficent_volume()

        print("Preparing BZ reaction")
        #dispense the BZ recipe into the arena
        self.p.pump_multiple(self.water, self.malonic, self.kbro3, self.h2so4, 
                self.ferroin)
        # activate all max speed for 60 second to mix
        self.b.activate_all(0, 200)
        time.sleep(60)
        self.b.disable_all()

        print("Waiting 10 minutes")
        # wait for 10 minutes
        time.sleep(60*10)
        
        # activate random pattern for 1 minute 30 times
        # need variable titles
        exp_time = datetime.now().strftime('%Y-%m-%d %H:%M')
        print("Starting actual experiment at "+exp_time)
        self.rv.record_threaded( exp_time )
        time.sleep(1)
        for i in range(15):
            #speeds = self.b.activate_rand_multiple(exp_time)
            speeds = self.b.activate_rand_column(exp_time)
            time.sleep(60*1)
            self.b.repeat_rand(exp_time, speeds)
            time.sleep(60*1)
        self.b.disable_all()
        
        print("Starting cleaning")
        # start cleaning platform
        for i in range(2):
            print("First cleaning phase "+str(i))
            self.p.pump_multiple(self.waste) # send to waste
            self.p.pump_multiple(self.water_clean, self.h2so4_clean, 
                    self.kbro3_clean) # clean system
            time.sleep(2*60)
            
        print("Second cleaning phase")
        for i in range(1):
            self.p.pump_multiple(self.waste)
            self.p.pump_multiple(self.water_clean) 

        print("Last cleaning phase")
        for i in range(2):
            self.p.pump_multiple(self.waste)
Example #5
0
File: main.py Project: croningp/BZ1
from bzboard.bzboard import BZBoard
from pumpsctl.pumpsctl import PumpsCtl

board = BZBoard('/dev/ttyACM0')
pumps = PumpsCtl('/dev/ttyACM1')

# prepare experiment
# our BZ recipe is (all in ml) 2.5 ferroin, 20 water, 12.5 h2so4
#                               18 malonic, 19 kbromate
ferroin = {'pump': 'P1', 'quantity': 2.5, 'speedIn': 20, 'speedOut': 10}
h2so4 = {'pump': 'P2', 'quantity': 12.5, 'speedIn': 20, 'speedOut': 10}
malonic = {'pump': 'P3', 'quantity': 18, 'speedIn': 20, 'speedOut': 10}
water = {'pump': 'P4', 'quantity': 20, 'speedIn': 20, 'speedOut': 10}
kbromate = {'pump': 'P5', 'quantity': 19, 'speedIn': 20, 'speedOut': 10}

pumps.pump_multiple(h2so4, water)
pumps.pump_multiple(ferroin, malonic)
pumps.pump_multiple(kbromate)

# activate stirrers
# activate camera
# let experiment go

# clean it - the volume of the experiment was 72 ml
# we can go mental and at first drain 100ml
pumps.pump_in('P0', 100, 30, 30)  # P0 is drain, 100 is ml

pumps.close()
del pumps
Example #6
0
import time
from pumpsctl.pumpsctl import PumpsCtl
from bzboard.bzboard import BZBoard
from tools.volctl import VolCtl

b = BZBoard("/dev/ttyACM1")
v = VolCtl()
p = PumpsCtl('/dev/ttyACM0', v)

# I am reducing the quantity of water to 16 to consider remains
waste = {'pump': 'P0', 'quantity': 75, 'speedIn': 40, 'speedOut': 50}
h2so4_clean = {'pump': 'P2', 'quantity': 5, 'speedIn': 60, 'speedOut': 60}
kbro3_clean = {'pump': 'P5', 'quantity': 7, 'speedIn': 110, 'speedOut': 110}
water_clean = {'pump': 'P4', 'quantity': 50, 'speedIn': 60, 'speedOut': 60}

for i in range(1):
    p.pump_multiple(waste)
    p.pump_multiple(water_clean, h2so4_clean, kbro3_clean)
    time.sleep(0 * 60)

for i in range(1):
    p.pump_multiple(waste)
    p.pump_multiple(water_clean)

for i in range(2):
    p.pump_multiple(waste)
Example #7
0
################################################################
# This script should be used before starting the experiments
# to make sure everything is working and tubes are filled
################################################################

import time

from pumpsctl.pumpsctl import PumpsCtl
from bzboard.bzboard import BZBoard
from img_proc.record_cam import RecordVideo
import os, sys
sys.path.append(os.path.abspath('..'))
from tools.volctl import VolCtl

v = VolCtl()
b = BZBoard("/dev/ttyACM1")
p = PumpsCtl('/dev/ttyACM0', v)

rv = RecordVideo(10)

waste = {'pump': 'P0', 'quantity': 75, 'speedIn': 50, 'speedOut': 50}
water = {'pump': 'P4', 'quantity': 5, 'speedIn': 60, 'speedOut': 70}
h2so4 = {'pump': 'P2', 'quantity': 5, 'speedIn': 60, 'speedOut': 70}
kbro3 = {'pump': 'P5', 'quantity': 5, 'speedIn': 110, 'speedOut': 110}
malonic = {'pump': 'P3', 'quantity': 5, 'speedIn': 60, 'speedOut': 70}
water_clean = {'pump': 'P4', 'quantity': 50, 'speedIn': 50, 'speedOut': 70}
ferroin = {'pump': 'P1', 'quantity': 2, 'speedIn': 50, 'speedOut': 50}

# make sure these 4 pumps are filled, I will test ferroin individually
p.pump_multiple(water, malonic, kbro3, h2so4, ferroin)
# activate all max speed for 30 second to mix