Beispiel #1
0
def runCustom(commandString):
    #connecto to ardustat and setup resistance table
    a = ard.ardustat()
    a.connect(7777)
    a.debug = False
    #a.calibrate(15000,16)
    a.load_resistance_table(16)

    #create arrays + a function for logging data
    """
Beispiel #2
0
def runCustom(commandString):
                #connecto to ardustat and setup resistance table
        a = ard.ardustat()
        a.connect(7777)
        a.debug = False
        #a.calibrate(15000,16)
        a.load_resistance_table(16)

        #create arrays + a function for logging data
        

        """
Beispiel #3
0
import numpy
import ardustat_library_simple as ard
import time

#set parameters
read_delay = .5 #second
ardustat_id = 16
file_name = "AAA_Test"
ardustat_socket = 7777
debug = False
pulse_time = 600

#Below here no touchy
#connect to to ardustat and setup resistance table
a = ard.ardustat()
a.connect(ardustat_socket)
a.debug = debug
a.load_resistance_table(ardustat_id)
a.ocv()
a.groundvalue = 2.5
a.moveground()
time.sleep(.2)
a.ocv()


#create arrays + a function for logging data
times = []
potential = []
current = []
time_start = time.time()
cycle = 0
Beispiel #4
0
import glob
import sys

##Guess a serial port
port = ""
if os.name == "posix":
	#try os x
	if len(glob.glob("/dev/tty.u*")) > 0:
		port = glob.glob("/dev/tty.u*")[0]
	elif len(glob.glob("/dev/ttyUSB*")) > 0:
		port = glob.glob("/dev/ttyUSB*")[0]
	else:
		print "can't see any ardustats.  PEACE."
		sys.exit()
	print port
	

#start a serial forwarder
p = subprocess.Popen(("python tcp_serial_redirect.py "+port+" 57600").split())
print "waiting"
time.sleep(5)
print "going"
a = ard.ardustat()
a.connect(7777)
foo = a.calibrate(9974,16)

for f in foo:
	print f,foo[f]
	
a.s.close()
p.kill()
Beispiel #5
0
def runGalvo(curr1=0.002, curr2=-0.002, vmax=1.6, vmin=0.9, cycles=4):
        #connecto to ardustat and setup resistance table
        #for i in range (0,3):
        a = ard.ardustat()
        a.connect(7777)
        a.debug = False
        #a.calibrate(15000,16)
        a.load_resistance_table(16)
        read = a.parsedread()
        print "Resistance table loaded"
        time.sleep(1)
        #create arrays + a function for logging data

                    
        """
        subplot(3,1,1)
        potLine, = plot(times,potential,'.')
        title("Potential vs. Time")
        ylabel("Potential (V)")

        subplot(3,1,2)
        curLine, = plot(times,current,'.')
        title("Current vs. Time")
        ylabel("Current (A)")
        subplot(3,1,3)
        resLine, = plot(times,numpy.array(potential)/numpy.array(current))
        title("Resistance vs. Time")
        ylabel("Resistance (Ohms)")
        xlabel("Time (s)")
        

        #ion()                           # interaction mode needs to be turned off
 
        x = arange(0,2*pi,0.01)         # we'll create an x-axis from 0 to 2 pi
        line, = plot(x,x)               # this is our initial plot, and does nothing
        line.axes.set_ylim(-3,3)        # set the range for our plot
         
        starttime = time.time()         # this is our start time
        t = 0                           # this is our relative start time

        """
        
        """
        #Step through values
        output = 0
        print a.ocv()
        print -1
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                print i


        #output = 0
        #while output < 2:
        output = 1.24
                #output = output + .01
        print a.potentiostat(output)
        for i in range(0,300):
        #for i in range(0,100):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                       
        if str(a.ocv()) == "None":
                print "None"
                #connecto to ardustat and setup resistance table
                a = ard.ardustat()
                a.connect(7777)
                a.debug = False
                #a.calibrate(15000,16)
                a.load_resistance_table(16)
                time.sleep(.1)
              
        print a.ocv()
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                print "Appending initial values!"
                appender(read)
                if not RealTime.TickTock(False):
                        return
        
          """
        
        #output = 0
        #while output < .001:
        #output = -curr # new line
        #print  curr
        #print  output
        numCycles = int (cycles)
        for i in range (0,numCycles): # new line
                #output = output + .00001
                #output = -output # new line
                #print output
                if not RealTime.ocv_on():
                        if (i%2) == 0:
                                a.galvanostat(curr1)
                        else:
                                a.galvanostat(curr2)
                #for i in range(0,3):
                if (i%2) == 0:
                        voltage = vmin
                        while voltage < vmax:#for i in range (0,100): # new line
                                if RealTime.paused():
                                        handle_paused()
                                if RealTime.ocv_on():
                                        handle_ocv(a,"galvo",curr1)
                                time.sleep(.01)
                                read = a.parsedread()
                                appender(read)
                                voltage = read['cell_ADC']
                                if not RealTime.TickTock(False):
                                        return
                                        
                else:
                        voltage = vmax
                        while voltage > vmin:
                                if RealTime.paused():
                                        handle_paused()
                                if RealTime.ocv_on():
                                        handle_ocv(a,"galvo",curr2)
                                time.sleep(.01)
                                read = a.parsedread()
                                appender(read)
                                voltage = read['cell_ADC']
                                if not RealTime.TickTock(False):
                                        return
                        

        
        """
        print a.ocv()
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
        """
        
        while True:
                if RealTime.ocv_on():
                        handle_ocv(a)
                elif not RealTime.TickTock(True):
                        return
        
        """
Beispiel #6
0
def runPot(vol=1.4, cur=.001, slope=.01):
        #connecto to ardustat and setup resistance table
        #for i in range (0,3):
        a = ard.ardustat()
        a.connect(7777)
        a.debug = False
        #a.calibrate(15000,16)
        a.load_resistance_table(16)
        time.sleep(1)

        #create arrays + a function for logging data

                    
        """
        subplot(3,1,1)
        potLine, = plot(times,potential,'.')
        title("Potential vs. Time")
        ylabel("Potential (V)")

        subplot(3,1,2)
        curLine, = plot(times,current,'.')
        title("Current vs. Time")
        ylabel("Current (A)")
        subplot(3,1,3)
        resLine, = plot(times,numpy.array(potential)/numpy.array(current))
        title("Resistance vs. Time")
        ylabel("Resistance (Ohms)")
        xlabel("Time (s)")
        

        #ion()                           # interaction mode needs to be turned off
 
        x = arange(0,2*pi,0.01)         # we'll create an x-axis from 0 to 2 pi
        line, = plot(x,x)               # this is our initial plot, and does nothing
        line.axes.set_ylim(-3,3)        # set the range for our plot
         
        starttime = time.time()         # this is our start time
        t = 0                           # this is our relative start time

        """
        """
        #Step through values
        output = 0
        print a.ocv()
        print -1
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                print i


        #output = 0
        #while output < 2:
        output = 1.24
                #output = output + .01
        print a.potentiostat(output)
        for i in range(0,300):
        #for i in range(0,100):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                       
        if str(a.ocv()) == "None":
                #connecto to ardustat and setup resistance table
                a = ard.ardustat()
                a.connect(7777)
                a.debug = False
                #a.calibrate(15000,16)
                a.load_resistance_table(16)
                
        a.ocv()
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)

        

        
        read = a.parsedread()
        appender(read)
        voltage = volmeasured = read['cell_ADC']
        while volmeasured < vol:
                voltage += slope
                a.potentiostat(voltage)
                read = a.parsedread()
                appender(read)
                volmeasured = read['cell_ADC']
                if not RealTime.TickTock(False):
                        return
                time.sleep(.01)
        """
        if not RealTime.ocv_on():
                potentiostat(a,vol)
        read = a.parsedread()
        appender(read)
        currmeasured = read['current']
        #volmeasured = read['cell_ADC']
        #vol = vol - volmeasured
        while True:#while currmeasured > cur:
                if RealTime.paused():
                        handle_paused()
                if RealTime.ocv_on():
                        handle_ocv(a,"pot",vol)
                read = a.parsedread()
                appender(read)
                currmeasured = read['current']
                if not RealTime.TickTock(False):
                        return
                time.sleep(.01)

        while True:
                if RealTime.ocv_on():
                        handle_ocv(a)
                elif not RealTime.TickTock(True):
                        return
Beispiel #7
0
def runGalvo(curr1=0.002, curr2=-0.002, vmax=1.6, vmin=0.9, cycles=4):
    #connecto to ardustat and setup resistance table
    #for i in range (0,3):
    a = ard.ardustat()
    a.connect(7777)
    a.debug = False
    #a.calibrate(15000,16)
    a.load_resistance_table(16)
    read = a.parsedread()
    print "Resistance table loaded"
    time.sleep(1)
    #create arrays + a function for logging data
    """
        subplot(3,1,1)
        potLine, = plot(times,potential,'.')
        title("Potential vs. Time")
        ylabel("Potential (V)")

        subplot(3,1,2)
        curLine, = plot(times,current,'.')
        title("Current vs. Time")
        ylabel("Current (A)")
        subplot(3,1,3)
        resLine, = plot(times,numpy.array(potential)/numpy.array(current))
        title("Resistance vs. Time")
        ylabel("Resistance (Ohms)")
        xlabel("Time (s)")
        

        #ion()                           # interaction mode needs to be turned off
 
        x = arange(0,2*pi,0.01)         # we'll create an x-axis from 0 to 2 pi
        line, = plot(x,x)               # this is our initial plot, and does nothing
        line.axes.set_ylim(-3,3)        # set the range for our plot
         
        starttime = time.time()         # this is our start time
        t = 0                           # this is our relative start time

        """
    """
        #Step through values
        output = 0
        print a.ocv()
        print -1
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                print i


        #output = 0
        #while output < 2:
        output = 1.24
                #output = output + .01
        print a.potentiostat(output)
        for i in range(0,300):
        #for i in range(0,100):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                       
        if str(a.ocv()) == "None":
                print "None"
                #connecto to ardustat and setup resistance table
                a = ard.ardustat()
                a.connect(7777)
                a.debug = False
                #a.calibrate(15000,16)
                a.load_resistance_table(16)
                time.sleep(.1)
              
        print a.ocv()
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                print "Appending initial values!"
                appender(read)
                if not RealTime.TickTock(False):
                        return
        
          """

    #output = 0
    #while output < .001:
    #output = -curr # new line
    #print  curr
    #print  output
    numCycles = int(cycles)
    for i in range(0, numCycles):  # new line
        #output = output + .00001
        #output = -output # new line
        #print output
        if not RealTime.ocv_on():
            if (i % 2) == 0:
                a.galvanostat(curr1)
            else:
                a.galvanostat(curr2)
        #for i in range(0,3):
        if (i % 2) == 0:
            voltage = vmin
            while voltage < vmax:  #for i in range (0,100): # new line
                if RealTime.paused():
                    handle_paused()
                if RealTime.ocv_on():
                    handle_ocv(a, "galvo", curr1)
                time.sleep(.01)
                read = a.parsedread()
                appender(read)
                voltage = read['cell_ADC']
                if not RealTime.TickTock(False):
                    return

        else:
            voltage = vmax
            while voltage > vmin:
                if RealTime.paused():
                    handle_paused()
                if RealTime.ocv_on():
                    handle_ocv(a, "galvo", curr2)
                time.sleep(.01)
                read = a.parsedread()
                appender(read)
                voltage = read['cell_ADC']
                if not RealTime.TickTock(False):
                    return
    """
        print a.ocv()
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
        """

    while True:
        if RealTime.ocv_on():
            handle_ocv(a)
        elif not RealTime.TickTock(True):
            return
    """
Beispiel #8
0
def runPot(vol=1.4, cur=.001, slope=.01):
    #connecto to ardustat and setup resistance table
    #for i in range (0,3):
    a = ard.ardustat()
    a.connect(7777)
    a.debug = False
    #a.calibrate(15000,16)
    a.load_resistance_table(16)
    time.sleep(1)

    #create arrays + a function for logging data
    """
        subplot(3,1,1)
        potLine, = plot(times,potential,'.')
        title("Potential vs. Time")
        ylabel("Potential (V)")

        subplot(3,1,2)
        curLine, = plot(times,current,'.')
        title("Current vs. Time")
        ylabel("Current (A)")
        subplot(3,1,3)
        resLine, = plot(times,numpy.array(potential)/numpy.array(current))
        title("Resistance vs. Time")
        ylabel("Resistance (Ohms)")
        xlabel("Time (s)")
        

        #ion()                           # interaction mode needs to be turned off
 
        x = arange(0,2*pi,0.01)         # we'll create an x-axis from 0 to 2 pi
        line, = plot(x,x)               # this is our initial plot, and does nothing
        line.axes.set_ylim(-3,3)        # set the range for our plot
         
        starttime = time.time()         # this is our start time
        t = 0                           # this is our relative start time

        """
    """
        #Step through values
        output = 0
        print a.ocv()
        print -1
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                print i


        #output = 0
        #while output < 2:
        output = 1.24
                #output = output + .01
        print a.potentiostat(output)
        for i in range(0,300):
        #for i in range(0,100):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)
                       
        if str(a.ocv()) == "None":
                #connecto to ardustat and setup resistance table
                a = ard.ardustat()
                a.connect(7777)
                a.debug = False
                #a.calibrate(15000,16)
                a.load_resistance_table(16)
                
        a.ocv()
        for i in range(0,10):
                time.sleep(.1)
                read = a.parsedread()
                appender(read)

        

        
        read = a.parsedread()
        appender(read)
        voltage = volmeasured = read['cell_ADC']
        while volmeasured < vol:
                voltage += slope
                a.potentiostat(voltage)
                read = a.parsedread()
                appender(read)
                volmeasured = read['cell_ADC']
                if not RealTime.TickTock(False):
                        return
                time.sleep(.01)
        """
    if not RealTime.ocv_on():
        potentiostat(a, vol)
    read = a.parsedread()
    appender(read)
    currmeasured = read['current']
    #volmeasured = read['cell_ADC']
    #vol = vol - volmeasured
    while True:  #while currmeasured > cur:
        if RealTime.paused():
            handle_paused()
        if RealTime.ocv_on():
            handle_ocv(a, "pot", vol)
        read = a.parsedread()
        appender(read)
        currmeasured = read['current']
        if not RealTime.TickTock(False):
            return
        time.sleep(.01)

    while True:
        if RealTime.ocv_on():
            handle_ocv(a)
        elif not RealTime.TickTock(True):
            return