DRV8434S library
|
#include <DRV8434S.h>
Public Member Functions | |
DRV8434S () | |
The default constructor. More... | |
void | setChipSelectPin (uint8_t pin) |
void | resetSettings () |
bool | verifySettings () |
void | applySettings () |
void | setCurrentPercent (uint8_t percent) |
void | setCurrentMilliamps (uint16_t current, uint16_t fullCurrent=2000) |
void | enableDriver () |
Enables the driver (EN_OUT = 1). More... | |
void | disableDriver () |
Disables the driver (EN_OUT = 0). More... | |
void | setDecayMode (DRV8434SDecayMode mode) |
void | setDirection (bool value) |
bool | getDirection () |
void | step () |
void | enableSPIDirection () |
void | disableSPIDirection () |
void | enableSPIStep () |
void | disableSPIStep () |
void | setStepMode (DRV8434SStepMode mode) |
void | setStepMode (uint16_t mode) |
uint8_t | readFault () |
uint8_t | readDiag1 () |
uint8_t | readDiag2 () |
void | clearFaults () |
uint8_t | getCachedReg (DRV8434SRegAddr address) |
void | setReg (DRV8434SRegAddr address, uint8_t value) |
Public Attributes | |
DRV8434SSPI | driver |
Protected Member Functions | |
uint8_t * | cachedRegPtr (DRV8434SRegAddr address) |
void | writeCachedReg (DRV8434SRegAddr address) |
Writes the cached value of the given register to the device. More... | |
Protected Attributes | |
uint8_t | ctrl1 |
uint8_t | ctrl2 |
uint8_t | ctrl3 |
uint8_t | ctrl4 |
uint8_t | ctrl5 |
uint8_t | ctrl6 |
uint8_t | ctrl7 |
This class provides high-level functions for controlling a DRV8434S stepper motor driver.
Definition at line 259 of file DRV8434S.h.
|
inline |
The default constructor.
Definition at line 263 of file DRV8434S.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 326 of file DRV8434S.h.
|
inlineprotected |
Returns a pointer to the variable containing the cached value for the given register.
Definition at line 648 of file DRV8434S.h.
|
inline |
Clears any fault conditions that are currently latched in the driver (CLR_FLT = 1).
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.
The driver automatically clears the CLR_FLT bit after it is written.
Definition at line 611 of file DRV8434S.h.
|
inline |
Disables the driver (EN_OUT = 0).
Definition at line 413 of file DRV8434S.h.
|
inline |
Disables direction control through SPI (SPI_DIR = 0), making the DIR pin control direction instead.
Definition at line 482 of file DRV8434S.h.
|
inline |
Disables stepping through SPI (SPI_STEP = 0), making the STEP pin control stepping instead.
Definition at line 498 of file DRV8434S.h.
|
inline |
Enables the driver (EN_OUT = 1).
Definition at line 406 of file DRV8434S.h.
|
inline |
Enables direction control through SPI (SPI_DIR = 1), allowing setDirection() to override the DIR pin.
Definition at line 474 of file DRV8434S.h.
|
inline |
Enables stepping through SPI (SPI_STEP = 1), allowing step() to override the STEP pin.
Definition at line 490 of file DRV8434S.h.
|
inline |
Gets the cached value of a register. If the given register address is not valid, this function returns 0.
Definition at line 618 of file DRV8434S.h.
|
inline |
Returns the cached value of the motor direction (DIR).
This does not perform any SPI communication with the driver.
Definition at line 455 of file DRV8434S.h.
|
inline |
Reads the DIAG1 status register of the driver.
The return value is an 8-bit unsigned integer that has one bit for each DIAG1 condition. You can simply compare the return value to 0 to see if any of the bits are set, or you can use the logical AND operator (&
) and the DRV8434SDiag1Bit enum to check individual bits.
Definition at line 586 of file DRV8434S.h.
|
inline |
Reads the DIAG2 status register of the driver.
The return value is an 8-bit unsigned integer that has one bit for each DIAG2 condition. You can simply compare the return value to 0 to see if any of the bits are set, or you can use the logical AND operator (&
) and the DRV8434SDiag2Bit enum to check individual bits.
Definition at line 597 of file DRV8434S.h.
|
inline |
Reads the FAULT status register of the driver.
The return value is an 8-bit unsigned integer that has one bit for each FAULT condition. You can simply compare the return value to 0 to see if any of the bits are set, or you can use the logical AND operator (&
) and the DRV8434SFaultBit enum to check individual bits.
Example usage:
Definition at line 575 of file DRV8434S.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 287 of file DRV8434S.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 277 of file DRV8434S.h.
|
inline |
Sets the driver's current scalar (TRQ_DAC) to produce the specified scaled current limit in milliamps. In order to calculate the correct value for TRQ_DAC, this function also needs to know the full current limit set by VREF (i.e. what the current limit is when the scaling is set to 100%). This is specified by the optional fullCurrent
argument, which defaults to 2000 milliamps (2 A).
If the desired current limit is not available, this function tries to pick the closest current limit that is lower than the desired one (although the lowest possible setting is 6.25% of the full current limit).
Example usage:
Definition at line 393 of file DRV8434S.h.
|
inline |
Sets the driver's current scalar (TRQ_DAC), which scales the full current limit (as set by VREF) by the specified percentage. The available settings are multiples of 6.25%.
This function takes an integer, and if the desired current limit is not available, it generally tries to pick the closest current limit that is lower than the desired one (although the lowest possible setting is 6.25%). However, it will round up if the next setting is no more than 0.75% higher; this allows you to specify 43.75% by passing a value of 43, for example.
Example usage:
Definition at line 363 of file DRV8434S.h.
|
inline |
Sets the driver's decay mode (DECAY).
Example usage:
Definition at line 425 of file DRV8434S.h.
|
inline |
Sets the motor direction (DIR).
Allowed values are 0 or 1.
You must first call enableSPIDirection() to allow the direction to be controlled through SPI. Once you have done so, you can use this command to control the direction of the stepper motor and leave the DIR pin disconnected.
Definition at line 439 of file DRV8434S.h.
|
inline |
Writes the specified value to a register after updating the cached value to match.
Using this function keeps this object's cached settings consistent with the settings being written to the driver, so if you are using verifySettings(), applySettings(), and/or any of the other functions for specific settings that this library provides, you should use this function for direct register accesses instead of calling DRV8434SSPI::writeReg() directly.
Definition at line 634 of file DRV8434S.h.
|
inline |
Sets the driver's stepping mode (MICROSTEP_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/16 micro-step, which is the driver's default.
Example usage:
Definition at line 517 of file DRV8434S.h.
|
inline |
Sets the driver's stepping mode (MICROSTEP_MODE).
This version of the function allows you to express the requested microstepping ratio as a number directly.
Example usage:
Definition at line 538 of file DRV8434S.h.
|
inline |
Advances the indexer by one step (STEP = 1).
You must first call enableSPIStep() to allow stepping to be controlled through SPI. Once you have done so, you can use this command to step the motor and leave the STEP pin disconnected.
The driver automatically clears the STEP bit after it is written.
Definition at line 467 of file DRV8434S.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 308 of file DRV8434S.h.
|
inlineprotected |
Writes the cached value of the given register to the device.
Definition at line 664 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
|
protected |
Definition at line 644 of file DRV8434S.h.
DRV8434SSPI DRV8434S::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 677 of file DRV8434S.h.