Koduino
|
Derived class for communicating with PWM-controlled boards. More...
#include <Motor.h>
Derived class for communicating with PWM-controlled boards.
Uses PWM signals to send open loop commands, and receive position.
Public Member Functions | |
void | init (uint8_t outPin_, uint8_t inPin_, float zero, int8_t dir, float gearRatio) |
Initialize a motor for PWM communication. More... | |
void | init (uint8_t outPin_, uint8_t inPin_, float zero, int8_t dir) |
Initialize a motor with gear ratio 1. More... | |
void | enable (bool flag) |
Enable the motor. More... | |
float | getRawPosition () |
Raw position read from the motor driver. More... | |
void | sendOpenLoop (float val) |
Communicate a raw PWM to the motor controller. More... | |
Public Member Functions inherited from Motor | |
void | init (float zero, int8_t direction, float gearRatio) |
Initialize motor properties. More... | |
float | getPosition () |
Get position after direction and zero are taken into account. More... | |
float | getVelocity () |
Get motor velocity after direction and zero are taken into account. More... | |
float | getOpenLoop () |
Get the PWM duty cycle commanded to the motor. More... | |
void | setTorqueEstParams (float Kt, float res, float Vsource, float curLim) |
Details for torque estimate in getTorque(). Not used elsewhere. More... | |
float | getTorque () |
Returns an estimate of torque assuming quasistatic. More... | |
void | setOpenLoop (float val) |
Set an open loop PWM command for the motor. More... | |
void | setGain (float Kp, float Kd) |
Set gain for position control. More... | |
void | setGain (float Kp) |
Set P-gain for position control (D-gain is set to 0) More... | |
void | setPosition (float setpoint) |
Set a desired position for the motor in radians. More... | |
float | update () |
Function that communicates with the motor controller (including getting position, commanding PWM) More... | |
void | resetOffset () |
Run this after you are sure there is non-garbage rawPosition data. | |
Static Public Attributes | |
static bool | useEXTI = false |
Set if all instances of BlCon34 use PWM_IN_EXTI (true) or PWM_IN (false). See pwmIn(). | |
Static Public Attributes inherited from Motor | |
static int | updateRate = 1000 |
Set expected rate (Hz) at which update() will be called. More... | |
static float | velSmooth = 0.8 |
Set smoothing factor for getVelocity() (0 is no smoothing, 1 never updates) | |
Inherits Motor.
|
virtual |
Enable the motor.
Must be implemented in derived classes
flag | true to enable, false to disable |
Implements Motor.
|
virtual |
Raw position read from the motor driver.
This is before the direction/zero are applied. The user should call getPosition()
Implements Motor.
void BlCon34::init | ( | uint8_t | outPin_, |
uint8_t | inPin_, | ||
float | zero, | ||
int8_t | dir, | ||
float | gearRatio | ||
) |
Initialize a motor for PWM communication.
outPin_ | PWM out pin (must be a PWM pin) |
inPin_ | PWM in pin (must be a PWM pin if BlCon34::useEXTI is false, otherwise an external interrupt pin) |
zero | See Motor::init() |
dir | See Motor::init() |
gearRatio | See Motor::init() |
|
inline |
Initialize a motor with gear ratio 1.
outPin_ | PWM out pin (must be a PWM pin) |
inPin_ | PWM in pin (must be a PWM pin if BlCon34::useEXTI is false, otherwise an external interrupt pin) |
zero | See Motor::init() |
dir | See Motor::init() |
|
virtual |
Communicate a raw PWM to the motor controller.
Must be implemented in derived classes. The user should call setOpenLoop()
val | Raw PWM in [-1, 1] |
Implements Motor.