John Bailey / ArduinoMotorShield

Dependents:   MUTTv1 ProvaMotoreSeriale SerialComLED motore2 ... more

Embed: (wiki syntax)

« Back to documentation index

ArduinoMotorShield Class Reference

ArduinoMotorShield Class Reference

Class to abstract the interface to an Arduino Motor Shield R3 See http://arduino.cc/en/Main/ArduinoMotorShieldR3. More...

#include <ArduinoMotorShield.hpp>

Public Types

enum  Motor_e
 

Enumeration to distinguish between the motors connected to the shield.

More...

Public Member Functions

 ArduinoMotorShield ()
 Constructor.
void SetMotorPower (const Motor_e p_motor, const float p_speed, bool p_force=false)
 Set the motor power (and direction) for the specified motor.
float GetMotorCurrent (const Motor_e p_motor)
 Retrieve the current being consumed by the specified motor.
void SetBrake (const Motor_e p_motor, bool p_enable)
 Enable or disable the brake on the specified motor.
void SetMotorPolarity (const Motor_e p_motor, const MotorDirection_e p_dir)
 Set the virtual 'polarity' of a motor.

Static Protected Attributes

static const uint8_t MOTOR_DRIVE_COUNT = 2U
 Maximum number of motors which can be connected to the shield.
static const uint8_t MOTOR_MAX_CURRENT = 2U
 Maximum current (per motor drive) supported by the shield.

Detailed Description

Class to abstract the interface to an Arduino Motor Shield R3 See http://arduino.cc/en/Main/ArduinoMotorShieldR3.

This class is a pretty thin wrapper around the analog inputs and digital outputs which interface to the motor drives

Currently supports: TARGET_KL46Z - Assumes the presence of the cross-wiring on PWM B (see "Issues" at http://mbed.org/users/johnb/notebook/mutt-mbed-enabled-robot-vehicle/ )

Definition at line 45 of file ArduinoMotorShield.hpp.


Member Enumeration Documentation

enum Motor_e

Enumeration to distinguish between the motors connected to the shield.

Definition at line 56 of file ArduinoMotorShield.hpp.


Constructor & Destructor Documentation

Constructor.


Member Function Documentation

float GetMotorCurrent ( const Motor_e  p_motor )

Retrieve the current being consumed by the specified motor.

Parameters:
p_motorThe motor to retrieve the current for

Definition at line 95 of file ArduinoMotorShield.cpp.

void SetBrake ( const Motor_e  p_motor,
bool  p_enable 
)

Enable or disable the brake on the specified motor.

In the case that the braking option is enabled then (when appropriate) the shield will actively brake the motor rather than allowing it to coast down

Parameters:
p_motorThe motor to set the brake option for
p_enableSpecify whether braking should be enabled or disabled

Definition at line 101 of file ArduinoMotorShield.cpp.

void SetMotorPolarity ( const Motor_e  p_motor,
const MotorDirection_e  p_dir 
)

Set the virtual 'polarity' of a motor.

This allows you to swap the meaning of "forward" with respect to the SetMotorPower() method. For example:

shield.SetMotorPolarity( MOTOR_A, MOTOR_FORWARD ); shield.SetMotorPower( MOTOR_A, 1.0F ); This call will cause the motor to change direction ! shield.SetMotorPolarity( MOTOR_A, MOTOR_BACKWARD ); No further change is caused by this call shield.SetMotorPower( MOTOR_A, 1.0F );

Parameters:
p_motorThe motor to change the direction setting for
p_dirThe direction which "forward" should map to.

Definition at line 106 of file ArduinoMotorShield.cpp.

void SetMotorPower ( const Motor_e  p_motor,
const float  p_speed,
bool  p_force = false 
)

Set the motor power (and direction) for the specified motor.

Parameters:
p_motorUse this parameter to specify which motor to set the power on
p_speedSet the power of the motor, ranging from -1 (full power, reverse direction) to +1 (full power, forward direction)

Definition at line 78 of file ArduinoMotorShield.cpp.


Field Documentation

const uint8_t MOTOR_DRIVE_COUNT = 2U [static, protected]

Maximum number of motors which can be connected to the shield.

Definition at line 66 of file ArduinoMotorShield.hpp.

const uint8_t MOTOR_MAX_CURRENT = 2U [static, protected]

Maximum current (per motor drive) supported by the shield.

Definition at line 69 of file ArduinoMotorShield.hpp.