HighPowerStepperDriver
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
HighPowerStepperDriver Class Reference

#include <HighPowerStepperDriver.h>

Public Member Functions

 HighPowerStepperDriver ()
 The default constructor.
 
void setChipSelectPin (uint8_t pin)
 
void resetSettings ()
 
bool verifySettings ()
 
void applySettings ()
 
void enableDriver ()
 Enables the driver (ENBL = 1).
 
void disableDriver ()
 Disables the driver (ENBL = 0).
 
void setDirection (bool value)
 
bool getDirection ()
 
void step ()
 
void setStepMode (HPSDStepMode mode)
 
void setStepMode (uint16_t mode)
 
void setCurrentMilliamps36v4 (uint16_t current)
 
void setDecayMode (HPSDDecayMode mode)
 
uint8_t readStatus ()
 
void clearStatus ()
 
uint8_t readFaults ()
 
void clearFaults ()
 

Public Attributes

DRV8711SPI driver
 

Protected Member Functions

void writeCTRL ()
 Writes the cached value of the CTRL register to the device.
 
void writeTORQUE ()
 Writes the cached value of the TORQUE register to the device.
 
void writeOFF ()
 Writes the cached value of the OFF register to the device.
 
void writeBLANK ()
 Writes the cached value of the BLANK register to the device.
 
void writeDECAY ()
 Writes the cached value of the DECAY register to the device.
 
void writeSTALL ()
 Writes the cached value of the STALL register to the device.
 
void writeDRIVE ()
 Writes the cached value of the DRIVE register to the device.
 

Protected Attributes

uint16_t ctrl
 
uint16_t torque
 
uint16_t off
 
uint16_t blank
 
uint16_t decay
 
uint16_t stall
 
uint16_t drive
 

Detailed Description

This class provides high-level functions for controlling a DRV8711-based High-Power Stepper Motor Driver.

Definition at line 178 of file HighPowerStepperDriver.h.

Member Function Documentation

◆ applySettings()

void HighPowerStepperDriver::applySettings ( )
inline

Re-writes the cached settings stored in this class to the device.

You should not normally need to call this function because settings are written to the device whenever they are changed. However, if verifySettings() returns false (due to a power interruption, for instance), then you could use applySettings() to get the device's settings back into the desired state.

Definition at line 246 of file HighPowerStepperDriver.h.

◆ clearFaults()

void HighPowerStepperDriver::clearFaults ( )
inline

Clears any fault conditions that are currently latched in the driver.

This function behaves the same as clearStatus(), except it only clears bits that indicate faults (STATUS bits 5:0).

WARNING: Calling this function clears latched faults, which might allow the motor driver outputs to reactivate. If you do this repeatedly without fixing an abnormal condition (like a short circuit), you might damage the driver.

Definition at line 480 of file HighPowerStepperDriver.h.

◆ clearStatus()

void HighPowerStepperDriver::clearStatus ( )
inline

Clears any status conditions that are currently latched in the driver.

WARNING: Calling this function clears latched faults, which might allow the motor driver outputs to reactivate. If you do this repeatedly without fixing an abnormal condition (like a short circuit), you might damage the driver.

Definition at line 456 of file HighPowerStepperDriver.h.

◆ getDirection()

bool HighPowerStepperDriver::getDirection ( )
inline

Returns the cached value of the motor direction (RDIR).

This does not perform any SPI communication with the driver.

Definition at line 298 of file HighPowerStepperDriver.h.

◆ readFaults()

uint8_t HighPowerStepperDriver::readFaults ( )
inline

Reads fault conditions indicated by the driver.

The return value is the same as that which would be returned by readStatus(), except it only contains bits that indicate faults (STATUS bits 5:0).

Definition at line 466 of file HighPowerStepperDriver.h.

◆ readStatus()

uint8_t HighPowerStepperDriver::readStatus ( )
inline

Reads the status of the driver (STATUS register).

The return value is an 8-bit unsigned integer that has one bit for each status condition (the upper 4 bits of the 12-bit STATUS register are not used). You can simply compare the return value to 0 to see if any of the status bits are set, or you can use the logical AND operator (&) and the HPSDStatusBit enum to check individual bits.

Example usage:

if (sd.readStatus() & (1 << (uint8_t)HPSDStatusBit::UVLO))
{
// Undervoltage lockout is active.
}

Definition at line 445 of file HighPowerStepperDriver.h.

◆ resetSettings()

void HighPowerStepperDriver::resetSettings ( )
inline

Changes all of the driver's settings back to their default values.

It is good to call this near the beginning of your program to ensure that there are no settings left over from an earlier time that might affect the operation of the driver.

Definition at line 206 of file HighPowerStepperDriver.h.

◆ setChipSelectPin()

void HighPowerStepperDriver::setChipSelectPin ( uint8_t  pin)
inline

Configures this object to use the specified pin as a chip select pin. You must use a chip select pin; the DRV8711 requires it.

Definition at line 196 of file HighPowerStepperDriver.h.

◆ setCurrentMilliamps36v4()

void HighPowerStepperDriver::setCurrentMilliamps36v4 ( uint16_t  current)
inline

Sets the current limit for a High-Power Stepper Motor Driver 36v4.

The argument to this function should be the desired current limit in milliamps.

WARNING: The 36v4 can supply up to about 4 A per coil continuously; higher currents might be sustainable for short periods, but can eventually cause the MOSFETs to overheat, which could damage them. See the driver's product page for more information.

This function allows you to set a current limit of up to 8 A (8000 mA), but we strongly recommend against using a current limit higher than 4 A (4000 mA) unless you are careful to monitor the MOSFETs' temperatures and/or restrict how long the driver uses the higher current limit.

This function takes care of setting appropriate values for ISGAIN and TORQUE to get the desired current limit.

Definition at line 381 of file HighPowerStepperDriver.h.

◆ setDecayMode()

void HighPowerStepperDriver::setDecayMode ( HPSDDecayMode  mode)
inline

Sets the driver's decay mode (DECMOD).

Example usage:

sd.setDecayMode(HPSDDecayMode::AutoMixed);

Definition at line 424 of file HighPowerStepperDriver.h.

◆ setDirection()

void HighPowerStepperDriver::setDirection ( bool  value)
inline

Sets the motor direction (RDIR).

Allowed values are 0 or 1.

You can use this command to control the direction of the stepper motor and leave the DIR pin disconnected.

Definition at line 282 of file HighPowerStepperDriver.h.

◆ setStepMode() [1/2]

void HighPowerStepperDriver::setStepMode ( HPSDStepMode  mode)
inline

Sets the driver's stepping mode (MODE).

This affects many things about the performance of the motor, including how much the output moves for each step taken and how much current flows through the coils in each stepping position.

If an invalid stepping mode is passed to this function, then it selects 1/4 micro-step, which is the driver's default.

Example usage:

sd.setStepMode(HPSDStepMode::MicroStep32);

Definition at line 327 of file HighPowerStepperDriver.h.

◆ setStepMode() [2/2]

void HighPowerStepperDriver::setStepMode ( uint16_t  mode)
inline

Sets the driver's stepping mode (MODE).

This version of the function allows you to express the requested microstepping ratio as a number directly.

sd.setStepMode(32);
See also
setStepMode(HPSDStepMode)

Definition at line 359 of file HighPowerStepperDriver.h.

◆ step()

void HighPowerStepperDriver::step ( )
inline

Advances the indexer by one step (RSTEP = 1).

You can use this command to step the stepper motor and leave the STEP pin disconnected.

The driver automatically clears the RSTEP bit after it is written.

Definition at line 309 of file HighPowerStepperDriver.h.

◆ verifySettings()

bool HighPowerStepperDriver::verifySettings ( )
inline

Reads back the SPI configuration registers from the device and verifies that they are equal to the cached copies stored in this class.

This can be used to verify that the driver is powered on and has not lost them due to a power failure. The STATUS register is not verified because it does not contain any driver settings.

Returns
1 if the settings from the device match the cached copies, 0 if they do not.

Definition at line 227 of file HighPowerStepperDriver.h.

Member Data Documentation

◆ driver

DRV8711SPI HighPowerStepperDriver::driver

This object handles all the communication with the DRV8711. Generally, you should not need to use it in your code for basic usage of a High-Power Stepper Motor Driver, but you might want to use it to access more advanced settings that the HighPowerStepperDriver class does not provide functions for.

Definition at line 537 of file HighPowerStepperDriver.h.


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