HighPowerStepperDriver
|
#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 |
This class provides high-level functions for controlling a DRV8711-based High-Power Stepper Motor Driver.
Definition at line 178 of file HighPowerStepperDriver.h.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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:
Definition at line 445 of file HighPowerStepperDriver.h.
|
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.
|
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.
|
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.
|
inline |
Sets the driver's decay mode (DECMOD).
Example usage:
Definition at line 424 of file HighPowerStepperDriver.h.
|
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.
|
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:
Definition at line 327 of file HighPowerStepperDriver.h.
|
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.
Definition at line 359 of file HighPowerStepperDriver.h.
|
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.
|
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.
Definition at line 227 of file HighPowerStepperDriver.h.
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.