Class MotorControl

Class Documentation

class btn99x0::MotorControl

Public Functions

MotorControl(DCShield &shield)

BTN99x0 Motor Control Constructor.

Parameters

shield[in] DC shield reference to be used for motor controlling

Pre

None

~MotorControl()

BTN99x0 Motor Control Destructor.

Pre

None

void begin()

Initializes the motor controller.

Initializes both half-bridges

Pre

None

void brake(void)

Stops the motor.

Sets the input pin of both half-bridges to low

Pre

None

void freewheel(void)

Sets the motor in freewheeling mode.

Sets the inhibit pin of both half-bridges to low

Pre

None

void set_speed(int16_t speed)

Sets the motor speed.

Enables the half-bridges outputs and provides a PWM with the given duty cycle to half-bridge 1 if the speed is positive, or to half-bridge 2 if the speed is negative

Note

If speed values out of range are provided these will be set the maximum or minimum allowed

Parameters

speed[in] Motor speed. Valid range is between -255 and 255. Use positive duty values for forward rotation and negative for backward rotation

Pre

None

void set_slew_rate(slew_rate_level_t sr_level)

Sets slew rate level.

Sets the slew rate level of both half-bridges

Warning

The current operation requires the device to be in slew rate selection mode, meaning the INH pins to be set to low. The function operates the INPUT pins, any PWM values previously configured will be overwritten

Parameters

sr_level[in] Slew rate level

Pre

begin() and freewheel() if the motor has been previously enabled