22vin_type = motoron.VinSenseType.MOTORON_256
26min_vin_voltage_mv = 4500
30 (1 << motoron.STATUS_FLAG_PROTOCOL_ERROR) |
31 (1 << motoron.STATUS_FLAG_CRC_ERROR) |
32 (1 << motoron.STATUS_FLAG_COMMAND_TIMEOUT_LATCHED) |
33 (1 << motoron.STATUS_FLAG_MOTOR_FAULT_LATCHED) |
34 (1 << motoron.STATUS_FLAG_NO_POWER_LATCHED) |
35 (1 << motoron.STATUS_FLAG_RESET) |
36 (1 << motoron.STATUS_FLAG_COMMAND_TIMEOUT))
43mc.set_error_response(motoron.ERROR_RESPONSE_COAST)
44mc.set_error_mask(error_mask)
48mc.set_command_timeout_milliseconds(100)
51mc.set_max_acceleration(1, 140)
52mc.set_max_deceleration(1, 300)
58while mc.get_motor_driving_flag():
pass
62def check_for_problems():
63 status = mc.get_status_flags()
64 if (status & error_mask):
68 print(
"Controller error: 0x%x" % status, file=sys.stderr)
71 voltage_mv = mc.get_vin_voltage_mv(reference_mv, vin_type)
72 if voltage_mv < min_vin_voltage_mv:
74 print(
"VIN voltage too low:", voltage_mv, file=sys.stderr)
81 if int(time.monotonic() * 1000) & 2048:
88except KeyboardInterrupt:
Represents an I2C connection to a Pololu Motoron Motor Controller.