Ejemplo n.º 1
0
def sysTest():
    print("testing parts")
    i = 0
    while (i < 1):
        print("\n")
        print("quit: 0")
        print("pumps: 1")
        print("valves:2")
        print("Photodiodes: 3")
        print("lasers: 4")
        var = input(": ")
        currInput = int(var)
        print("current input: ", currInput)

        if (currInput == 0):
            print(
                "turning off pump, closing all valves, turning off lasers, quitting"
            )
            DAQC2.clrDOUTbit(0, 6)  #turn off pump1
            DAQC2.clrDOUTbit(1, 6)  #turn off pump2
            DAQC2.clrDOUTbit(0, 0)  #turn off valves
            DAQC2.clrDOUTbit(0, 1)
            DAQC2.clrDOUTbit(0, 2)
            DAQC2.clrDOUTbit(0, 3)
            DAQC2.clrDOUTbit(0, 4)
            DAQC2.clrDOUTbit(0, 5)
            DAQC2.clrDOUTbit(1, 0)
            DAQC2.clrDOUTbit(1, 1)
            DAQC2.clrDOUTbit(1, 2)
            DAQC2.clrDOUTbit(1, 3)
            DAQC2.clrDOUTbit(1, 4)
            DAQC2.clrDOUTbit(1, 5)
            DAQC2.clrDOUTbit(0, 7)  #turn off lasers
            i = 5
            print("quitting")
            break

        elif (currInput == 1):
            print("pumps")
            j = 0
            while (j < 1):
                print("\n")
                print("to go back: 0")
                print("turn on pump#1: 1")
                print("turn on pump#2: 2")
                print("turn off pump#1: 3")
                print("turn off pump#2: 4")
                var = input(": ")
                currInput1 = int(var)
                print("current input: ", currInput1)

                if (currInput1 == 0):
                    print("back to main test menu")
                    j = 5

                elif (currInput1 == 1):
                    print("turning on pump#1")
                    DAQC2.setDOUTbit(0, 6)

                elif (currInput1 == 2):
                    print("turning on pump#2")
                    DAQC2.setDOUTbit(1, 6)

                elif (currInput1 == 3):
                    print("turning off pump#1")
                    DAQC2.clrDOUTbit(0, 6)

                elif (currInput1 == 4):
                    print("turning off pump#1")
                    DAQC2.clrDOUTbit(1, 6)

        elif (currInput == 4):
            print("Lasers")
            j = 0
            while (j < 1):
                print("\n")
                print("turn lasers on: 1")
                print("turn lasers off: 2")
                print("go back to test menu: 0")
                var = input(": ")
                currInput2 = int(var)
                print("current input: ", currInput2)

                if (currInput2 == 0):
                    print("back to main test menu")
                    j = 5

                elif (currInput2 == 1):
                    print("lasers on")
                    DAQC2.setDOUTbit(0, 7)

                elif (currInput2 == 2):
                    print("lasers off")
                    DAQC2.clrDOUTbit(0, 7)

        elif (currInput == 2):
            print("Valves")
            j = 0
            while (j < 1):
                print("\n")
                print("to go back: 0")
                print("to open individual valves: 1-12")
                print("to close individual valves 21-32")
                print("to open all valves: 13")
                print("to close all valves: 14")
                var = input(": ")
                currInput3 = int(var)
                print("current input: ", currInput3)

                if (currInput3 == 0):
                    print("back to main test menu")
                    j = 5

                elif (currInput3 == 13):
                    print("opening all valves")
                    DAQC2.setDOUTbit(0, 0)  #open all valves
                    DAQC2.setDOUTbit(0, 1)
                    DAQC2.setDOUTbit(0, 2)
                    DAQC2.setDOUTbit(0, 3)
                    DAQC2.setDOUTbit(0, 4)
                    DAQC2.setDOUTbit(0, 5)
                    DAQC2.setDOUTbit(1, 0)
                    DAQC2.setDOUTbit(1, 1)
                    DAQC2.setDOUTbit(1, 2)
                    DAQC2.setDOUTbit(1, 3)
                    DAQC2.setDOUTbit(1, 4)
                    DAQC2.setDOUTbit(1, 5)

                elif (currInput3 == 14):
                    print("closing all valves")
                    DAQC2.clrDOUTbit(0, 0)  #close all valves
                    DAQC2.clrDOUTbit(0, 1)
                    DAQC2.clrDOUTbit(0, 2)
                    DAQC2.clrDOUTbit(0, 3)
                    DAQC2.clrDOUTbit(0, 4)
                    DAQC2.clrDOUTbit(0, 5)
                    DAQC2.clrDOUTbit(1, 0)
                    DAQC2.clrDOUTbit(1, 1)
                    DAQC2.clrDOUTbit(1, 2)
                    DAQC2.clrDOUTbit(1, 3)
                    DAQC2.clrDOUTbit(1, 4)
                    DAQC2.clrDOUTbit(1, 5)

                elif (currInput3 == 1):
                    print("opening valve #1")
                    DAQC2.setDOUTbit(0, 0)

                elif (currInput3 == 2):
                    print("opening valve #2")
                    DAQC2.setDOUTbit(0, 1)

                elif (currInput3 == 3):
                    print("opening valve #3")
                    DAQC2.setDOUTbit(0, 2)

                elif (currInput3 == 4):
                    print("opening valve #4")
                    DAQC2.setDOUTbit(0, 3)

                elif (currInput3 == 5):
                    print("opening valve #5")
                    DAQC2.setDOUTbit(0, 4)

                elif (currInput3 == 6):
                    print("opening valve #6")
                    DAQC2.setDOUTbit(0, 5)

                elif (currInput3 == 7):
                    print("opening valve #7")
                    DAQC2.setDOUTbit(1, 0)

                elif (currInput3 == 8):
                    print("opening valve #8")
                    DAQC2.setDOUTbit(1, 1)

                elif (currInput3 == 9):
                    print("opening valve #9")
                    DAQC2.setDOUTbit(1, 2)

                elif (currInput3 == 10):
                    print("opening valve #10")
                    DAQC2.setDOUTbit(1, 3)

                elif (currInput3 == 11):
                    print("opening valve #11")
                    DAQC2.setDOUTbit(1, 4)

                elif (currInput3 == 12):
                    print("opening valve #12")
                    DAQC2.setDOUTbit(1, 5)

                elif (currInput3 == 21):
                    print("closing valve #1")
                    DAQC2.clrDOUTbit(0, 0)

                elif (currInput3 == 22):
                    print("closing valve #2")
                    DAQC2.clrDOUTbit(0, 1)

                elif (currInput3 == 23):
                    print("closing valve #3")
                    DAQC2.clrDOUTbit(0, 2)

                elif (currInput3 == 24):
                    print("closing valve #4")
                    DAQC2.clrDOUTbit(0, 3)

                elif (currInput3 == 25):
                    print("closing valve #5")
                    DAQC2.clrDOUTbit(0, 4)

                elif (currInput3 == 26):
                    print("closing valve #6")
                    DAQC2.clrDOUTbit(0, 5)

                elif (currInput3 == 27):
                    print("closing valve #7")
                    DAQC2.clrDOUTbit(1, 0)

                elif (currInput3 == 28):
                    print("closing valve #8")
                    DAQC2.clrDOUTbit(1, 1)

                elif (currInput3 == 29):
                    print("closing valve #9")
                    DAQC2.clrDOUTbit(1, 2)

                elif (currInput3 == 30):
                    print("closing valve #10")
                    DAQC2.clrDOUTbit(1, 3)

                elif (currInput3 == 31):
                    print("closing valve #11")
                    DAQC2.clrDOUTbit(1, 4)

                elif (currInput3 == 32):
                    print("closing valve #12")
                    DAQC2.clrDOUTbit(1, 5)

        elif (currInput == 3):
            print("Photodiodes")
            j = 0
            while (j < 1):
                print("\n")
                print("to go back: 0")
                print("to take a reading from a single morbidostat: 1-12")
                print("to take a reading from all morbidostats: 13")
                var = input(": ")
                currInput4 = int(var)
                print("current input: ", currInput4)

                if (currInput4 == 0):
                    print("back to main test menu")
                    j = 5

                elif (currInput4 == 13):
                    print("reading from all morbidostats")
                    plate1 = DAQC2.getADCall(0)
                    plate2 = DAQC2.getADCall(1)
                    j = 0
                    k = 0
                    num = 1
                    while (k < 12):
                        if (k <= 5):
                            currVolt = plate1[k]
                            print(num, ": ", currVolt)
                            k = k + 1
                            num = num + 1
                        elif (k > 5):
                            a = k - 6
                            currVolt = plate2[a]
                            print(num, ": ", currVolt)
                            k = k + 1
                            num = num + 1

                elif (currInput4 == 1):
                    currVolt = DAQC2.getADC(0, 0)
                    print("Morbidostat#1: ", currVolt)

                elif (currInput4 == 2):
                    currVolt = DAQC2.getADC(0, 1)
                    print("Morbidostat#2: ", currVolt)

                elif (currInput4 == 3):
                    currVolt = DAQC2.getADC(0, 2)
                    print("Morbidostat#3: ", currVolt)

                elif (currInput4 == 4):
                    currVolt = DAQC2.getADC(0, 3)
                    print("Morbidostat#4: ", currVolt)

                elif (currInput4 == 5):
                    currVolt = DAQC2.getADC(0, 4)
                    print("Morbidostat#4: ", currVolt)

                elif (currInput4 == 6):
                    currVolt = DAQC2.getADC(0, 5)
                    print("Morbidostat#6: ", currVolt)

                elif (currInput4 == 7):
                    currVolt = DAQC2.getADC(1, 0)
                    print("Morbidostat#7: ", currVolt)

                elif (currInput4 == 8):
                    currVolt = DAQC2.getADC(1, 1)
                    print("Morbidostat#8: ", currVolt)

                elif (currInput4 == 9):
                    currVolt = DAQC2.getADC(1, 2)
                    print("Morbidostat#9: ", currVolt)

                elif (currInput4 == 10):
                    currVolt = DAQC2.getADC(1, 3)
                    print("Morbidostat#10: ", currVolt)

                elif (currInput4 == 11):
                    currVolt = DAQC2.getADC(1, 4)
                    print("Morbidostat#11: ", currVolt)

                elif (currInput4 == 12):
                    currVolt = DAQC2.getADC(1, 5)
                    print("Morbidostat#12: ", currVolt)
Ejemplo n.º 2
0
        "Failed to import library from parent folder")

####### zet de LED uit
DAQC.setLED(0, 'off')

####### stuur de analoge output aan
DAQC.setDAC(0, 1, 2.64) # DAQ 0, adres analog-output 1, voltage 2.64 V

###### stuur 0, 1, 2, 3 volt naar analog-output 1
for i in range(10):
    volt = i % 4 # i modulo 4
    DAQC.setDAC(0, 1, volt)
    time.sleep(0.1)


####### Lees data van Analoge Input

val = DAQC.getADC(0, 1) # DAQC 0, adres Analog-Input 1
print(val)
val8 = DAQC.getADCall(0) # lees alle 8 Analog-Inputs
print(val8)

######## Lees meerdere data punten

data = get_data.readPiPlate(DAQC, 3) # kanaal 0, 1000 punten, ADC 0

# maak een (unieke) filenaam aan
filename = 'meting_test1_%s.txt' % (int(time.time()))
write_data.saveArray(data, filename)

                print(str(datetime.datetime.now()),
                      "Interrupt error ! " + str(DINInterrupt))
            else:
                for i in range(8):
                    if (testBit(DINInterrupt, i)):
                        msg = oscbuildparse.OSCMessage(
                            "/DIN/" + str(i), None,
                            [int(testBit(DINByte, i) == True)])
                        osc_send(msg, "OSCTx")
                        osc_process()
                        #print(str(datetime.datetime.now()), "DIN #"+str(i)+" "+str(testBit(DINByte,i)))
        DINInterrupt = 0

        # Process CANs to OSC
        # Get all 8 channels
        CAN = DAQC2.getADCall(AD)
        for i in range(8):
            if prevCAN[i] != CAN[i]:
                msg = oscbuildparse.OSCMessage("/CAN/" + str(i), None,
                                               [CAN[i]])
                osc_send(msg, "OSCTx")
                osc_process()
                #print(str(datetime.datetime.now()), "/CAN/"+str(i), CAN[i])
                prevCAN[i] = CAN[i]

        # Slow down to <50 hz
        sleep(0.02)

# Properly close the system.
except KeyboardInterrupt:
    print(str(datetime.datetime.now()),