Koduino
Public Member Functions | Static Public Attributes | List of all members
BlCon34 Class Reference

Derived class for communicating with PWM-controlled boards. More...

#include <Motor.h>

Detailed Description

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.

Member Function Documentation

void BlCon34::enable ( bool  flag)
virtual

Enable the motor.

Must be implemented in derived classes

Parameters
flagtrue to enable, false to disable

Implements Motor.

float BlCon34::getRawPosition ( )
virtual

Raw position read from the motor driver.

This is before the direction/zero are applied. The user should call getPosition()

Returns
Raw position in [0, 2pi]

Implements Motor.

void BlCon34::init ( uint8_t  outPin_,
uint8_t  inPin_,
float  zero,
int8_t  dir,
float  gearRatio 
)

Initialize a motor for PWM communication.

Parameters
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)
zeroSee Motor::init()
dirSee Motor::init()
gearRatioSee Motor::init()
void BlCon34::init ( uint8_t  outPin_,
uint8_t  inPin_,
float  zero,
int8_t  dir 
)
inline

Initialize a motor with gear ratio 1.

Parameters
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)
zeroSee Motor::init()
dirSee Motor::init()
void BlCon34::sendOpenLoop ( float  val)
virtual

Communicate a raw PWM to the motor controller.

Must be implemented in derived classes. The user should call setOpenLoop()

Parameters
valRaw PWM in [-1, 1]

Implements Motor.


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