Robot Control Library
|
Control 4 DC motor Channels.
The robotics cape can drive 4 DC motors bidirectionally powered only from a 2-cell lithium battery pack connected to the cape. The motors will not draw power from USB or the 9-18v DC Jack. Each channel can support 1.2A continuous and the user must be careful to choose motors which will not exceed this rating when stalled. Each channel is broken out on an independent 2-pin JST ZH connector.
Macros | |
#define | RC_MOTOR_DEFAULT_PWM_FREQ 25000 |
25kHz More... | |
Functions | |
int | rc_motor_init (void) |
Initializes all 4 motors and leaves them in a free-spin (0 throttle) state. More... | |
int | rc_motor_init_freq (int pwm_frequency_hz) |
Just like rc_motor_init but allows the user to set the pwm frequency. More... | |
int | rc_motor_cleanup (void) |
Puts all 4 motors into a free-spin (0 throttle) state, puts the h-bridges into standby mode, and closes all file pointers to GPIO and PWM systems. More... | |
int | rc_motor_standby (int standby_en) |
Toggle the H-bridges in and out of low-power standby mode. More... | |
int | rc_motor_set (int ch, double duty) |
Sets the bidirectional duty cycle (power) to a single motor or all motors if 0 is provided as a channel. More... | |
int | rc_motor_free_spin (int ch) |
Puts a motor into a zero-throttle state allowing it to spin freely. More... | |
int | rc_motor_brake (int ch) |
Connects the motor terminal pairs together which makes the motor fight against its own back EMF turning it into a brake resisting rotation. More... | |
#define RC_MOTOR_DEFAULT_PWM_FREQ 25000 |
25kHz
int rc_motor_init | ( | void | ) |
Initializes all 4 motors and leaves them in a free-spin (0 throttle) state.
Note, if the user is optionally using the rc_motor_standby functionality they should be aware that rc_motor_init starts standby mode in a disabled state so it is not necessary for the majority of users who are not interested in standby mode.
This starts the motor drivers at RC_MOTOR_DEFAULT_PWM_FREQ. To use another frequency initialize with rc_motor_init_freq instead.
int rc_motor_init_freq | ( | int | pwm_frequency_hz | ) |
Just like rc_motor_init but allows the user to set the pwm frequency.
RC_MOTOR_DEFAULT_PWM_FREQ is a good frequency to start at.
Note, if the user is optionally using the rc_motor_standby functionality they should be aware that rc_motor_init starts standby mode in a disabled state so it is not necessary for the majority of users who are not interested in standby mode.
[in] | pwm_frequency_hz | The pwm frequency in hz |
int rc_motor_cleanup | ( | void | ) |
Puts all 4 motors into a free-spin (0 throttle) state, puts the h-bridges into standby mode, and closes all file pointers to GPIO and PWM systems.
int rc_motor_standby | ( | int | standby_en | ) |
Toggle the H-bridges in and out of low-power standby mode.
This is an entirely optional function as calling rc_motor_cleanup when your program closes will put the h-bridges into standby mode and then calling rc_motor_init at the beginning of your program will take them out of standby mode. However, if the user wishes to toggle in and out of standby mode in their program (for example while paused) then they can use this function.
[in] | standby_en | 1 to enable standby mode, 0 to disable |
int rc_motor_set | ( | int | ch, |
double | duty | ||
) |
Sets the bidirectional duty cycle (power) to a single motor or all motors if 0 is provided as a channel.
[in] | ch | The motor channel (1-4) or 0 for all channels. |
[in] | duty | Duty cycle, -1.0 for full reverse, 1.0 for full forward |
int rc_motor_free_spin | ( | int | ch | ) |
Puts a motor into a zero-throttle state allowing it to spin freely.
This is accomplished by putting both motor terminals connected to the h-bridge into a high-impedance state.
[in] | ch | The motor channel (1-4) or 0 for all channels. |
int rc_motor_brake | ( | int | ch | ) |
Connects the motor terminal pairs together which makes the motor fight against its own back EMF turning it into a brake resisting rotation.
[in] | ch | The motor channel (1-4) or 0 for all channels. |