當前位置: 首頁>>代碼示例>>Python>>正文


Python Machine.invert_motor方法代碼示例

本文整理匯總了Python中machine.Machine.invert_motor方法的典型用法代碼示例。如果您正苦於以下問題:Python Machine.invert_motor方法的具體用法?Python Machine.invert_motor怎麽用?Python Machine.invert_motor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在machine.Machine的用法示例。


在下文中一共展示了Machine.invert_motor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Printer

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import invert_motor [as 別名]

#.........這裏部分代碼省略.........
        if 'encoder' in config:
            # read out the encoder config
            encoder_config = config['encoder']
            increments = int(encoder_config['increments-per-revolution'])
            if 'differential' in encoder_config and encoder_config['differential']:
                differential = True
            else:
                differential = False
            if 'inverted' in encoder_config and encoder_config['inverted']:
                inverted = True
            else:
                inverted = False
            axis['encoder'] = {
                'steps-per-rev': config['steps-per-revolution'],
                'increments-per-rev': increments,
                'differential': differential,
                'inverted': inverted
            }
            self.machine.configure_encoder(axis['motor'], deepcopy(axis['encoder']))

        current = config["current"]
        if axis["motor"]:
            self.machine.set_current(axis["motor"], current)
        else:
            for motor in axis['motors']:
                self.machine.set_current(motor, current)

        # let's see if there are any inverted motors
        if 'motor' in config:
            if "inverted" in config and config["inverted"]:
                axis['inverted'] = True
            else:
                axis['inverted'] = False
            self.machine.invert_motor(axis["motor"], axis['inverted'])
        else:
            # todo this is ok - but no perfect structure
            if "inverted" in config:
                axis['inverted'] = config["inverted"]
                for motor in axis['motors']:
                    if str(motor) in config['inverted'] and config['inverted'][str(motor)]:
                        self.machine.invert_motor(motor, True)

    def _configure_heater(self, heater_config):
        output_number = heater_config['output'] - 1
        if output_number < 0 or output_number >= len(beagle_bone_pins.pwm_config):
            raise PrinterError("PWM pins can only be between 1 and %s" % len(beagle_bone_pins.pwm_config))
        output = beagle_bone_pins.pwm_config[output_number]['out']
        thermometer = Thermometer(themistor_type=heater_config['sensor-type'],
                                  analog_input=beagle_bone_pins.pwm_config[output_number]['temp'])
        if 'current_input' in beagle_bone_pins.pwm_config[output_number]:
            current_pin = beagle_bone_pins.pwm_config[output_number]['current_input']
        else:
            current_pin = None
        type = heater_config['type']
        if type == 'PID':
            # do we have a maximum duty cycle??
            max_duty_cycle = None
            if 'max-duty-cycle' in heater_config:
                max_duty_cycle = heater_config['max-duty-cycle']
            pid_controller = PID(P=heater_config['pid-config']['Kp'],
                                 I=heater_config['pid-config']['Ki'],
                                 D=heater_config['pid-config']['Kd'],
                                 Integrator_max=heater_config['max-duty-cycle'])
            heater = PwmHeater(thermometer=thermometer, pid_controller=pid_controller,
                               output=output, maximum_duty_cycle=max_duty_cycle,
                               current_measurement=current_pin, machine=self.machine)
開發者ID:MbedTinkerer,項目名稱:T-Bone,代碼行數:70,代碼來源:printer.py


注:本文中的machine.Machine.invert_motor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。