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>

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
 
uStepperSpointer
 
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
 

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

Constructor & Destructor Documentation

◆ uStepperDriver()

uStepperDriver::uStepperDriver ( void  )

Constructor.

        This is the constructor of the uStepperDriver class.

Definition at line 36 of file uStepperDriver.cpp.

Member Function Documentation

◆ 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 225 of file uStepperDriver.cpp.

◆ 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 220 of file uStepperDriver.cpp.

◆ 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 62 of file uStepperDriver.cpp.

◆ 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 292 of file uStepperDriver.cpp.

◆ 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 105 of file uStepperDriver.cpp.

◆ 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 129 of file uStepperDriver.cpp.

◆ 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 117 of file uStepperDriver.cpp.

◆ 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 135 of file uStepperDriver.cpp.

◆ 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 146 of file uStepperDriver.cpp.

◆ 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 177 of file uStepperDriver.cpp.

◆ 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 154 of file uStepperDriver.cpp.

◆ 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 93 of file uStepperDriver.cpp.

◆ updateCurrent()

void uStepperDriver::updateCurrent ( void  )
protected

Writes the current setting registers of the motor driver.

Definition at line 141 of file uStepperDriver.cpp.

◆ 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.
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 260 of file uStepperDriver.cpp.

Member Data Documentation

◆ mode

uint8_t uStepperDriver::mode = DRIVER_STOP
protected

STOP, VELOCITY, POSITION

Definition at line 300 of file uStepperDriver.h.

◆ status

uint8_t uStepperDriver::status
protected

Status bits from the driver

Definition at line 297 of file uStepperDriver.h.

◆ VSTART

uint32_t uStepperDriver::VSTART = 0
protected

Default acceleration profile for positioning mode

Definition at line 309 of file uStepperDriver.h.

◆ xTarget

volatile int32_t uStepperDriver::xTarget = 0

target position in microsteps

Definition at line 292 of file uStepperDriver.h.


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