Пример #1
0
def readU6Counter(counternumber=0):
    """
    We need to see what state the counter IO is in. If it's already a counter, we just read it.
    If it is not yet a counter, we instantiate it and return count of 0

    Also, this is not safe when other timer and counter inputs are used. For now, this is just one singular counter
    """

    import u6
    from iiutilities.datalib import gettimestring
    device = u6.U6()

    result = {'readtime': gettimestring()}

    # When passed no argument, just reads.
    currentconfig = device.configIO()
    try:
        device.getCalibrationData()
        if currentconfig['Counter0Enabled'] or currentconfig[
                'NumberTimersEnabled'] != 1:
            device.configIO(EnableCounter0=True, NumberTimersEnabled=1)
            device.getFeedback(u6.Timer0Config(TimerMode=6, Value=1))

        result['value'] = device.getFeedback(u6.Timer0())[0]

    except:
        pass
        # Error handling ....

    device.close()

    return result
Пример #2
0
    def loadDevice(self, deviceType):
        """
        Name: loadDevice(deviceType)
        Desc: loads the first device of device type
        """

        self.deviceType = deviceType

        # Determine which device to use
        if self.deviceType == LJTickDAC.U3:
            self.device = u3.U3()
        elif self.deviceType == LJTickDAC.U6:
            self.device = u6.U6()
        else:
            self.device = ue9.UE9()

        # Display serial number
        self.serialDisplay.config(text=self.device.serialNumber)

        # Configure pins if U3
        if self.deviceType == LJTickDAC.U3:
            self.device.configIO(
                FIOAnalog=15,
                TimerCounterPinOffset=8)  # Configures FIO0-2 as analog

        # Get the calibration constants
        self.getCalConstants()
Пример #3
0
	def __init__(self):
		self.device = u6.U6()
		print self.device.configU6()
		
		#for the labjack
		self.numChannels = 12
		self.firstChannel = 2
		self.resolutionIndex = 4
		self.gainIndex = 0
		self.settlingFactor = 0
		self.differential = False
		
		self.latestAinValues = np.array([0]*self.numChannels, dtype='float')
		self.lastForceMoments = np.array([0]*self.numChannels, dtype='float')
		self.latestForceMoments = np.array([0]*self.numChannels, dtype='float')
		self.zero = np.array([0]*self.numChannels, dtype='float')
		
		self.lastTime = 0
		self.latestTime = 0
		
		self.lastLeftOn = False
		self.latestLeftOn = False
		self.lastLeftCOP = [0, 0]
		self.latestLeftCOP = [0, 0]

		self.lastRightOn = False
		self.latestRightOn = False
		self.lastRightCOP = [0, 0]
		self.latestRightCOP = [0, 0]
		
		FIOEIOAnalog = ( 2 ** self.numChannels ) - 1;
		fios = FIOEIOAnalog & (0xFF)
		eios = FIOEIOAnalog/256
		self.device.getFeedback(u6.PortDirWrite(Direction = [0, 0, 0], WriteMask = [0, 0, 15]))
		self.feedbackArguments = []
		self.feedbackArguments.append(u6.DAC0_8(Value = 125))
		self.feedbackArguments.append(u6.PortStateRead())
		for i in range(self.firstChannel, self.numChannels+self.firstChannel):
			self.feedbackArguments.append( u6.AIN24(i, self.resolutionIndex, self.gainIndex, self.settlingFactor, self.differential) )
			
		self.task = viztask.schedule(self.__update)
		self.going = True
		self.history = []
		self.recording = False
		
		#magic numbers to turn volts into Newtons and Newton.meters
		#left is stored in first 6 (x,y,z,mx,my,mz) and right in second 6
		self.M = np.array([[0, -2.309900 , 0.000000 , 1.308000 , 0.000000 , 2.306800 , 0.000000 , -495.780000 , 0.000000 , -494.040000 , 0.000000 , -2.034400],\
			[0, 6.308900 , 0.000000 , 5.913600 , 0.000000 , 11.633000 , 0.000000 , -2.295700 , 0.000000 , -13.079000 , 0.000000 , 499.990000],\
			[0, -491.360000 , 0.000000 , -488.510000 , 0.000000 , -488.270000 , 0.000000 , 5.064000 , 0.000000 , 6.732400 , 0.000000 , 0.391790],\
			[0, 48.162000 , 0.000000 , -298.930000 , 0.000000 , 299.410000 , 0.000000 , -1.565600 , 0.000000 , 4.956800 , 0.000000 , 54.786000],\
			[0, -254.760000 , 0.000000 , -26.647000 , 0.000000 , -25.153000 , 0.000000 , 42.462000 , 0.000000 , 42.087000 , 0.000000 , 1.601900],\
			[0, -7.032800 , 0.000000 , 1.345700 , 0.000000 , -1.140100 , 0.000000 , -243.640000 , 0.000000 , 354.550000 , 0.000000 , -4.020500],\
			[-2.688400 , 0.000000 , -0.083334 , 0.000000 , 1.258500 , 0.000000 , 491.220000 , 0.000000 , -495.750000 , 0.000000 , -6.723600 , 0],\
			[-7.642900 , 0.000000 , -5.959700 , 0.000000 , -3.659100 , 0.000000 , 15.847000 , 0.000000 , -12.401000 , 0.000000 , 507.580000 , 0],\
			[-490.840000 , 0.000000 , -490.690000 , 0.000000 , -492.520000 , 0.000000 , -6.428000 , 0.000000 , 3.723600 , 0.000000 , 4.807000 , 0],\
			[300.830000 , 0.000000 , -300.260000 , 0.000000 , 48.265000 , 0.000000 , -5.152500 , 0.000000 , -1.434500 , 0.000000 , 49.278000 , 0],\
			[26.955000 , 0.000000 , 27.005000 , 0.000000 , 253.680000 , 0.000000 , -40.116000 , 0.000000 , 41.703000 , 0.000000 , -1.501700 , 0],\
			[-1.380200 , 0.000000 , -2.450800 , 0.000000 , -1.349500 , 0.000000 , -348.250000 , 0.000000 , -245.680000 , 0.000000 , 10.366000 , 0]],\
			dtype='float')
Пример #4
0
 def __init__(self):
     self.devicename = 'LJ'
     self.lj = u6.U6()
     self.dacPin = LabJack.DAC_PIN_DEFAULT
     self.sclPin = self.dacPin
     self.sdaPin = self.sclPin + 1
     self.getCalConstants()
Пример #5
0
def read_volts(ch, dmmtype):
    global dmm
    v = []
    if dmmtype == "u6":
        if diff:
            di = 2
            iend = int(ch) * 2
        else:
            di = 1
            iend = int(ch)

        for i in range(0, iend, di):
            try:
                v.append(dmm.getAIN(i, differential=diff))
            except:
                print("Got zero packet")
                dmm.close()
                time.sleep(0.5)
                dmm = u6.U6()
                dmm.getCalibrationData()
                v.append(np.nan)

    elif dmmtype == "agil":
        v = float(dmm.ask(":MEAS:VOLT:DC?"))
    elif dmmtype == "test":
        for i in range(0, int(ch)):
            v.append(np.random.randn())
    else:
        raise ValueError("Acquisition Type not recognized.")
    return v
Пример #6
0
    def __init__( self, parameters ):
        # number of packets to be read
        self.max_packets = parameters['max_packets']
        
        # At high frequencies ( >5 kHz), the number of samples will be max_packets
        # times 48 (packets per request) times 25 (samples per packet)
        self.num_samples = self.max_packets*48*25

        # initialize LabJack U6 device
        self.d = u6.U6()
    
        # For applying the proper calibration to readings.
        self.d.getCalibrationData()

        # number of analog channels
        self.num_analog_channels = parameters['num_analog_channels']

        # configure stream
        print "configuring U6 stream"
        self.d.streamConfig( NumChannels = self.num_analog_channels,
                             ChannelNumbers = range(self.num_analog_channels),
                             ChannelOptions = [0]*self.num_analog_channels,
                             SettlingFactor = 1,
                             ResolutionIndex = 1,
                             SampleFrequency = 50000/self.num_analog_channels )

        # get stream reader
        self.sdr = StreamDataReader(self.d,max_packets=self.max_packets)
        self.sdrThread = threading.Thread(target = self.sdr.readStreamData)

        # output list
        self.out = []
        self.out_arr = None
    def start(self):
        """
        Name:MainWindow.start()
        Desc:Starts reading values from EI1050 probe
        """
        try:
            # Get device selection
            if len(LabJackPython.listAll(3)) > 0:
                self.device = u3.U3()
            elif len(LabJackPython.listAll(6)) > 0:
                self.device = u6.U6()
            else:
                self.device = ue9.UE9()

            self.serialDisplay.config(text=self.device.serialNumber)

            # Create and start the thread
            self.thread = ei1050.EI1050Reader(self.device, self.targetQueue)

            # Start scheduleing
            self.window.after(1000, self.updateLabels)
            self.thread.start()

            # Change button
            self.startButton.config(text="Stop", command=self.stop)
        except:
            showErrorWindow(sys.exc_info()[0], sys.exc_info()[1])
Пример #8
0
def acquireStack(cam, nFrames, downscaleTuple, animal, outdir):
    """   Get an image stack from the camera.
     Args:
        cam: (TIS_CAM) initialized camera object
        nFrames: (int) number of frames to acquire
        sendCounter (bool) whether or not to send strobe signal
        downscaleTuple: (tuple) downscale factor in (z, x, y), e.g. (1, 2, 2) for 2x downscale
        animal: (str) animal ID, used for output naming
        outdir: (str) path to output directory

    Returns:
        stack: (np.ndarray) image stack in (z, x, y)
    """
    # setup the labjack
    dioPortNum = 0  # FIO0
    u6Obj = u6.U6()
    u6Obj.configU6()
    u6Obj.configIO()
    u6Obj.setDOState(dioPortNum, state=0)

    stack = []

    cam.StartLive(1)
    # Not using 191001: strobe code below.
    # if sendCounter:
    #     _set_and_check(cam.SetPropertyValue, 'GPIO', 'GP Out', 1)
    #     _set_and_check(cam.PropertyOnePush, 'GPIO', 'Write')
    t_start = time.time()
    for iF in np.arange(nFrames):
        pulseLengthTicks = int(1000/64)
        u6Obj.getFeedback(u6.BitDirWrite(dioPortNum, 1),
                          u6.BitStateWrite(dioPortNum, State=1),
                          u6.WaitShort(pulseLengthTicks),
                          u6.BitStateWrite(dioPortNum, State=0))
        cam.SnapImage()
        im = cam.GetImage()  # appears to have three identical(?) frames
        im = np.mean(im, axis=2).astype('int16')
        stack.append(im)  # averaging to one frame

    # Not using 191001: strobe code below.
    # if sendCounter:
    #     _set_and_check(cam.SetPropertyValue, 'GPIO', 'GP Out', 0)
    #     _set_and_check(cam.PropertyOnePush, 'GPIO', 'Write')

    cam.StopLive()

    print('Done. Downsizing and saving.')
    stack = np.r_[stack]
    stack = transform.downscale_local_mean(stack, downscaleTuple)
    stack = stack.astype('int16')

    timeStr = time.strftime("_%y%m%d_%H-%M-%S", time.localtime(t_start))
    outfile = os.path.join(outdir, '{}{}.tif'.format(animal, timeStr))
    tfl.imsave(outfile, stack)
    nFrames = stack.shape[0]

    print('Saved {} frames to {}'.format(nFrames, outfile))

    return stack
Пример #9
0
 def connect(self):
     """
     Connect to U6 LabJack.
     """
     try:
         self.sensor = u6.U6()
     except TypeError:
         print("Can't find LabJack. Is it connected?")
Пример #10
0
 def connect(self):
     self._device = u6.U6()
     self._device.getCalibrationData()
     # Set up a frequency source for testing.
     self._device.configIO(NumberTimersEnabled=1)
     # 1MHz / 250 = 4 kHz
     self._device.configTimerClock(3, 250)
     # 4KHz / 2 * 16 = 125 Hz
     self._device.getFeedback(u6.Timer0Config(7, 16))
    def connect(self):

        iscompleted = False

        nbattempts = 0

        while not(iscompleted) and nbattempts<1000:#while iscompleted is false and nb<1000   will be doing this constantly

            try:

                nbattempts = nbattempts +1

                #print ('Attempt nb ' + str(nbattempts))

                self.jack = u6.U6()

                iscompleted = True

            except:

                print('Pb with labjack initialisation nb '+ str(nbattempts))

                time.sleep(0.01)

        if not(iscompleted): #if iscompleted  equals false   which would give true he 

            raise IOError('Labjack could not connect')

    

		# the FIO0-FIO7 inputs are flexible, meaning they can be analog or digital, so ensure

		# they are all digital by sending a zero for the FIO Analog parameter

		# self.jack.configIO(FIOAnalog = 0)



		# now set all the channels to output, since each digital IO channel supports input and output

        for channel in BIOPAC_CHANNELS:

            #self.jack.getFeedback(u6.BitDirWrite(channel,DIGITAL_CHANNEL_DIRECTION_OUTPUT))

            self.sendMsg(u6.BitDirWrite(channel,DIGITAL_CHANNEL_DIRECTION_OUTPUT))

        for channel in EYETRACKER_CHANNELS:

            #self.jack.getFeedback(u6.BitDirWrite(channel,DIGITAL_CHANNEL_DIRECTION_OUTPUT))

            self.sendMsg(u6.BitDirWrite(channel,DIGITAL_CHANNEL_DIRECTION_OUTPUT))

        for channel in DIGITIMER_CHANNELS:

            #self.jack.getFeedback(u6.BitDirWrite(channel, DIGITAL_CHANNEL_DIRECTION_OUTPUT))

            self.sendMsg(u6.BitDirWrite(channel, DIGITAL_CHANNEL_DIRECTION_OUTPUT))
Пример #12
0
 def __init__(self):
     # A buffer for incoming data. Use deque for fast writes.
     self.buffer = deque()
     # Integration time in seconds
     self.t_integrate = 1
     self._device = u6.U6()
     self._device.getCalibrationData()
     self._barrier = threading.Barrier(2)
     self.data_ready = threading.Event()
Пример #13
0
def check_pressure():
    fh = open('pressure_data.txt', 'a+')
    d = u6.U6()
    AIN_channel = 6  #set MOT AIN channel here
    AIN_voltage = d.getAIN(AIN_channel)
    a = float(int(AIN_voltage)) - 11.0
    b = (AIN_voltage - float(int(AIN_voltage)) + 0.1) / 0.11
    current_mot_pressure = round(b, 3) * 10**a
    e = u6.U6()
    AIN_channel_2 = 10  #set backing AIN channel here
    AIN_voltage = e.getAIN(AIN_channel_2)
    current_backing_pressure = round(10**(float(AIN_voltage) - 5.0) * 1000.0,
                                     1)
    fh.write(
        str(current_backing_pressure) + " , " + str(current_mot_pressure) +
        " , " + (time.strftime("%H:%M:%S")) + " , " +
        (time.strftime("%d/%m/%Y")) + " \n")
    fh.close()
    print("backing pressure: " + str(current_backing_pressure) + " mTorr  " +
          "MOT pressure: " + str(current_mot_pressure) + " Torr")
    return current_mot_pressure, current_backing_pressure
Пример #14
0
def init_device():
    d = u6.U6()
    #
    ## For applying the proper calibration to readings.
    d.getCalibrationData()
    #
    logging.info("configuring U6 stream")
    d.streamConfig(NumChannels=6,
                   ChannelNumbers=[0, 2, 4, 6, 8, 10],
                   ChannelOptions=[128, 128, 128, 128, 128, 128],
                   SettlingFactor=1,
                   ResolutionIndex=1,
                   SampleFrequency=1000)
    return d
Пример #15
0
 def connectDevice(self):
     try:
         if self.runningFlag:
             pass
         else:
             self.labJackU6 = u6.U6()
             self.labJackU6.getCalibrationData()
             self.checkConnectionThread()
             self.supportClass.statusBar.showMessage(
                 "Connection State: Connected")
             self.runningFlag = True
             self.supportClass.runningFlag = True
         return True
     except Exception as e:
         print(e)
         return False
Пример #16
0
    def __init__(self):
        super().__init__()
        self.grid_rowconfigure(0, w=1)
        self.grid_columnconfigure(0, w=1)
        self.grid_columnconfigure(1, w=1)

        self.Dict = {
                'AIN0' : 'Failure',
                'AIN1' : 'Low Speed',
                'AIN2' : 'Frequency',
                'AIN3' : 'Supply Current',
                'AIN4' : 'Driving Frequency',
                'FIO3' : 'Error Reset',
                'FIO4' : 'On/Off',
                'FIO5' : 'Low Speed Activate',
                'FIO6' : 'Enable Override',
                'DAC0' : 'Direction',
                'FIO0' : 'Frequency Driver',
                'FIO1' : 'Timer Stop',
                'AIN5' : 'Inner Limit Switch',
                'AIN6' : 'Outer Limit Switch',
                }

        s = ttk.Style()
        s.configure('.', font=('Times', 18))
        s.configure('Header.TLabel', font=('Times', 24))

        self.DevFlag = False
        try:
            self.LJ = u6.U6()
            self.LJ.getCalibrationData()
            for i in range(20):
                self.LJ.getFeedback(u6.BitDirWrite(i, 0)) # output
            self.LJ.configTimerClock(TimerClockBase=3, TimerClockDivisor=2)
            self.LJ.configIO(NumberTimersEnabled=2)
        except:
            self.DevFlag = True
            print('Dev')

        self.turbo = TurboController(self)
        self.turbo.grid(row=0, column=0, sticky='news')

        self.stepper = StepperController(self)
        self.stepper.grid(row=0, column=1, sticky='news')
Пример #17
0
def readU6Analog(positiveChannel,
                 resolutionIndex=0,
                 gainIndex=0,
                 settlingFactor=0,
                 differential=False):
    """
    Name: U6.getAIN(positiveChannel, resolutionIndex = 0, gainIndex = 0,
                    settlingFactor = 0, differential = False)
    Args: positiveChannel, the positive channel to read from
          resolutionIndex, the resolution index.  0 = default, 1-8 = high-speed
                           ADC, 9-12 = high-res ADC (U6-Pro only).
          gainIndex, the gain index.  0=x1, 1=x10, 2=x100, 3=x1000,
                     15=autorange.
          settlingFactor, the settling factor.  0=Auto, 1=20us, 2=50us,
                          3=100us, 4=200us, 5=500us, 6=1ms, 7=2ms, 8=5ms,
                          9=10ms.
          differential, set to True for differential reading.  Negative
                        channel is positiveChannel+1.
    Desc: Reads an AIN and applies the calibration constants to it.

    >>> myU6.getAIN(14)
    299.87723471224308

    strRanges = ["+/- 10", "+/- 1", "+/- 0.1", "+/- 0.01"]

    """
    from iiutilities.datalib import gettimestring
    import u6
    result = {}
    device = u6.U6()
    result['readtime'] = gettimestring()
    try:
        device.getCalibrationData()
        result['value'] = device.getAIN(positiveChannel, resolutionIndex,
                                        gainIndex, settlingFactor,
                                        differential)
    except:
        #handle stuff ...
        pass
    device.close()

    return result
Пример #18
0
def record_pressure_trace(time_interval=600):
    """ """
    import time

    d = u6.U6()
    d.configU6()
    pkr = PKR251(d)

    pressure = []
    t = []

    t0 = time.time()
    for i in range(time_interval):
        pressure.append(pkr.get_pressure('torr'))
        t.append(time.time() - t0)
        time.sleep(1)
        print('time: {0:.2f}s; pressure: {1:2e}torr'.format(
            t[-1], pressure[-1]))

    return t, pressure
Пример #19
0
    def __init__(self):
        '''
        Initializing the a QuenchManager involves reading the hardware data
        for the quenches from quench.csv, and opening the relevant LabJacks.
        This will not work for more than one instance of a QuenchManager since
        LabJacks cannot be opened from more than one Python kernel at a time.
        '''

        # Open quench information file.
        self.quench_info = quench_info
        num_quenches = len(self.quench_info.index)

        # Create new columns specifically for this instance of a QuenchManager.
        self.quench_info["Is Open"] = [False for i in range(num_quenches)]
        self.quench_info["Is On"] = [False for i in range(num_quenches)]
        self.quench_info["Handle"] = [None for i in range(num_quenches)]

        # Open the relevant LabJacks.
        try:
            self.quench_u3 = u3.U3(autoOpen=False)
            self.quench_u3.open(serial=320044466)
            self.quench_u3.configIO(FIOAnalog=255)
        except LabJackException as err:
            print("U3 error:")
            print(err.__str__)
            raise err
        finally:
            print("U3 opened")

        try:
            self.quench_u6 = u6.U6(autoOpen=False)
            self.quench_u6.open(serial=360007343)
        except LabJackException as err:
            print("U6 error:")
            print(err.__str__)
            raise err
        finally:
            print("U6 opened")
Пример #20
0
def readU6(registers):

    import u6
    from iiutilities.datalib import gettimestring
    device = u6.U6()

    resultslist = []
    for register in registers:
        try:
            value = device.readRegister(register)
            status = 0
        except:
            value = ''
            status = 1

        resultslist.append({
            'register': register,
            'value': value,
            'status': status,
            'time': gettimestring()
        })
        print(resultslist)

    return resultslist
Пример #21
0
"""
The default SPI settings for a U6 are:

  AutoCS = True, DisableDirConfig = False, SPIMode = 'A', SPIClockFactor = 0,
  CSPinNum = 0 (FIO0), CLKPinNum = 1 (FIO1), MISOPinNum = 2 (FIO2),
  MOSIPinNum = 3 (FIO3)

Note the CSPinNum, CLKPinNum, MISOPinNum, and MOSIPinNum pin numbers and make
your connections accordingly.
"""
from __future__ import print_function
import os
import time

import u6
d = u6.U6()  #Open first found U6 over USB


def convert(inByte2, inByte3):
    combined = inByte2 * 256 + inByte3
    return combined


while (True):
    d.setDOState(4, 0)

    results = d.spi([0x00, 0])
    inByte1 = results['SPIBytes'][0]
    inByte2 = results['SPIBytes'][1]
    results = d.spi([0x00, 0])
    inByte3 = results['SPIBytes'][0]
Пример #22
0
 def connect(self):
     self.d = u6.U6()
     self.d.getCalibrationData()
Пример #23
0
def init_comm():
    global chan_d
    chan_d['port'] = u6.U6()
Пример #24
0
if failed==False:
    #set up some options that should not change often
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_MODE","UPLOAD_CLIENT","Off")
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_MODE","UPLOAD_BOTH","Off")
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_MODE","UPLOAD_LOCAL","On")
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","CCD_COOLER","COOLER_ON","On")
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","CCD_COOLER","COOLER_OFF","Off")
#   Default binning is 1x1. Not need to set this as it is a CCD default.
#    dummy=indi.set_and_send_float("SX CCD SXVR-H694","CCD_BINNING","VER_BIN",2)
    if not os.path.exists('./images/'):
        dummy=subprocess.call('mkdir ./images', shell=True)
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_SETTINGS","UPLOAD_DIR","images")
    dummy=indi.set_and_send_text("SX CCD SXVR-H694","UPLOAD_SETTINGS","UPLOAD_PREFIX","TEMPIMAGE")
    
try:
    LJ=u6.U6()
    #Need to set up fancy DAC here for the temperature control
    #LJ.configIO(NumberOfTimersEnabled = 2, EnableCounter0 = 1, TimerCounterPinOffset=8)
    #LJ.getFeedback(u3.Timer0Config(8), u3.Timer1Config(8)) #Sets up the dome tracking wheel

    #Start off with no current:
    LJ.getFeedback(u6.BitStateWrite(1,0)) #H-Bridge bit 1
    LJ.getFeedback(u6.BitStateWrite(2,0)) #H-Bridge bit 2
    LJ.getFeedback(u6.BitStateWrite(3,0)) #Back-LED Off
except Exception:
    print 'Unable to connect to the labjack.'


class Subaru():
    """As this server class controls several pieces of hardware at once, d
      defaults for this class are in blocks, in the order below... 
Пример #25
0
from numpy import *
import u6

h = u6.U6()

while True:
    tF0 = h.getFeedback(u6.PortDirRead())
    tF1 = h.getFeedback(u6.PortStateRead())

    print tF0, tF1




















try:
    import Queue
except ImportError:  # Python 3
    import queue as Queue

import u6

# MAX_REQUESTS is the number of packets to be read.
MAX_REQUESTS = 2500

################################################################################
## U6
## Uncomment these lines to stream from a U6
################################################################################
## At high frequencies ( >5 kHz), the number of samples will be MAX_REQUESTS times 48 (packets per request) times 25 (samples per packet)
d = u6.U6()
#
## For applying the proper calibration to readings.
d.getCalibrationData()
#
print "configuring U6 stream"
d.streamConfig(NumChannels=1,
               ChannelNumbers=[0],
               ChannelOptions=[0],
               SettlingFactor=1,
               ResolutionIndex=1,
               SampleFrequency=50000)


class StreamDataReader(object):
    def __init__(self, device):
Пример #27
0
@author: paulnakroshis
"""

# streamU3.py
# Peter N. Saeta, 2011 July 2
# Using the LabJack U3, sample four voltages at a fixed sampling rate
# and log the results to a text file. This file can then be used by
# Igor to manage further analysis

import u6
from time import sleep
from math import *

# Prepare the u3 interface for streaming

d = u6.U6(
)  # initialize the interface; assumes a single U3 is plugged in to a USB port
d.configU6()  # set default configuration
#d.configIO( FIOAnalog = 1 )		# ask for analog inputs

# The following requests 4 analog input channels to be streamed,
# with the positive terminals being 0-3 and the negative terminals
# all set to 31. The sampling frequency is 5000 samples (of each channel)
# per second. The Resolution parameter sets the effective quality of the
# samples. See http://labjack.com/support/u3/users-guide/3.2
d.streamConfig(NumChannels=4,
               PChannels=[0, 1, 2, 3],
               NChannels=[31, 31, 31, 31],
               Resolution=3,
               SampleFrequency=5000)

d.packetsPerRequest = 100  # you can adjust this value to get more or less data
def init_labjack(): #initialize the U6 and return the handle
    d = u6.U6()
    d.getCalibrationData()
    return d
Пример #29
0
#! /usr/bin/python
import u6
import pylab
import numpy as np
import time, datetime, os

today       = datetime.date.today() # get time string for folder name
todaystr    = today.isoformat()

d           = u6.U6() # open LabJack U6

d.getCalibrationData() # get calibration info for U6

# turn off device first
DAC0_value = d.voltageToDACBits(0, dacNumber = 0, is16Bits = False)
d.getFeedback(u6.DAC0_8(DAC0_value))

device_type = raw_input('Are you calibrating led or lasergreen or laserblue or laserblueC? ')
fiber_type  = raw_input('What is your fiber diameter(nm)? ')

# Set DAC0 to 2V and get analog reading from AIN0 to calculate scale
if device_type == "led":
    startV = 0.07
    stopV  = 5
    nVPts  = 81
    DAC0_value = d.voltageToDACBits(1.4, dacNumber = 0, is16Bits = False)
elif device_type == "lasergreen":
    
    startV = 1.5
    stopV  = 3
    nVPts  = 19
    def __init__(self, task_manager):
        self.task_manager = task_manager  #class that controls all elements and I/O

        self.device = u6.U6()
        self.device.configU6()