uStepper S
|
Prototype of class for the TMC5130 Driver. More...
#include <uStepperDriver.h>
Public Member Functions | |
uStepperDriver (void) | |
Constructor. More... | |
void | init (uStepperS *_pointer) |
Initiation of the motor driver. More... | |
void | setPosition (int32_t position) |
Set the motor position. More... | |
void | setVelocity (uint32_t velocity) |
Set motor velocity. More... | |
void | setAcceleration (uint32_t acceleration) |
Set motor acceleration. More... | |
void | setDeceleration (uint32_t deceleration) |
Set motor deceleration. More... | |
void | setCurrent (uint8_t current) |
Set motor driver current. More... | |
void | setHoldCurrent (uint8_t current) |
Set motor driver hold current. More... | |
void | setShaftDirection (bool direction) |
Set motor driver direction. More... | |
void | stop (void) |
Stops any ongoing movement with deceleration. | |
int32_t | getVelocity (void) |
Returns the current speed of the motor driver. More... | |
int32_t | getPosition (void) |
Returns the current position of the motor driver. More... | |
void | setHome (void) |
Resets the internal position counter of the motor driver. | |
int32_t | writeRegister (uint8_t address, uint32_t datagram) |
Write a register of the motor driver. More... | |
int32_t | readRegister (uint8_t address) |
Reads a register from the motor driver. More... | |
Public Attributes | |
volatile int32_t | xTarget = 0 |
Protected Member Functions | |
void | chipSelect (bool state) |
void | updateCurrent (void) |
Writes the current setting registers of the motor driver. More... | |
void | setRampMode (uint8_t mode) |
Set motor driver to position mode or velocity mode. More... | |
void | setDirection (bool direction) |
void | reset (void) |
void | enableStealth (void) |
void | readMotorStatus (void) |
Protected Attributes | |
uint8_t | status |
uint8_t | mode = DRIVER_STOP |
uStepperS * | pointer |
uint8_t | current = 16 |
uint8_t | holdCurrent = 10 |
uint8_t | holdDelay = 0 |
uint32_t | VSTART = 0 |
uint32_t | V1 = 0 |
uint32_t | VMAX = 200000 |
uint32_t | VSTOP = 10 |
uint16_t | A1 = 600 |
uint16_t | AMAX = 600 |
uint16_t | DMAX = 600 |
uint16_t | D1 = 600 |
Friends | |
class | uStepperS |
Prototype of class for the TMC5130 Driver.
This class enables the user of the library to access the TMC5130 Driver on the uStepper S board.
Definition at line 147 of file uStepperDriver.h.
uStepperDriver::uStepperDriver | ( | void | ) |
Constructor.
This is the constructor of the uStepperDriver class.
Definition at line 36 of file uStepperDriver.cpp.
int32_t uStepperDriver::getPosition | ( | void | ) |
Returns the current position of the motor driver.
This function returns the position of the motor drivers internal position counter. unit is in microsteps (default 1/256th).
Definition at line 225 of file uStepperDriver.cpp.
int32_t uStepperDriver::getVelocity | ( | void | ) |
Returns the current speed of the motor driver.
This function returns the current speed of the internal ramp generator of the motor driver. unit is in ((microsteps/s)/8MHz)/2^23. See page 74 of datasheet for more information
Definition at line 220 of file uStepperDriver.cpp.
void uStepperDriver::init | ( | uStepperS * | _pointer | ) |
Initiation of the motor driver.
This function initiates all the registers of the motor driver.
[in] | _pointer | - reference to the uStepper S object |
Definition at line 62 of file uStepperDriver.cpp.
int32_t uStepperDriver::readRegister | ( | uint8_t | address | ) |
Reads a register from the motor driver.
This function is used to read the content of a register in the TMC5130 motor driver. Please refer to datasheet for details.
[in] | address | - Register to read |
Definition at line 292 of file uStepperDriver.cpp.
void uStepperDriver::setAcceleration | ( | uint32_t | acceleration | ) |
Set motor acceleration.
This function tells the motor driver to use a specific acceleration while ramping up the velocity. input unit is in (microsteps/s^2)/116.42. See page 74 of datasheet for more information
[in] | acceleration | - see description for unit |
Definition at line 105 of file uStepperDriver.cpp.
void uStepperDriver::setCurrent | ( | uint8_t | current | ) |
Set motor driver current.
[in] | current | - sets the current to use during movements in percent (0-100) |
Definition at line 129 of file uStepperDriver.cpp.
void uStepperDriver::setDeceleration | ( | uint32_t | deceleration | ) |
Set motor deceleration.
This function tells the motor driver to use a specific deceleration while ramping down the velocity. input unit is in (microsteps/s^2)/116.42. See page 74 of datasheet for more information
[in] | deceleration | - see description for unit |
Definition at line 117 of file uStepperDriver.cpp.
void uStepperDriver::setHoldCurrent | ( | uint8_t | current | ) |
Set motor driver hold current.
[in] | current | - sets the current to use during standstill in percent (0-100) |
Definition at line 135 of file uStepperDriver.cpp.
void uStepperDriver::setPosition | ( | int32_t | position | ) |
Set the motor position.
This function tells the motor to go to an absolute position.
[in] | position | - position the motor should move to, in micro steps (1/256th default) |
Definition at line 146 of file uStepperDriver.cpp.
|
protected |
Set motor driver to position mode or velocity mode.
[in] | mode | - can be either POSITIONING_MODE or VELOCITY_MODE_POS |
Definition at line 177 of file uStepperDriver.cpp.
void uStepperDriver::setShaftDirection | ( | bool | direction | ) |
Set motor driver direction.
This function is used to set the direction of the motor driver to either normal or inverted. In normal mode, a positiv target position corresponds to a CW movement, while a negative target position corresponds to a CCW movement.
[in] | direction | - 0 = normal direction, 1 = inverted direction |
Definition at line 154 of file uStepperDriver.cpp.
void uStepperDriver::setVelocity | ( | uint32_t | velocity | ) |
Set motor velocity.
This function tells the motor driver to make the motor spin at a specific velocity. input unit is in ((microsteps/s)/8MHz)/2^23. See page 74 of datasheet for more information
[in] | velocity | - see description for unit |
Definition at line 93 of file uStepperDriver.cpp.
|
protected |
Writes the current setting registers of the motor driver.
Definition at line 141 of file uStepperDriver.cpp.
int32_t uStepperDriver::writeRegister | ( | uint8_t | address, |
uint32_t | datagram | ||
) |
Write a register of the motor driver.
This function is used to write a value into a register in the TMC5130 motor driver. Please refer to datasheet for details.
[in] | address | - Register to write |
[in] | datagram | - data to write into the register |
Definition at line 260 of file uStepperDriver.cpp.
|
protected |
STOP, VELOCITY, POSITION
Definition at line 300 of file uStepperDriver.h.
|
protected |
Status bits from the driver
Definition at line 297 of file uStepperDriver.h.
|
protected |
Default acceleration profile for positioning mode
Definition at line 309 of file uStepperDriver.h.
volatile int32_t uStepperDriver::xTarget = 0 |
target position in microsteps
Definition at line 292 of file uStepperDriver.h.