uStepper S
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
uStepperDriver Class Reference

Prototype of class for the TMC5130 Driver. More...

#include <uStepperDriver.h>

Collaboration diagram for uStepperDriver:
Collaboration graph

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. More...
 
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 (int32_t initialSteps=0)
 Resets the internal position counter of the motor driver. More...
 
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...
 
uint16_t getStallValue (void)
 Returns the load measurement used for Stall detection. More...
 

Public Attributes

volatile int32_t xTarget = 0
 
volatile int32_t xActual = 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 enableStallguard (int8_t threshold, bool stopOnStall)
 
void disableStallguard (void)
 
void clearStall (void)
 
void readMotorStatus (void)
 

Protected Attributes

uint8_t status
 
uint8_t mode = DRIVER_STOP
 
uStepperSpointer
 
uint8_t current = 16
 
uint8_t holdCurrent = 0
 
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 = 100
 
uint16_t DMAX = 600
 
uint16_t D1 = 600
 

Friends

class uStepperS
 

Detailed Description

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 149 of file uStepperDriver.h.

Constructor & Destructor Documentation

◆ uStepperDriver()

uStepperDriver::uStepperDriver ( void  )

Constructor.

        This is the constructor of the uStepperDriver class.

Definition at line 35 of file uStepperDriver.cpp.

Member Function Documentation

◆ chipSelect()

void uStepperDriver::chipSelect ( bool  state)
protected

Definition at line 344 of file uStepperDriver.cpp.

Here is the caller graph for this function:

◆ clearStall()

void uStepperDriver::clearStall ( void  )
protected

Definition at line 393 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableStallguard()

void uStepperDriver::disableStallguard ( void  )
protected

Definition at line 381 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableStallguard()

void uStepperDriver::enableStallguard ( int8_t  threshold,
bool  stopOnStall 
)
protected

Definition at line 352 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableStealth()

void uStepperDriver::enableStealth ( void  )
protected

Definition at line 220 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPosition()

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). 
Returns
microsteps (default 1/256th).

Definition at line 237 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getStallValue()

uint16_t uStepperDriver::getStallValue ( void  )

Returns the load measurement used for Stall detection.

Definition at line 399 of file uStepperDriver.cpp.

Here is the call graph for this function:

◆ getVelocity()

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 
Returns
see description for unit

Definition at line 232 of file uStepperDriver.cpp.

Here is the call graph for this function:

◆ init()

void uStepperDriver::init ( uStepperS _pointer)

Initiation of the motor driver.

        This function initiates all the registers of the motor driver.
Parameters
[in]_pointer- reference to the uStepper S object

Definition at line 68 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMotorStatus()

void uStepperDriver::readMotorStatus ( void  )
protected

Definition at line 99 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readRegister()

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.
Returns
Return data of the read register
Parameters
[in]address- Register to read

Definition at line 306 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void uStepperDriver::reset ( void  )
protected

Definition at line 39 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAcceleration()

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 
Parameters
[in]acceleration- see description for unit

Definition at line 117 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCurrent()

void uStepperDriver::setCurrent ( uint8_t  current)

Set motor driver current.

Parameters
[in]current- sets the current to use during movements in percent (0-100)

Definition at line 141 of file uStepperDriver.cpp.

Here is the call graph for this function:

◆ setDeceleration()

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 
Parameters
[in]deceleration- see description for unit

Definition at line 129 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDirection()

void uStepperDriver::setDirection ( bool  direction)
protected

Definition at line 179 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHoldCurrent()

void uStepperDriver::setHoldCurrent ( uint8_t  current)

Set motor driver hold current.

Parameters
[in]current- sets the current to use during standstill in percent (0-100)

Definition at line 147 of file uStepperDriver.cpp.

Here is the call graph for this function:

◆ setHome()

void uStepperDriver::setHome ( int32_t  initialSteps = 0)

Resets the internal position counter of the motor driver.

Parameters
[in]initialSteps- Home step offset from zero

Definition at line 248 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPosition()

void uStepperDriver::setPosition ( int32_t  position)

Set the motor position.

        This function tells the motor to go to an absolute position.
Parameters
[in]position- position the motor should move to, in micro steps (1/256th default)

Definition at line 158 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRampMode()

void uStepperDriver::setRampMode ( uint8_t  mode)
protected

Set motor driver to position mode or velocity mode.

Parameters
[in]mode- can be either POSITIONING_MODE or VELOCITY_MODE_POS

Definition at line 189 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShaftDirection()

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.
Parameters
[in]direction- 0 = normal direction, 1 = inverted direction

Definition at line 166 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVelocity()

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 
Parameters
[in]velocity- see description for unit

Definition at line 105 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void uStepperDriver::stop ( void  )

Stops any ongoing movement with deceleration.

Definition at line 242 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateCurrent()

void uStepperDriver::updateCurrent ( void  )
protected

Writes the current setting registers of the motor driver

Definition at line 153 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeRegister()

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.

        When using this function you are on your own and expect you know what you are doing !
Returns
Return data associated with last SPI command
Parameters
[in]address- Register to write
[in]datagram- data to write into the register

Definition at line 274 of file uStepperDriver.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ uStepperS

friend class uStepperS
friend

Definition at line 151 of file uStepperDriver.h.

Member Data Documentation

◆ A1

uint16_t uStepperDriver::A1 = 600
protected

Definition at line 327 of file uStepperDriver.h.

◆ AMAX

uint16_t uStepperDriver::AMAX = 100
protected

Definition at line 328 of file uStepperDriver.h.

◆ current

uint8_t uStepperDriver::current = 16
protected

Definition at line 318 of file uStepperDriver.h.

◆ D1

uint16_t uStepperDriver::D1 = 600
protected

Definition at line 330 of file uStepperDriver.h.

◆ DMAX

uint16_t uStepperDriver::DMAX = 600
protected

Definition at line 329 of file uStepperDriver.h.

◆ holdCurrent

uint8_t uStepperDriver::holdCurrent = 0
protected

Definition at line 319 of file uStepperDriver.h.

◆ holdDelay

uint8_t uStepperDriver::holdDelay = 0
protected

Definition at line 320 of file uStepperDriver.h.

◆ mode

uint8_t uStepperDriver::mode = DRIVER_STOP
protected

STOP, VELOCITY, POSITION

Definition at line 314 of file uStepperDriver.h.

◆ pointer

uStepperS* uStepperDriver::pointer
protected

Definition at line 316 of file uStepperDriver.h.

◆ status

uint8_t uStepperDriver::status
protected

Status bits from the driver

Definition at line 311 of file uStepperDriver.h.

◆ V1

uint32_t uStepperDriver::V1 = 0
protected

Definition at line 324 of file uStepperDriver.h.

◆ VMAX

uint32_t uStepperDriver::VMAX = 200000
protected

Definition at line 325 of file uStepperDriver.h.

◆ VSTART

uint32_t uStepperDriver::VSTART = 0
protected

Default acceleration profile for positioning mode

Definition at line 323 of file uStepperDriver.h.

◆ VSTOP

uint32_t uStepperDriver::VSTOP = 10
protected

Definition at line 326 of file uStepperDriver.h.

◆ xActual

volatile int32_t uStepperDriver::xActual = 0

current position in microsteps

Definition at line 306 of file uStepperDriver.h.

◆ xTarget

volatile int32_t uStepperDriver::xTarget = 0

target position in microsteps

Definition at line 303 of file uStepperDriver.h.


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