Beispiel #1
0
    def autolevel(self, processID, direction, adjustment):
        initial = self.com.readReg(processID, 460, 1)
        self.com.setReg(processID, 255, [28])
        time.sleep(1)
        read = self.com.readReg(processID, 255, 1)
        if read[0] != 29:
            self.com.setReg(processID, 255, [29])
        if direction == -1:
            self.logger.info("adjusting level motor up")
            self.display.fb_println("adjusting level motor up", 0)
            target = initial[0] + abs(adjustment)
            read = self.com.readReg(processID, 460, 1)
            self.moveLvlMotor(1, direction)
            startTime = time.time()
            self.logger.info("inital: %r, target: %r" % (initial[0], target))
            #self.display.fb_println("inital: %r, target: %r" %(initial[0], target), 0)
            while read[0] <= target and commonFX.timeCal(
                    startTime) < self.lvlMotorTime:
                read = self.com.readReg(processID, 460, 1)
            self.moveLvlMotor(0, 0)
            if commonFX.timeCal(startTime) > self.lvlMotorTime:
                self.logger.info(
                    "level motor did not reach target, timed out at %r (sec)" %
                    self.lvlMotorTime)
                self.display.fb_println(
                    "level motor did not reach target >%r (sec)" %
                    self.lvlMotorTime, 1)

        if direction == 1:
            self.logger.info("adjusting level motor down")
            self.display.fb_println("adjusting level motor down", 0)
            target = initial[0] - abs(adjustment)
            read = self.com.readReg(processID, 460, 1)
            self.moveLvlMotor(1, direction)
            startTime = time.time()
            self.logger.info("inital: %r, target: %r" % (initial[0], target))
            #self.display.fb_println("inital: %r, target: %r" % (initial[0], target), 0)
            while read[0] >= target and commonFX.timeCal(
                    startTime) < self.lvlMotorTime:
                read = self.com.readReg(processID, 460, 1)
            self.moveLvlMotor(0, 0)
            if commonFX.timeCal(startTime) > self.lvlMotorTime:
                self.logger.info(
                    "level motor did not reach target, timed out at %r (sec)" %
                    self.lvlMotorTime)
                self.display.fb_println(
                    "level motor did not reach target >%r (sec)" %
                    self.lvlMotorTime, 1)

        self.logger.info("adjustment completed")
        self.display.fb_println("adjustment completed", 0)
Beispiel #2
0
    def calZDBF(self):
        processID = 305
        self.resetMode(processID)
        self.com.setReg(processID, 255, [10])
        read = self.com.readReg(processID, 255, 1)
        startTime = time.time()
        while read[0] != 14 and commonFX.timeCal(
                startTime) < self.lvlMotorTime / 2:
            time.sleep(0.5)
            read = self.com.readReg(processID, 255, 1)
        if commonFX.timeCal(startTime) > self.lvlMotorTime / 2:
            self.logger.info("Unable to capture ZDBF")
            self.display.fb_println("Unable to capture ZDBF", 1)
            os._exit(1)

        gap = self.com.readReg(processID, 5, 2)
        ZDBF = gap[0] - gap[1]
        self.logger.info("ZDBF: " + str(ZDBF))
        self.display.fb_println("ZDBF: %r" % ZDBF, 0)
        self.resetMode(processID)
        return ZDBF, gap
    def homing(self, processID):
        homeStatus = self.com.readReg(processID, 25, 1)
        if homeStatus[0] != 5:
            self.com.setReg(processID, 25, [0])
            self.com.setReg(processID, 255, [1])
        startTime = time.time()
        while homeStatus[0] != 5 and commonFX.timeCal(
                startTime) < self.timeout:
            homeStatus = self.com.readReg(processID, 25, 1)

        if homeStatus[0] != 5:
            self.logger.info("Homing sequence failed, @ processID %r" %
                             processID)
            self.stopMotion(processID)
            os._exit(1)

        self.logger.info("Homing sequence successful, @ processID %r" %
                         processID)
Beispiel #4
0
def main():
    # main starts here
    FB_X = 280
    config = myConfig()
    if config.display.checkOS() == True:
        config.display.fb_clear()
        config.copyLog()
    logger = setup_logger('event_log', config.logfile + config.log)
    config.logger = logger
    try:
        master = setup()
    except serial.serialutil.SerialException:
        config.display.fb_clear()
        config.display.fb_long_print(
            "FTDI USB cable not found, please connect cable and restart", 1)
        logger.info(
            "FTDI USB cable not found, please connect cable and restart")
        os._exit(1)

    config.updateSettings()

    config.display.fb_clear()
    logger.info("==================== Load Settings ====================")
    config.display.fb_println("=============== Load Settings ===============",
                              1)

    com = modbus.communicate()
    com.setup(logger, master, config.device, config.restTime)

    processID = 0
    com.setCoil(processID, 30, [1])  # reset button status

    myJSON = jsonToFile.loadJSON()
    myJSON.update(logger, com, config.loadReg_enable)

    # info = myJSON.readJSON(config.linuxPath + config.sysPath + 'settings.json')
    try:
        info = myJSON.readJSON(config.linuxPath + config.sysPath +
                               'settings.json')
    except ValueError:
        logger.info("settings.json file corrupted, update settings required")
        config.display.fb_long_print(
            "settings.json file corrupted, update settings required", 0)
        os._exit(1)

    processID = 1
    config.grillType = myJSON.grillType(processID)
    config.updateJSON(config.grillType)
    logger.info(config.jsonFile)
    config.test_enable, config.customer = testRequired(config)

    config.json_test_config, config.voltage_config, config.platen_config, config.actuator_config, config.switch_config = myJSON.loadSettings(
        info, config.customer)

    data = myJSON.readJSON(config.jsonFile)
    config.description, config.sync_role = myJSON.loadHardware(data)
    myJSON.setDevice(data)
    config.display.fb_long_print(str(config.description), 1)

    power = voltage.measure()
    power.update(logger, com, config)

    motor = actuator.motion()
    motor.update(logger, com, config)
    config.encoder_conv = motor.encoder_conv

    pl = platen.sensors()
    pl.update(logger, com, config)

    config.display.fb_long_print("Press green button to execute custom test",
                                 0)
    config.display.fb_long_print("Test selection: ", 0)
    button = com.readCoil(processID, 30, 1)
    startTime = time.time()
    counter = -1
    config.display.reverseLine()
    while button != 0 and commonFX.timeCal(startTime) < 10:
        button = com.readCoil(processID, 30, 1)
        if button[0] == 0:
            counter += 1
            config.display.fb_printX("%r " % counter, FB_X, 1)
            FB_X += 40
            # config.display.fb_long_print("< execute customized test sequence >", 1)
            com.setCoil(processID, 30, [1])
    config.display.nextLine()
    if counter != -1 and counter <= 7:
        config.test_enable = testCase(config, counter)

    # seek upper switch
    processID = 1
    com.setReg(processID, 255, [3])

    logger.info("==================== Test Begins ====================")
    config.display.fb_println("================ Test Begins ================",
                              1)
    logger.info("< execute voltage reading >")
    config.display.fb_println("< execute voltage reading >", 1)
    processID = 2
    config.phase_status, config.supply_voltage = power.voltage(processID)
    power.validate(config)

    if config.test_enable[0]:
        logger.info("< execute switch test >")
        config.display.fb_println("< # 1 execute switch test >", 1)
        config.switch, config.time_elapse = motor.switchTest(config)
    if config.test_enable[1]:
        logger.info("< execute kill switch test >")
        config.display.fb_println("< # 2 execute kill switch test >", 1)
        config.killsw_enc = motor.killSwitchTest()
    if config.test_enable[2]:
        logger.info("< execute magnet drift test >")
        config.display.fb_println("< # 3 execute magnet drift test >", 1)
        config.magnet = motor.magnetDrift(config)
    if config.test_enable[3]:
        logger.info("< execute homing test >")
        config.display.fb_clear()
        config.display.fb_println("< # 4 execute homing test >", 1)
        motor.homing(processID)
    if config.test_enable[4]:
        logger.info("< execute sensors gap test >")
        config.display.fb_println("< # 5 execute sensors gap test >", 1)
        motor.homing(processID)
        motor.setpoint(0)
        time.sleep(2)
        config.sensor = pl.sensorGap()
    if config.test_enable[5]:
        logger.info("< execute ZDBF test >")
        config.display.fb_println("< # 6 execute ZDBF test >", 1)
        motor.homing(processID)
        motor.setpoint(0)
        time.sleep(2)
        config.ZDBF, config.gap = pl.calZDBF()
    if config.test_enable[6]:
        logger.info("< execute level motor test >")
        config.display.fb_println("< # 7 execute level motor test >", 1)
        motor.homing(processID)
        time.sleep(2)
        config.motor_range, config.motor_limit, config.newZDBF = pl.motorRangeTest(
            config)
    if config.test_enable[7]:
        logger.info("< calculate results >")
        config.display.fb_println("< # 8 calculate results >", 1)
        config.calculate()

    logger.info("==================== Test Completed ====================")
    config.display.fb_println("============== Test Completed ==============",
                              1)
    config.report()
    config.display.checkOS()
    if config.display.myPlatform == True:
        config.copyLog()
        config.display.keepON()
Beispiel #5
0
    def motorRangeTest(self, config):
        processID = 307
        sample = []
        motor_range = [0, 0, 0]
        self.resetMode(processID)
        self.setpoint(processID, 0)
        pos = self.com.readReg(processID, 0, 1)
        if commonFX.signedInt(pos[0]) != -32768:
            time.sleep(7)
        sensorReading = self.readSensor(processID)
        motor_range[0] = sensorReading[0]  # current position
        sample.append(sensorReading[0])  # initial
        sample.append(sensorReading[0] *
                      2)  # ensure it's not the same as initial

        offset = commonFX.baumerToMM(motor_range[0]) - self.offset_required[0]
        target = int(commonFX.mmToBaumer(offset))

        # adjustment upwards
        self.logger.info("Adjusting level motor up, gap target (mil): %r" %
                         round(commonFX.baumerToThou(offset), 3))
        self.display.fb_println("Adjusting level motor up", 0)
        self.moveLvlMotor(1, -1)

        startTime = time.time()
        while sensorReading[0] < target and commonFX.timeCal(
                startTime) < self.lvlMotorTime:
            sensorReading = self.readSensor(processID)
            sample.append(sensorReading[0])
            # print sensorReading[0]
            time.sleep(1)

        self.moveLvlMotor(0, 0)
        if commonFX.timeCal(startTime) > self.lvlMotorTime:
            self.logger.info(
                "level motor did not reach target, timed out at %r (sec)" %
                self.lvlMotorTime)
            self.display.fb_println(
                "level motor did not reach target >%r (sec)" %
                self.lvlMotorTime, 1)

        sensorReading = self.readSensor(processID)
        motor_range[1] = sensorReading[0]

        # determine motor direction
        try:
            if commonFX.rangeCheck(sample[-1], sample[0], 0.01):
                self.logger.info("No level motor movement detected")
                self.display.fb_println("No level motor movement detected", 1)
                os._exit(1)
            elif sample[0] > sample[-1] - self.movement_trigger[0]:
                self.logger.info("Level motor moving in reverse direction")
                self.display.fb_println(
                    "Level motor moving in reverse direction", 1)
                os._exit(1)
            elif sample[0] < sample[-1] + self.movement_trigger[0]:
                self.logger.info("Level motor installed correctly")
                self.display.fb_println("Level motor installed correctly", 0)

        except IndexError:
            self.logger.info("No sensor reading collected")
            self.display.fb_println("No sensor reading collected", 1)

        # reset motor to inital position
        self.logger.info("Reset level motor to inital position")
        self.display.fb_println("Reset level motor to inital position", 0)
        sensorReading = self.readSensor(processID)
        self.moveLvlMotor(1, 1)
        startTime = time.time()
        while sensorReading[0] > sample[0] and commonFX.timeCal(
                startTime) < self.lvlMotorTime:
            sensorReading = self.readSensor(processID)
            time.sleep(0.5)
        self.moveLvlMotor(0, 0)
        if commonFX.timeCal(startTime) > self.lvlMotorTime:
            self.logger.info(
                "level motor did not reach target, timed out at %r (sec)" %
                self.lvlMotorTime)
            self.display.fb_println(
                "level motor did not reach target >%r (sec)" %
                self.lvlMotorTime, 1)

        # adjustment downwards
        offset = commonFX.baumerToMM(motor_range[0]) + self.offset_required[1]
        target = int(commonFX.mmToBaumer(offset))
        sensorReading = self.readSensor(processID)
        self.logger.info("Adjusting level motor down, gap target (mm): %r" %
                         round(offset, 3))
        self.display.fb_println("Adjusting level motor down", 0)
        self.moveLvlMotor(1, 1)
        startTime = time.time()
        while sensorReading[0] > target and commonFX.timeCal(
                startTime) < self.lvlMotorTime:
            sensorReading = self.readSensor(processID)
            # print sensorReading[0]
            time.sleep(1)

        self.moveLvlMotor(0, 0)
        if commonFX.timeCal(startTime) > self.lvlMotorTime:
            self.logger.info(
                "level motor did not reach target, timed out at %r (sec)" %
                self.lvlMotorTime)
            self.display.fb_println(
                "level motor did not reach target >%r (sec)" %
                self.lvlMotorTime, 1)

        sensorReading = self.readSensor(processID)
        motor_range[2] = sensorReading[0]

        # log data
        position = commonFX.baumerToThou(motor_range[0])
        upperLimit = commonFX.baumerToThou(motor_range[1])
        lowerLimit = commonFX.baumerToThou(motor_range[2])

        self.logger.info(
            "Sensor Reading {position: %r, upper range: %r, lower range: %r}" %
            (round(position, 3), round(upperLimit, 3), round(lowerLimit, 3)))

        # reset motor to inital position
        self.logger.info("Reset level motor to inital position")
        self.display.fb_println("Reset level motor to inital position", 0)
        sensorReading = self.readSensor(processID)
        self.moveLvlMotor(1, -1)
        startTime = time.time()
        while sensorReading[0] < sample[0] and commonFX.timeCal(
                startTime) < self.lvlMotorTime:
            sensorReading = self.readSensor(processID)
            time.sleep(0.5)
        self.moveLvlMotor(0, 0)
        if commonFX.timeCal(startTime) > self.lvlMotorTime:
            self.logger.info(
                "level motor did not reach target, timed out at %r (sec)" %
                self.lvlMotorTime)
            self.display.fb_println(
                "level motor did not reach target >%r (sec)" %
                self.lvlMotorTime, 1)

        # reset
        self.resetMode(processID)
        self.logger.info("Check ZDBF range")
        self.display.fb_println("Check ZDBF range", 0)
        newZDBF, direction, adjustment = self.resetGAP(config)

        retry = 1
        while direction != 0 and retry <= self.autolevel_retry:
            self.resetMode(processID)
            time.sleep(2)
            self.autolevel(processID, direction, adjustment)
            newZDBF, direction, adjustment = self.resetGAP(config)
            if retry > self.autolevel_retry:
                self.logger.info("Max auto level retry reached, > %r" % retry)
                self.display.fb_println(
                    "Max auto level retry reached, > %r" % retry, 1)
            retry += 1

        self.resetMode(processID)
        self.logger.info("New ZDBF: %r" % newZDBF)

        return motor_range, [position, upperLimit, lowerLimit], newZDBF
    def switchTest(self, config):
        processID = 203

        # seek lower switch for initial position
        self.com.setReg(processID, 255, [6])
        read = self.com.readReg(processID, 255, 1)
        startTime = time.time()
        while read[0] != 8 and commonFX.timeCal(startTime) < self.timeout / 2:
            read = self.com.readReg(processID, 255, 1)
        if read[0] != 8:
            self.logger.info("Seeking lower switch failed, @ processID %r" %
                             processID)
            self.display.fb_println(
                "Seeking lower switch failed, @ processID %r" % processID, 0)
            self.stopMotion(processID)
            os._exit(1)
        self.logger.info("Seeking lower switch successful, @ processID %r" %
                         processID)

        # seek upper switch
        self.com.setReg(processID, 255, [3])
        read = self.com.readReg(processID, 255, 1)
        startTime = time.time()
        while read[0] != 5 and commonFX.timeCal(startTime) < self.timeout / 2:
            read = self.com.readReg(processID, 255, 1)
        if read[0] != 5:
            self.logger.info("Seeking upper switch failed, @ processID %r" %
                             processID)
            self.display.fb_println(
                "Seeking upper switch failed, @ processID %r" % processID, 1)
            self.stopMotion(processID)
            os._exit(1)
        self.logger.info("Seeking upper switch successful, @ processID %r" %
                         processID)
        endTimeUP = commonFX.timeCal(startTime)
        time.sleep(1)
        encUP = self.spFeedback()

        # seek lower switch
        self.com.setReg(processID, 255, [6])
        read = self.com.readReg(processID, 255, 1)
        startTime = time.time()
        while read[0] != 8 and commonFX.timeCal(startTime) < self.timeout / 2:
            read = self.com.readReg(processID, 255, 1)
        if read[0] != 8:
            self.logger.info("Seeking lower switch failed, @ processID %r" %
                             processID)
            self.display.fb_println(
                "Seeking lower switch failed, @ processID %r" % processID, 0)
            self.stopMotion(processID)
            os._exit(1)
        self.logger.info("Seeking lower switch successful, @ processID %r" %
                         processID)
        endTimeDN = commonFX.timeCal(startTime)
        time.sleep(1)
        encDown = self.spFeedback()

        # results
        distance = abs(encUP - encDown) * config.encoder_conv
        self.logger.info("Distance between Lift and Home switch (inch): " +
                         str(distance))
        self.logger.info("Lift switch location (count): %r" % encUP)
        self.logger.info("Home switch location (count): %r" % encDown)
        self.logger.info("Moving upwards time elapse (sec): " + str(endTimeUP))
        self.logger.info("Moving downwards time elapse (sec): " +
                         str(endTimeDN))
        self.logger.info("Actuator speed upwards (inch/sec): " +
                         str(distance / endTimeUP))
        self.logger.info("Actuator speed downwards (inch/sec): " +
                         str(distance / endTimeDN))
        self.display.fb_println("Lift switch location (count): %r" % encUP, 0)
        self.display.fb_println("Home switch location (count): %r" % encDown,
                                0)
        return [encUP, encDown], [endTimeUP, endTimeDN]
    def killSwitchTest(self):
        processID = 205
        encoder = [0, 0]
        status = self.com.readReg(processID, 25, 1)
        if status[0] != 5:
            self.homing(processID)
        self.resetMode(processID)

        # seek upper switch
        self.com.setReg(processID, 255, [3])
        read = self.com.readReg(processID, 255, 1)
        startTime = time.time()
        while read[0] != 5 and commonFX.timeCal(startTime) < self.timeout / 2:
            read = self.com.readReg(processID, 255, 1)
        if read[0] != 5:
            self.logger.info("Seeking upper switch failed, @ processID %r" %
                             processID)
            self.display.fb_println(
                "Seeking upper switch failed, @ processID %r" % processID, 1)
            self.stopMotion(processID)
            os._exit(1)
        self.logger.info("Seeking upper switch successful, @ processID %r" %
                         processID)
        self.resetMode(processID)

        # move to high setpoint
        self.com.setReg(processID, 0, [self.killSP[0]])
        time.sleep(4)
        startTime = time.time()
        upperSW = self.com.readCoil(processID, 7, 1)
        if upperSW[0]:
            self.com.setCoil(processID, 55, [0])
            timer = time.time()
            while commonFX.timeCal(startTime) <= self.oc_runtime:
                oc = self.com.readCoil(processID, 55, 1)
                if oc[0] == 1:
                    self.com.setCoil(processID, 55, [0])
                else:
                    timer = time.time()
                if commonFX.timeCal(timer) >= self.oc_time:
                    self.logger.info(
                        "Over current detected, upper kill switch failed")
                    self.display.fb_println(
                        "Over current detected, upper kill switch failed", 1)
                    self.stopMotion(processID)
                    os._exit(1)
        else:
            self.logger.info("Platen did not reach upper position")
            self.display.fb_println("Platen did not reach upper position", 1)
            self.stopMotion(processID)
            os._exit(1)

        encRead = self.com.readReg(processID, 3, 1)
        encoder[0] = commonFX.signedInt(encRead[0])
        self.logger.info("Upper kill switch location: %r" % encoder[0])
        self.display.fb_println("Upper kill switch location: %r" % encoder[0],
                                0)

        # seek lower reference switch
        self.com.setReg(processID, 255, [6])
        read = self.com.readReg(processID, 255, 1)
        startTime = time.time()
        while read[0] != 8 and commonFX.timeCal(startTime) < self.timeout:
            read = self.com.readReg(processID, 255, 1)

        if read[0] != 8:
            self.logger.info("Seeking lower switch failed, @ processID %r" %
                             processID)
            self.display.fb_println(
                "Seeking lower switch failed, @ processID %r" % processID, 1)
            self.stopMotion(processID)
            os._exit(1)
        self.logger.info("Seeking lower switch successful, @ processID %r" %
                         processID)
        self.resetMode(processID)

        # move to low setpoint
        self.com.setReg(processID, 0, [self.killSP[1]])
        time.sleep(5)
        startTime = time.time()
        lowerSW = self.com.readCoil(processID, 6, 1)
        if lowerSW[0]:
            self.com.setCoil(processID, 55, [0])
            timer = time.time()
            while commonFX.timeCal(startTime) <= self.oc_runtime:
                oc = self.com.readCoil(processID, 55, 1)
                if oc[0] == 1:
                    self.com.setCoil(processID, 55, [0])
                else:
                    timer = time.time()
                if commonFX.timeCal(timer) >= self.oc_time:
                    self.logger.info(
                        "Over current detected, lower kill switch failed")
                    self.display.fb_println(
                        "Over current detected, lower kill switch failed", 1)
                    self.stopMotion(processID)
                    os._exit(1)

            lowerSW = self.com.readCoil(processID, 6, 1)
            if lowerSW[0]:
                self.logger.info(
                    "Home switch remain engaged, switch bracket ok ")
            else:
                self.logger.info(
                    "Home switch disengaged, check switch bracket or crossbar")
                self.display.fb_println(
                    "Home switch disengaged, check switch bracket", 1)
                self.stopMotion(processID)
                os._exit(1)
        else:
            self.logger.info("Platen did not reach lower position")
            self.display.fb_println("Platen did not reach lower position", 1)
            self.stopMotion(processID)
            os._exit(1)

        encRead = self.com.readReg(processID, 3, 1)
        encoder[1] = commonFX.signedInt(encRead[0])
        self.logger.info("Lower kill switch location: %r" % encoder[1])
        self.display.fb_println("Lower kill switch location: %r" % encoder[1],
                                0)
        self.logger.info("Kill switch test successful")
        self.resetMode(processID)
        self.stopMotion(processID)
        return encoder
    def magnetDrift(self, config):
        processID = 204
        test = 1
        error = 0
        distanceUP = [0]
        distanceDOWN = [0]
        drift = [0]

        while test <= self.magnet_testrun:
            self.homing(processID)
            self.logger.info("Test run #%r" % test)
            self.display.fb_println("Test run #%r" % test, 0)
            # seek upper reference switch
            self.com.setReg(processID, 255, [3])
            read = self.com.readReg(processID, 255, 1)
            startTime = time.time()
            while read[0] != 5 and commonFX.timeCal(startTime) < self.timeout:
                read = self.com.readReg(processID, 255, 1)
            if read[0] != 5:
                self.logger.info(
                    "Seeking upper switch failed, @ processID %r" % processID)
                self.display.fb_println(
                    "Seeking upper switch failed, @ processID %r" % processID,
                    1)
                self.stopMotion(processID)
                os._exit(1)
            self.logger.info(
                "Seeking upper switch successful, @ processID %r" % processID)
            encUPintial = self.spFeedback()

            # move to lower test setpoint
            self.setpoint(self.magnet_setpoint)
            self.resetMode(processID)
            read = self.com.readReg(processID, 0, 1)
            startTime = time.time()
            while commonFX.signedInt(read[0]) != -32768 and commonFX.timeCal(
                    startTime) < self.timeout:
                read = self.com.readReg(processID, 0, 1)
                if commonFX.signedInt(read[0]) != -32768:
                    time.sleep(0.4)
                    self.com.setReg(processID, 255, [0])
                    time.sleep(0.4)
                    self.resetMode(processID)

            if commonFX.timeCal(startTime) > self.timeout:
                self.logger.info("Motor did not reach lower target > %r" %
                                 self.timeout)
                self.display.fb_println(
                    "Motor did not reach lower target > %r" % self.timeout, 1)
                self.stopMotion(processID)
                os._exit(1)

            read = self.com.readCoil(processID, 6, 1)
            if read[0] == 1:
                self.logger.info(
                    "Reduce lower setpoint required, home switch pressed")
                self.display.fb_println(
                    "Reduce lower setpoint required, home switch pressed")
                self.stopMotion(processID)
                os._exit(1)

            self.resetMode(processID)
            encDown = self.spFeedback()
            distanceDOWN.append(abs(encUPintial - encDown))

            # seek upper reference switch
            self.com.setReg(processID, 255, [3])
            read = self.com.readReg(processID, 255, 1)
            startTime = time.time()
            while read[0] != 5 and commonFX.timeCal(
                    startTime) < self.timeout / 2:
                read = self.com.readReg(processID, 255, 1)
            if read[0] != 5:
                self.logger.info(
                    "Seeking upper switch failed, @ processID %r" % processID)
                self.display.fb_println(
                    "Seeking upper switch failed, @ processID %r" % processID,
                    1)
                self.stopMotion(processID)
                os._exit(1)
            self.logger.info(
                "Seeking upper switch successful, @ processID %r" % processID)
            self.resetMode(processID)
            encUP = self.spFeedback()
            distanceUP.append(abs(encDown - encUP))
            drift.append(abs(distanceUP[test] - distanceDOWN[test]))

            if drift[test] <= self.magnet_drift_target:
                self.logger.info("Distance moving up: " +
                                 str(distanceUP[test]))
                self.logger.info("Distance moving down: " +
                                 str(distanceDOWN[test]))
                self.logger.info("Encoder magnet ok, no drift found (%r)" %
                                 drift[test])
                self.display.fb_println(
                    "Distance moving up: %r" % distanceUP[test], 0)
                self.display.fb_println(
                    "Distance moving down: %r" % distanceDOWN[test], 0)
                self.display.fb_println(
                    "Encoder magnet ok, no drift found (%r)" % drift[test], 0)
            else:
                self.logger.info("Distance moving up: " +
                                 str(distanceUP[test]))
                self.logger.info("Distance moving down: " +
                                 str(distanceDOWN[test]))
                self.logger.info("Check encoder magnet, %r count drift found" %
                                 drift[test])
                self.display.fb_println(
                    "Distance moving up: %r" % distanceUP[test], 1)
                self.display.fb_println(
                    "Distance moving down: %r" % distanceDOWN[test], 1)
                self.display.fb_println(
                    "Check encoder magnet, %r count drift found" % drift[test],
                    1)
                error += 1
                #os._exit(1)

            test += 1

        if error >= 2:
            self.logger.info("Check encoder magnet, max drift count (%r)" %
                             max(drift))
            self.display.fb_println(
                "Magnet test failed, max drift count (%r)" % max(drift), 1)
            os._exit(1)

        index = drift.index(max(drift))

        return [distanceDOWN[index], distanceUP[index], max(drift)]