|
upm
0.2.0
Sensor/Actuator repository for libmraa (v0.6.1)
|
C++ 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 actually controlled by the pca9685 controller (or this class), rather they are connected directly to digital PWM pins 9 and 10 on the arduino breakout.
An example using a DC motor conected 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) |
| AdafruitMS1438 | ( | int | bus, |
| uint8_t | address = ADAFRUITMS1438_DEFAULT_I2C_ADDR |
||
| ) |
AdafruitMS1438 constructor
| bus | i2c bus to use |
| address | the address for this sensor |

| ~AdafruitMS1438 | ( | ) |
AdafruitMS1438 Destructor
| uint32_t getMillis | ( | STEPMOTORS_T | motor | ) |
Return the number of milliseconds elapsed since initClock(...) was last called.

| void initClock | ( | STEPMOTORS_T | motor | ) |
Reset the Clock

| void setPWMPeriod | ( | float | hz | ) |
Set the PWM period. Note this applies to all PWM channels.
| hz | set the PWM period |


| void enableMotor | ( | DCMOTORS_T | motor | ) |
enable PWM output for a motor
| motor | the DC motor to enable |

| void disableMotor | ( | DCMOTORS_T | motor | ) |
disable PWM output for a motor
| motor | the DC motor to disable |


| void enableStepper | ( | STEPMOTORS_T | motor | ) |
enable output for a stepper motor
| motor | the stepper motor to enable |

| void disableStepper | ( | STEPMOTORS_T | motor | ) |
disable output for a stepper motor
| motor | the 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 | ||
| ) |
set the speed of a stepper in revolution per minute (RPM)
| motor | the DC motor to configure |
| speed | speed to set the motor to |
| void setMotorDirection | ( | DCMOTORS_T | motor, |
| DIRECTION_T | dir | ||
| ) |
set the direction of a DC motor, clockwise or counter clockwise
| motor | the DC motor to configure |
| dir | direction to set the motor to |

| void setStepperDirection | ( | STEPMOTORS_T | motor, |
| DIRECTION_T | dir | ||
| ) |
set the direction of a stepper motor, clockwise or counter clockwise
| motor | the stepper motor to configure |
| dir | direction to set the motor to |
| void stepConfig | ( | STEPMOTORS_T | motor, |
| unsigned int | stepsPerRev | ||
| ) |
set a stepper motor configuration
| motor | the stepper motor to configure |
| stepsPerRev | the number of step to complete a full revolution |


| void stepperSteps | ( | STEPMOTORS_T | motor, |
| unsigned int | steps | ||
| ) |
step a stepper motor a specified number of steps
| motor | the stepper motor to step |
| steps | number of steps to move the stepper motor |

1.8.9.1