RSeries astromech firmware
TB9051FTGMotorCarrier Class Reference

#include <motor/TB9051FTGMotorCarrier.h>

Detailed Description

Implements support for the Pololu TB9051FTG MotorCarrier (https://www.pololu.com/product/2997)

Public Member Functions

 TB9051FTGMotorCarrier (uint8_t pwm1, uint8_t pwm2, uint8_t en=kPinNotUsed, uint8_t enb=kPinNotUsed, uint8_t ocm=kPinNotUsed, uint8_t diag=kPinNotUsed, uint8_t occ=kPinNotUsed)
 Constructor. More...
 
float getCurrent (void) const
 Reads an estimate of the motor current from the motor driver carrier. More...
 
uint8_t getDiagnostic (void) const
 Reads the DIAG pin on the motor driver carrier. More...
 
void setDeadband (float lower, float upper)
 Sets the dead band range. More...
 
void setBrakeMode (bool mode)
 Sets the brake mode for the motor driver carrier. More...
 
void setOutput (float percent) const
 Sets the throttle output percentage [-1, 1], which is the percentage of the driver carrier's input voltage. More...
 
void setOccResponse (bool automatic) const
 Sets the over-current response. More...
 
void enable (void)
 Enable the motor driver carrier's outputs. More...
 
void disable (void)
 Disable the motor driver carrier's outputs. More...
 

Static Public Attributes

static constexpr uint8_t kPinNotUsed {255}
 

Constructor & Destructor Documentation

◆ TB9051FTGMotorCarrier()

TB9051FTGMotorCarrier::TB9051FTGMotorCarrier ( uint8_t  pwm1,
uint8_t  pwm2,
uint8_t  en = kPinNotUsed,
uint8_t  enb = kPinNotUsed,
uint8_t  ocm = kPinNotUsed,
uint8_t  diag = kPinNotUsed,
uint8_t  occ = kPinNotUsed 
)
inline

Constructor.

Construct a new instance of TB9051FTGMotorCarrier.

Parameters
pwm1The pin number connected to the PWM1 input on the motor driver carrier
pwm2The pin number connected to the PWM2 input on the motor driver carrier
en(Optional) The pin number connected to the EN input on the motor driver carrier. Defaults to kPinNotUsed
enb(Optional) The pin number connected to the ENB input on the motor driver carrier. Defaults to kPinNotUsed
ocm(Optional) The pin number connected to the OCM output on the motor driver carrier. Defaults to kPinNotUsed
diag(Optional) The pin number connected to the DIAG output on the motor driver carrier. Defaults to kPinNotUsed
occ(Optional) The pin number connected to the OCC input on the motor driver carrier. Defaults to kPinNotUsed

Member Function Documentation

◆ disable()

void TB9051FTGMotorCarrier::disable ( void  )
inline

Disable the motor driver carrier's outputs.

◆ enable()

void TB9051FTGMotorCarrier::enable ( void  )
inline

Enable the motor driver carrier's outputs.

The motor driver carrier Initially is disabled, so it needs to be manually enabled using this function

◆ getCurrent()

float TB9051FTGMotorCarrier::getCurrent ( void  ) const
inline

Reads an estimate of the motor current from the motor driver carrier.

Output is in milliamps (mA). Note: This measurement is a coarse approximation only. Consider using an external sensor for fine current measurements.

Returns
Current measurement in mA

◆ getDiagnostic()

uint8_t TB9051FTGMotorCarrier::getDiagnostic ( void  ) const
inline

Reads the DIAG pin on the motor driver carrier.

If there is a fault, or if the motor driver carrier is disabled by the EN or ENB pins, it returns logical low (0). Otherwise, it returns logical high (1)

Returns
0 if fault or disabled. 1 otherwise.

◆ setBrakeMode()

void TB9051FTGMotorCarrier::setBrakeMode ( bool  mode)
inline

Sets the brake mode for the motor driver carrier.

If the carrier is set to brake mode (mode 1), the carrier outputs will be shorted to ground when the motor stops. This acts as a brake. If the carrier is not set to brake mode (0), the carrier outputs will be left floating, so the motor will coast to a stop.

Parameters
modeBrake mode (true) or non brake mode (false).

◆ setDeadband()

void TB9051FTGMotorCarrier::setDeadband ( float  lower,
float  upper 
)
inline

Sets the dead band range.

When the throttle output value is within this range, the motor driver carrier stops the motor according to the current brake mode configuration

Parameters
lowerLower dead band value (exclusively)
upperUpper dead band value (exclusively)

◆ setOccResponse()

void TB9051FTGMotorCarrier::setOccResponse ( bool  automatic) const
inline

Sets the over-current response.

If false, the motor driver carrier is disabled when an over-current event happens. The motor driver carrier can be reset by toggling either the EN pin or the ENB pin. If true, the motor driver carrier will re-enable after a short period following an over-current event.

Parameters
automaticover-current response

◆ setOutput()

void TB9051FTGMotorCarrier::setOutput ( float  percent) const
inline

Sets the throttle output percentage [-1, 1], which is the percentage of the driver carrier's input voltage.

When the output percentage is negative, the motor will turn in reverse

Parameters
percentoutput throttle percentage (-1.0 - 1.0)

Member Data Documentation

◆ kPinNotUsed

constexpr uint8_t TB9051FTGMotorCarrier::kPinNotUsed {255}
staticconstexpr

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