adafruit_motor.motor
¶
Simple control of a DC motor. DC motors have two wires and should not be connected directly to the PWM connections. Instead use intermediate circuitry to control a much stronger power source with the PWM. The Adafruit Stepper + DC Motor FeatherWing, Adafruit TB6612 1.2A DC/Stepper Motor Driver Breakout Board and Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit - v2.3 do this for popular form factors already.
Note
The TB6612 boards feature three inputs XIN1, XIN2 and PWMX. Since we PWM the INs directly its expected that the PWM pin is consistently high.
- Author(s): Scott Shawcroft
-
class
adafruit_motor.motor.
DCMotor
(positive_pwm, negative_pwm)[source]¶ DC motor driver.
positive_pwm
andnegative_pwm
can be swapped if the motor runs in the opposite direction from what was expected for “forwards”.Parameters: -
throttle
¶ How much power is being delivered to the motor. Values range from
-1.0
(full throttle reverse) to1.0
(full throttle forwards.)0
will stop the motor from spinning andNone
will let the motor spin freely.
-
adafruit_motor.servo
¶
Servos are motor based actuators that incorporate a feedback loop into the design. These feedback loops enable pulse width modulated control to determine position or rotational speed.
- Author(s): Scott Shawcroft
-
class
adafruit_motor.servo.
ContinuousServo
(pwm_out, *, min_pulse=1000, max_pulse=2000)[source]¶ Control a continuous rotation servo.
Parameters: -
throttle
¶ How much power is being delivered to the motor. Values range from
-1.0
(full throttle reverse) to1.0
(full throttle forwards.)0
will stop the motor from spinning.
-
adafruit_motor.stepper
¶
Stepper motors feature multiple wire coils that are used to rotate the magnets connected to the motor shaft in a precise way. Each increment of the motor is called a step. Stepper motors have a varying number of steps per rotation so check the motor’s documentation to determine exactly how precise each step is.
- Author(s): Tony DiCola, Scott Shawcroft
-
adafruit_motor.stepper.
BACKWARD
¶ “Step backward
-
adafruit_motor.stepper.
DOUBLE
¶ Step so that each step only activates two coils to produce more torque.
-
adafruit_motor.stepper.
FORWARD
¶ Step forward
-
adafruit_motor.stepper.
INTERLEAVE
¶ Step half a step to alternate between single coil and double coil steps.
-
adafruit_motor.stepper.
MICROSTEP
¶ Step a fraction of a step by partially activating two neighboring coils. Step size is determined by
microsteps
constructor argument.
-
adafruit_motor.stepper.
SINGLE
¶ Step so that each step only activates a single coil
-
class
adafruit_motor.stepper.
StepperMotor
(ain1, ain2, bin1, bin2, *, microsteps=16)[source]¶ A bipolar stepper motor or four coil unipolar motor.
Parameters: - ain1 (PWMOut) –
pulseio.PWMOut
-compatible output connected to the driver for the first coil (unipolar) or first input to first coil (bipolar). - ain2 (PWMOut) –
pulseio.PWMOut
-compatible output connected to the driver for the third coil (unipolar) or second input to first coil (bipolar). - bin1 (PWMOut) –
pulseio.PWMOut
-compatible output connected to the driver for the second coil (unipolar) or second input to second coil (bipolar). - bin2 (PWMOut) –
pulseio.PWMOut
-compatible output connected to the driver for the fourth coil (unipolar) or second input to second coil (bipolar). - microsteps (int) – Number of microsteps between full steps. Must be at least 2 and even.
-
onestep
(*, direction=<sphinx.ext.autodoc.importer._MockObject object>, style=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Performs one step of a particular style. The actual rotation amount will vary by style.
SINGLE
andDOUBLE
will normal cause a full step rotation.INTERLEAVE
will normally do a half step rotation.MICROSTEP
will perform the smallest configured step.When step styles are mixed, subsequent
SINGLE
,DOUBLE
orINTERLEAVE
steps may be less than normal in order to align to the desired style’s pattern.Parameters:
- ain1 (PWMOut) –