upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the SmartDrive advanced motor controller from OpenElectronis. More...

Detailed Description

SmartDrive is a multiplexer to control high current DC motors

This module has been tested on the SmartDrive.

// Instantiate a SmartDrive connected to /dev/i2c-0 bus, using DefaultAddress
upm::SmartDrive drive(0);
std::cout << "Battery Voltage before motor run : " << drive.GetBattVoltage() << std::endl;
// Set motor M1 to run for 120 seconds, with speed of 15RPM, waith for it to
// finish and then Brake It
drive.Run_Seconds(
SmartDrive_Motor_ID_1, SmartDrive_Dir_Forward, 15, 120, true, SmartDrive_Action_Brake);
std::cout << "Battery Voltage after motor run : " << drive.GetBattVoltage() << std::endl;
// Rotate motor M2 2270 degrees, in reverse sense, with speed of 10RPM, return
// immediately from function call
drive.Run_Degrees(
SmartDrive_Motor_ID_2, SmartDrive_Dir_Reverse, 10, 2270, false, SmartDrive_Action_Float);
// While motor is running, Display its status
drive.PrintMotorStatus(SmartDrive_Motor_ID_2);
upm_delay(2); // Sleep for 2 seconds
// Stop motor M2 and then finish program
drive.StopMotor(SmartDrive_Motor_ID_2, SmartDrive_Action_BrakeHold);

Public Member Functions

 SmartDrive (int i2c_bus, int address=SmartDrive_DefaultAddress)
 
void command (uint8_t cmd)
 
float GetBattVoltage ()
 
uint32_t ReadTachometerPosition (int motor_id)
 
void Run_Unlimited (int motor_id, int direction, uint8_t speed)
 
void StopMotor (int motor_id, int next_action)
 
void Run_Seconds (int motor_id, int direction, uint8_t speed, uint8_t duration, bool wait_for_completion, int next_action)
 
void WaitUntilTimeDone (int motor_id)
 
bool IsTimeDone (int motor_id)
 
void Run_Degrees (int motor_id, int direction, uint8_t speed, uint32_t degrees, bool wait_for_completion, int next_action)
 
void Run_Rotations (int motor_id, int direction, uint8_t speed, uint32_t rotations, bool wait_for_completion, int next_action)
 
void Run_Tacho (int motor_id, uint8_t speed, uint32_t tacho_count, bool wait_for_completion, int next_action)
 
void WaitUntilTachoDone (int motor_id)
 
bool IsTachoDone (int motor_id)
 
void SetPerformanceParameters (uint16_t Kp_tacho, uint16_t Ki_tacho, uint16_t Kd_tacho, uint16_t Kp_speed, uint16_t Ki_speed, uint16_t Kd_speed, uint8_t passcount, uint8_t tolerance)
 
void ReadPerformanceParameters ()
 
uint8_t GetMotorStatus (int motor_id)
 
void PrintMotorStatus (int motor_id)
 

Constructor & Destructor Documentation

SmartDrive ( int  i2c_bus,
int  address = SmartDrive_DefaultAddress 
)

Initialize the class with the i2c address of your SmartDrive

Parameters
i2c_busI2C bus to use.
addressAddress of your SmartDrive.

Member Function Documentation

void command ( uint8_t  cmd)

Writes a specified command on the command register of the SmartDrive

Parameters
cmdThe command you wish the SmartDrive to execute.
float GetBattVoltage ( )

Reads the battery voltage. Multiplier constant not yet verified

uint32_t ReadTachometerPosition ( int  motor_id)

Reads the tacheometer position of the specified motor

Parameters
motor_idNumber of the motor you wish to read.
void Run_Unlimited ( int  motor_id,
int  direction,
uint8_t  speed 
)

Turns the specified motor(s) forever

Parameters
motor_idNumber of the motor(s) you wish to turn.
directionThe direction you wish to turn the motor(s).
speedThe speed at which you wish to turn the motor(s).
void StopMotor ( int  motor_id,
int  next_action 
)

Stops the specified motor(s)

Parameters
motor_idNumber of the motor(s) you wish to turn.
next_actionHow you wish to stop the motor(s).
void Run_Seconds ( int  motor_id,
int  direction,
uint8_t  speed,
uint8_t  duration,
bool  wait_for_completion,
int  next_action 
)

Turns the specified motor(s) for a given amount of seconds

Parameters
motor_idNumber of the motor(s) you wish to turn.
directionThe direction you wish to turn the motor(s).
speedThe speed at which you wish to turn the motor(s).
durationThe time in seconds you wish to turn the motor(s).
wait_for_completionTells the program when to handle the next line of code.
next_actionHow you wish to stop the motor(s).

Here is the call graph for this function:

void WaitUntilTimeDone ( int  motor_id)

Waits until the specified time for the motor(s) to run is completed

Parameters
motor_idNumber of the motor(s) to wait for.

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsTimeDone ( int  motor_id)

Checks to ensure the specified time for the motor(s) to run is completed.

Parameters
motor_idNumber of the motor(s) to check.

Here is the caller graph for this function:

void Run_Degrees ( int  motor_id,
int  direction,
uint8_t  speed,
uint32_t  degrees,
bool  wait_for_completion,
int  next_action 
)

Turns the specified motor(s) for given relative tacheometer count

Parameters
motor_idNumber of the motor(s) you wish to turn.
directionThe direction you wish to turn the motor(s).
speedThe speed at which you wish to turn the motor(s).
degreesThe relative tacheometer count you wish to turn the motor(s).
wait_for_completionTells the program when to handle the next line of code.
next_actionHow you wish to stop the motor(s).

Here is the call graph for this function:

void Run_Rotations ( int  motor_id,
int  direction,
uint8_t  speed,
uint32_t  rotations,
bool  wait_for_completion,
int  next_action 
)

Turns the specified motor(s) for given relative tacheometer count

Parameters
motor_idNumber of the motor(s) you wish to turn.
directionThe direction you wish to turn the motor(s).
speedThe speed at which you wish to turn the motor(s).
rotationsThe relative amount of rotations you wish to turn the motor(s).
wait_for_completionTells the program when to handle the next line of code.
next_actionHow you wish to stop the motor(s).

Here is the call graph for this function:

void Run_Tacho ( int  motor_id,
uint8_t  speed,
uint32_t  tacho_count,
bool  wait_for_completion,
int  next_action 
)

Turns the specified motor(s) for given absolute tacheometer count

Parameters
motor_idNumber of the motor(s) you wish to turn.
speedThe speed at which you wish to turn the motor(s).
tacho_countThe absolute tacheometer count you wish to turn the motor(s).
wait_for_completionTells the program when to handle the next line of code.
next_actionHow you wish to stop the motor(s).

Here is the call graph for this function:

void WaitUntilTachoDone ( int  motor_id)

Waits until the specified tacheomter count for the motor(s) to run is reached.

Parameters
motor_idNumber of the motor(s) to wait for.

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsTachoDone ( int  motor_id)

Checks to ensure the specified tacheomter count for the motor(s) to run is reached.

Parameters
motor_idNumber of the motor(s) to check.

Here is the caller graph for this function:

void SetPerformanceParameters ( uint16_t  Kp_tacho,
uint16_t  Ki_tacho,
uint16_t  Kd_tacho,
uint16_t  Kp_speed,
uint16_t  Ki_speed,
uint16_t  Kd_speed,
uint8_t  passcount,
uint8_t  tolerance 
)

Writes user specified values to the PID control registers

Parameters
Kp_tachoProportional-gain of the tacheometer position of the motor.
Ki_tachoIntegral-gain of the tacheometer position of the motor.
Kd_tachoDerivative-gain of the tacheometer position of the motor.
Kp_speedProportional-gain of the speed of the motor.
Ki_speedIntegral-gain of the speed of the motor.
Kd_speedDerivative-gain of the speed of the motor.
void ReadPerformanceParameters ( )

Reads the values of the PID control registers

uint8_t GetMotorStatus ( int  motor_id)

Read the status of a motor, and return it in a uint8_t param motor_id Number fo the motor to check

Here is the caller graph for this function:

void PrintMotorStatus ( int  motor_id)

Print the detailed status of the motor

Parameters
motor_idNumber fo the motor to check

Here is the call graph for this function:


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