pyupm_adafruitms1438 module

class pyupm_adafruitms1438.AdafruitMS1438(bus, address=96)[source]

Bases: object

API for the AdafruitMS1438 Motor Shield.

ID: adafruitms1438

Name: Module for the Adafruit Motor Shield 1438

Category: motor

Manufacturer: adafruit

Link:http://www.adafruit.com/products/1438

Connection: i2c This class implements support for the stepper and DC motors that can be connected to this Motor Shield. Note: the two servo connections are not controlled by the PCA9685 controller (or this class). They are connected directly to digital PWM pins 9 and 10 on the Arduino* breakout board.

An example using a DC motor connected to M3An example using a stepper motor connected to M1 & M2

C++ includes: adafruitms1438.hpp

DIR_CCW = 2
DIR_CW = 1
DIR_NONE = 0
MOTOR_M1 = 0
MOTOR_M2 = 1
MOTOR_M3 = 2
MOTOR_M4 = 3
STEPMOTOR_M12 = 0
STEPMOTOR_M34 = 1
disableMotor(motor)[source]

void disableMotor(DCMOTORS_T motor)

Disables PWM output for a motor

motor: DC motor to disable

disableStepper(motor)[source]

void disableStepper(STEPMOTORS_T motor)

Disable output for a stepper motor

motor: Stepper motor to disable

enableMotor(motor)[source]

void enableMotor(DCMOTORS_T motor)

Enables PWM output for a motor

motor: DC motor to enable

enableStepper(motor)[source]

void enableStepper(STEPMOTORS_T motor)

Enables output for a stepper motor

motor: Stepper motor to enable

getMillis(motor)[source]

uint32_t getMillis(STEPMOTORS_T motor)

Returns the number of milliseconds elapsed since initClock(…) was last called.

Elapsed milliseconds

initClock(motor)[source]

void initClock(STEPMOTORS_T motor)

Resets the clock

setMotorDirection(motor, dir)[source]

void setMotorDirection(DCMOTORS_T motor, DIRECTION_T dir)

Sets the direction of a DC motor, clockwise or counterclockwise

motor: DC motor to configure

dir: Direction to set the motor in

setMotorSpeed(motor, speed)[source]

void setMotorSpeed(DCMOTORS_T motor, int speed)

set the speed of a DC motor. Values can range from 0 (off) to 100 (full speed).

motor: the DC motor to configure

speed: speed to set the motor to

setPWMPeriod(hz)[source]

void setPWMPeriod(float hz)

Sets the PWM period. Note: this applies to all PWM channels.

hz: Sets the PWM period

setStepperDirection(motor, dir)[source]

void setStepperDirection(STEPMOTORS_T motor, DIRECTION_T dir)

Sets the direction of a stepper motor, clockwise or counterclockwise

motor: Stepper motor to configure

dir: Direction to set the motor in

setStepperSpeed(motor, speed)[source]

void setStepperSpeed(STEPMOTORS_T motor, int speed)

Sets the speed of a stepper in revolutions per minute (RPM)

motor: DC motor to configure

speed: Speed to set the motor to

stepConfig(motor, stepsPerRev)[source]

void stepConfig(STEPMOTORS_T motor, unsigned int stepsPerRev)

Sets a stepper motor configuration

motor: Stepper motor to configure

stepsPerRev: Number of steps to complete a full revolution

stepperSteps(motor, steps)[source]

void stepperSteps(STEPMOTORS_T motor, unsigned int steps)

Steps a stepper motor a specified number of steps

motor: Stepper motor to step

steps: Number of steps to move the stepper motor