def initCMMD(self):
        DES_CMMD = 2

        sensor = Sensor(self.calMatrix)

        for i in range(6):
            current_command = 0
            sensor.config_dac(i, current_command)
            sample = sensor.poll()

            while sample.sum[i] < DES_CMMD:
                current_command += 1
                sensor.config_dac(i, current_command)
                sample = sensor.poll()

            while sample.sum[i] > DES_CMMD:
                current_command -= 0.1
                sensor.config_dac(i, current_command)
                sample = sensor.poll()

            while sample.sum[i] < DES_CMMD:
                current_command += 0.01
                sensor.config_dac(i, current_command)
                sample = sensor.poll()

        print "**************************************"
        print "Common-mode values of channels A to F:"
        print sample.sum
        print "**************************************"

        sensor.disconnect()
Exemplo n.º 2
0
    def __init__(self):
        signal.signal(signal.SIGINT, self.signal_handler)
        filename = './calibration.cal'
        root = xml.parse(str(filename)).getroot()
        axes = root.findall('Calibration/Axis')
        calMatrix = np.array(
            [[float(axes[i].attrib['values'].split()[j]) for j in range(6)]
             for i in range(6)])

        sensor = Sensor(calMatrix)

        self.time = []
        self.sums = []
        self.diff = []
        self.temp = []

        ma = 0
        sumMax = 0
        start = time.time()
        try:
            while sumMax < 2.386:
                sample = sensor.poll()
                if sample != None:
                    self.time.append(time.time() - start)
                    self.temp.append(sample.temperature)
                    self.sums.append(sample.sum)
                    self.diff.append(sample.differential)

                    if sample.isSaturated():
                        print('Saturated')
                        break

                    sumMax = max(self.sums[-1])
                    # print('Max sum value: ' + str(sumMax))
                    # print('Current: ' + str(ma) + 'mA')
                    sensor.config_dac(-1, ma)
                    ma += 0.1
        finally:
            np.savetxt('./times.txt', np.array(self.time))
            np.savetxt('./temps.txt', np.array(self.temp))
            np.savetxt('./sum.txt', np.array(self.sums))
            np.savetxt('./diff.txt', np.array(self.diff))
Exemplo n.º 3
0
from sensor import Sensor
import time
import numpy as np

DES_CMMD = 2

calMatrix = np.eye(6)
sensor = Sensor(calMatrix)

#Turn on LEDs
# test all modules are working
for i in range(6):
    sensor.config_dac(i, 7)

cont = True
time.sleep(1)
sample = sensor.poll()
for cmmd in sample.sum:
    if cmmd < 0.5:
        cont = False
        print('Sum Signal too low (' + str(cmmd) + 'V)')

for i in range(6):
    current_command = 0
    sensor.config_dac(i, current_command)
    sample = sensor.poll()

    while sample.sum[i] < DES_CMMD:
        current_command += 1
        sensor.config_dac(i, current_command)
        sample = sensor.poll()