upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

API for the AdafruitMS1438 Motor Shield. More...

Detailed Description

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.

adafruitms1438.jpg

An example using a DC motor connected to M3

An example using a stepper motor connected to M1 & M2

Classes

class  DCMOTORS_T
 
class  DIRECTION_T
 
class  STEPMOTORS_T
 

Public Member Functions

synchronized void delete ()
 
 AdafruitMS1438 (int bus, short address)
 
 AdafruitMS1438 (int bus)
 
long getMillis (AdafruitMS1438.STEPMOTORS_T motor)
 
void initClock (AdafruitMS1438.STEPMOTORS_T motor)
 
void setPWMPeriod (float hz)
 
void enableMotor (AdafruitMS1438.DCMOTORS_T motor)
 
void disableMotor (AdafruitMS1438.DCMOTORS_T motor)
 
void enableStepper (AdafruitMS1438.STEPMOTORS_T motor)
 
void disableStepper (AdafruitMS1438.STEPMOTORS_T motor)
 
void setMotorSpeed (AdafruitMS1438.DCMOTORS_T motor, int speed)
 
void setStepperSpeed (AdafruitMS1438.STEPMOTORS_T motor, int speed)
 
void setMotorDirection (AdafruitMS1438.DCMOTORS_T motor, AdafruitMS1438.DIRECTION_T dir)
 
void setStepperDirection (AdafruitMS1438.STEPMOTORS_T motor, AdafruitMS1438.DIRECTION_T dir)
 
void stepConfig (AdafruitMS1438.STEPMOTORS_T motor, long stepsPerRev)
 
void stepperSteps (AdafruitMS1438.STEPMOTORS_T motor, long steps)
 

Constructor & Destructor Documentation

AdafruitMS1438 ( int  bus,
short  address 
)

AdafruitMS1438 constructor

Parameters
busI2C bus to use
addressAddress for this sensor

Member Function Documentation

void disableMotor ( AdafruitMS1438.DCMOTORS_T  motor)

Disables PWM output for a motor

Parameters
motorDC motor to disable
void disableStepper ( AdafruitMS1438.STEPMOTORS_T  motor)

Disable output for a stepper motor

Parameters
motorStepper motor to disable
void enableMotor ( AdafruitMS1438.DCMOTORS_T  motor)

Enables PWM output for a motor

Parameters
motorDC motor to enable
void enableStepper ( AdafruitMS1438.STEPMOTORS_T  motor)

Enables output for a stepper motor

Parameters
motorStepper motor to enable
long getMillis ( AdafruitMS1438.STEPMOTORS_T  motor)

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

Returns
Elapsed milliseconds
void initClock ( AdafruitMS1438.STEPMOTORS_T  motor)

Resets the clock

void setMotorDirection ( AdafruitMS1438.DCMOTORS_T  motor,
AdafruitMS1438.DIRECTION_T  dir 
)

Sets the direction of a DC motor, clockwise or counterclockwise

Parameters
motorDC motor to configure
dirDirection to set the motor in
void setMotorSpeed ( AdafruitMS1438.DCMOTORS_T  motor,
int  speed 
)

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

Parameters
motorthe DC motor to configure
speedspeed to set the motor to
void setPWMPeriod ( float  hz)

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

Parameters
hzSets the PWM period
void setStepperDirection ( AdafruitMS1438.STEPMOTORS_T  motor,
AdafruitMS1438.DIRECTION_T  dir 
)

Sets the direction of a stepper motor, clockwise or counterclockwise

Parameters
motorStepper motor to configure
dirDirection to set the motor in
void setStepperSpeed ( AdafruitMS1438.STEPMOTORS_T  motor,
int  speed 
)

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

Parameters
motorDC motor to configure
speedSpeed to set the motor to
void stepConfig ( AdafruitMS1438.STEPMOTORS_T  motor,
long  stepsPerRev 
)

Sets a stepper motor configuration

Parameters
motorStepper motor to configure
stepsPerRevNumber of steps to complete a full revolution
void stepperSteps ( AdafruitMS1438.STEPMOTORS_T  motor,
long  steps 
)

Steps a stepper motor a specified number of steps

Parameters
motorStepper motor to step
stepsNumber of steps to move the stepper motor

The documentation for this class was generated from the following file: