upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the SmartDrive advanced motor controller from OpenElectronis. More...
SmartDrive is a multiplexer to control high current DC motors
This module has been tested on the SmartDrive.
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) |
SmartDrive | ( | int | i2c_bus, |
int | address = SmartDrive_DefaultAddress |
||
) |
Initialize the class with the i2c address of your SmartDrive
i2c_bus | I2C bus to use. |
address | Address of your SmartDrive. |
void command | ( | uint8_t | cmd | ) |
Writes a specified command on the command register of the SmartDrive
cmd | The 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
motor_id | Number of the motor you wish to read. |
void Run_Unlimited | ( | int | motor_id, |
int | direction, | ||
uint8_t | speed | ||
) |
Turns the specified motor(s) forever
motor_id | Number of the motor(s) you wish to turn. |
direction | The direction you wish to turn the motor(s). |
speed | The speed at which you wish to turn the motor(s). |
void StopMotor | ( | int | motor_id, |
int | next_action | ||
) |
Stops the specified motor(s)
motor_id | Number of the motor(s) you wish to turn. |
next_action | How 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
motor_id | Number of the motor(s) you wish to turn. |
direction | The direction you wish to turn the motor(s). |
speed | The speed at which you wish to turn the motor(s). |
duration | The time in seconds you wish to turn the motor(s). |
wait_for_completion | Tells the program when to handle the next line of code. |
next_action | How you wish to stop the motor(s). |
void WaitUntilTimeDone | ( | int | motor_id | ) |
Waits until the specified time for the motor(s) to run is completed
motor_id | Number of the motor(s) to wait for. |
bool IsTimeDone | ( | int | motor_id | ) |
Checks to ensure the specified time for the motor(s) to run is completed.
motor_id | Number of the motor(s) to check. |
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
motor_id | Number of the motor(s) you wish to turn. |
direction | The direction you wish to turn the motor(s). |
speed | The speed at which you wish to turn the motor(s). |
degrees | The relative tacheometer count you wish to turn the motor(s). |
wait_for_completion | Tells the program when to handle the next line of code. |
next_action | How you wish to stop the motor(s). |
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
motor_id | Number of the motor(s) you wish to turn. |
direction | The direction you wish to turn the motor(s). |
speed | The speed at which you wish to turn the motor(s). |
rotations | The relative amount of rotations you wish to turn the motor(s). |
wait_for_completion | Tells the program when to handle the next line of code. |
next_action | How you wish to stop the motor(s). |
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
motor_id | Number of the motor(s) you wish to turn. |
speed | The speed at which you wish to turn the motor(s). |
tacho_count | The absolute tacheometer count you wish to turn the motor(s). |
wait_for_completion | Tells the program when to handle the next line of code. |
next_action | How you wish to stop the motor(s). |
void WaitUntilTachoDone | ( | int | motor_id | ) |
Waits until the specified tacheomter count for the motor(s) to run is reached.
motor_id | Number of the motor(s) to wait for. |
bool IsTachoDone | ( | int | motor_id | ) |
Checks to ensure the specified tacheomter count for the motor(s) to run is reached.
motor_id | Number of the motor(s) to check. |
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
Kp_tacho | Proportional-gain of the tacheometer position of the motor. |
Ki_tacho | Integral-gain of the tacheometer position of the motor. |
Kd_tacho | Derivative-gain of the tacheometer position of the motor. |
Kp_speed | Proportional-gain of the speed of the motor. |
Ki_speed | Integral-gain of the speed of the motor. |
Kd_speed | Derivative-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
void PrintMotorStatus | ( | int | motor_id | ) |
Print the detailed status of the motor
motor_id | Number fo the motor to check |