Esempio n. 1
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')
Esempio n. 2
0
from numpy import *
import u6

h = u6.U6()

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

    print tF0, tF1




















Esempio n. 3
0
d = u6.U6()
d.getCalibrationData()

try:
    #Configure the IOs before the test starts

    FIOEIOAnalog = (2**numChannels) - 1
    fios = FIOEIOAnalog & (0xFF)
    eios = FIOEIOAnalog / 256

    d.getFeedback(u6.PortDirWrite(Direction=[0, 0, 0], WriteMask=[0, 0, 15]))

    feedbackArguments = []

    feedbackArguments.append(u6.DAC0_8(Value=125))
    feedbackArguments.append(u6.PortStateRead())

    for i in range(numChannels):
        feedbackArguments.append(
            u6.AIN24(i, resolutionIndex, gainIndex, settlingFactor,
                     differential))

    start = datetime.now()
    # Call Feedback 1000 times
    i = 0
    while i < numIterations:
        results = d.getFeedback(feedbackArguments)

        for j in range(numChannels):
            latestAinValues[j] = d.binaryToCalibratedAnalogVoltage(
                gainIndex, results[2 + j])