upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the AdafruitMS1438 Motor Shield. More...
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 M3
An example using a stepper motor connected to M1 & M2
Public Types | |
enum | DIRECTION_T { DIR_NONE = 0x00, DIR_CW = 0x01, DIR_CCW = 0x02 } |
enum | DCMOTORS_T { MOTOR_M1 = 0, MOTOR_M2 = 1, MOTOR_M3 = 2, MOTOR_M4 = 3 } |
enum | STEPMOTORS_T { STEPMOTOR_M12 = 0, STEPMOTOR_M34 = 1 } |
Public Member Functions | |
AdafruitMS1438 (int bus, uint8_t address=ADAFRUITMS1438_DEFAULT_I2C_ADDR) | |
~AdafruitMS1438 () | |
uint32_t | getMillis (STEPMOTORS_T motor) |
void | initClock (STEPMOTORS_T motor) |
void | setPWMPeriod (float hz) |
void | enableMotor (DCMOTORS_T motor) |
void | disableMotor (DCMOTORS_T motor) |
void | enableStepper (STEPMOTORS_T motor) |
void | disableStepper (STEPMOTORS_T motor) |
void | setMotorSpeed (DCMOTORS_T motor, int speed) |
void | setStepperSpeed (STEPMOTORS_T motor, int speed) |
void | setMotorDirection (DCMOTORS_T motor, DIRECTION_T dir) |
void | setStepperDirection (STEPMOTORS_T motor, DIRECTION_T dir) |
void | stepConfig (STEPMOTORS_T motor, unsigned int stepsPerRev) |
void | stepperSteps (STEPMOTORS_T motor, unsigned int steps) |
enum DIRECTION_T |
Enum to specify the direction of a motor
enum DCMOTORS_T |
Enum to specify a DC motor
enum STEPMOTORS_T |
Enum to specify a stepper motor
AdafruitMS1438 | ( | int | bus, |
uint8_t | address = ADAFRUITMS1438_DEFAULT_I2C_ADDR |
||
) |
AdafruitMS1438 constructor
bus | I2C bus to use |
address | Address for this sensor |
~AdafruitMS1438 | ( | ) |
AdafruitMS1438 destructor
uint32_t getMillis | ( | STEPMOTORS_T | motor | ) |
Returns the number of milliseconds elapsed since initClock(...) was last called.
void initClock | ( | STEPMOTORS_T | motor | ) |
Resets the clock
void setPWMPeriod | ( | float | hz | ) |
Sets the PWM period. Note: this applies to all PWM channels.
hz | Sets the PWM period |
void enableMotor | ( | DCMOTORS_T | motor | ) |
Enables PWM output for a motor
motor | DC motor to enable |
void disableMotor | ( | DCMOTORS_T | motor | ) |
Disables PWM output for a motor
motor | DC motor to disable |
void enableStepper | ( | STEPMOTORS_T | motor | ) |
Enables output for a stepper motor
motor | Stepper motor to enable |
void disableStepper | ( | STEPMOTORS_T | motor | ) |
Disable output for a stepper motor
motor | Stepper motor to disable |
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 |
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 |
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 |
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 |
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 |
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 |