uStepper S
Classes | Macros
uStepperDriver.h File Reference

Function prototypes and definitions for the TMC5130 motor driver. More...

#include <Arduino.h>
#include <uStepperS.h>

Go to the source code of this file.

Classes

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

Macros

#define GCONF   0x00
 
#define DIRECTION(n)   (((n)&0x1)<<4)
 
#define EN_PWM_MODE(n)   (((n)&0x1)<<2)
 
#define I_SCALE_ANALOG(n)   (((n)&0x1)<<0)
 
#define GSTAT   0x01
 
#define X_COMPARE   0x05
 
#define IHOLD_IRUN   0x10
 
#define TPOWERDOWN   0x11
 
#define TPWMTHRS   0x13
 
#define TCOOLTHRS   0x14
 
#define THIGH   0x15
 
#define RAMPMODE   0x20
 
#define XACTUAL   0x21
 
#define VACTUAL   0x22
 
#define VSTART_REG   0x23
 
#define A1_REG   0x24
 
#define V1_REG   0x25
 
#define AMAX_REG   0x26
 
#define VMAX_REG   0x27
 
#define DMAX_REG   0x28
 
#define D1_REG   0x2A
 
#define VSTOP_REG   0x2B
 
#define TZEROWAIT   0x2C
 
#define XTARGET   0x2D
 
#define VDCMIN   0x33
 
#define SW_MODE   0x34
 
#define RAMP_STAT   0x35
 
#define XLATCH   0x36
 
#define PWMCONF   0x70
 
#define FREEWHEEL(n)   (((n)&0x3UL)<<20)
 
#define PWM_AUTOSCALE(n)   (((n)&0x1UL)<<18)
 
#define PWM_FREQ(n)   (((n)&0x3UL)<<16)
 
#define PWM_GRAD(n)   (((n)&0xFF)<<8)
 
#define PWM_AMPL(n)   (((n)&0xFF)<<0)
 
#define CHOPCONF   0x6C
 
#define DISS2G(n)   (((n)&0x1UL)<<30)
 
#define DEDGE(n)   (((n)&0x1UL)<<29)
 
#define INTPOL(n)   (((n)&0x1UL)<<28)
 
#define MRES(n)   (((n)&0xFUL)<<24)
 
#define SYNC(n)   (((n)&0xFUL)<<20)
 
#define VHIGHCHM(n)   (((n)&0x1UL)<<19)
 
#define VHIGHFS(n)   (((n)&0x1UL)<<18)
 
#define VSENSE(n)   (((n)&0x1UL)<<17)
 
#define TBL(n)   (((n)&0x3UL)<<15)
 
#define CHM(n)   (((n)&0x1UL)<<14)
 
#define RNDTF(n)   (((n)&0x1)<<13)
 
#define DISFDCC(n)   (((n)&0x1)<<12)
 
#define TFD3(n)   (((n)&0x1)<<11)
 
#define HEND(n)   (((n)&0xF)<<7)
 
#define HSTRT_TFD(n)   (((n)&0x7)<<4)
 
#define TOFF(n)   (((n)&0xF)<<0)
 
#define COOLCONF   0x6D
 
#define SFILT(n)   (((n)&0x1UL)<<24)
 
#define SGT(n)   (((n)&0x7FUL)<<16)
 
#define SEIMIN(n)   (((n)&0x1UL)<<15)
 
#define SEDN(n)   (((n)&0x3)<<13)
 
#define SEMAX(n)   (((n)&0xF)<<8)
 
#define SEUP(n)   (((n)&0x3)<<5)
 
#define SEMIN(n)   (((n)&0xF)<<0)
 
#define DCCTRL   0x6E
 
#define DC_SG(n)   (((n)&0xFFUL)<<16)
 
#define DC_TIME(n)   (((n)&0x3FF)<<0)
 
#define DRV_STATUS   0x6F
 
#define IHOLDDELAY(n)   (((n)&0xFUL)<<16)
 
#define IRUN(n)   (((n)&0x1F)<<8)
 
#define IHOLD(n)   (((n)&0x1F)<<0)
 
#define WRITE_ACCESS   0x80
 
#define POSITIONING_MODE   0x00
 
#define VELOCITY_MODE_POS   0x01
 
#define VELOCITY_MODE_NEG   0x02
 
#define HOLD_MODE   0x03
 
#define DRIVER_STOP   0
 
#define DRIVER_VELOCITY   1
 
#define DRIVER_POSITION   2
 
#define ACCELERATIONCONVERSION   1.0/116.415321827
 
#define VELOCITYCONVERSION   1.0/0.953674316
 

Detailed Description

Function prototypes and definitions for the TMC5130 motor driver.

        This file contains class and function prototypes for the TMC5130 motor driver,
        as well as necessary constants and global variables.
Author
Thomas Hørring Olsen (thoma.nosp@m.s@us.nosp@m.teppe.nosp@m.r.co.nosp@m.m)

Definition in file uStepperDriver.h.

Macro Definition Documentation

◆ A1_REG

#define A1_REG   0x24

First acceleration between VSTART and V1

Definition at line 56 of file uStepperDriver.h.

◆ ACCELERATIONCONVERSION

#define ACCELERATIONCONVERSION   1.0/116.415321827

page 74 datasheet

Definition at line 138 of file uStepperDriver.h.

◆ AMAX_REG

#define AMAX_REG   0x26

Second acceleration between V1 and VMAX

Definition at line 58 of file uStepperDriver.h.

◆ CHM

#define CHM (   n)    (((n)&0x1UL)<<14)

DESCRIPTION PENDING

Definition at line 93 of file uStepperDriver.h.

◆ CHOPCONF

#define CHOPCONF   0x6C

Chopper and driver configuration DESCRIPTION PENDING

Definition at line 82 of file uStepperDriver.h.

◆ COOLCONF

#define COOLCONF   0x6D

DESCRIPTION PENDING

Definition at line 104 of file uStepperDriver.h.

◆ D1_REG

#define D1_REG   0x2A

Deceleration between V1 and VSTOP

Definition at line 61 of file uStepperDriver.h.

◆ DC_SG

#define DC_SG (   n)    (((n)&0xFFUL)<<16)

DESCRIPTION PENDING

Definition at line 115 of file uStepperDriver.h.

◆ DC_TIME

#define DC_TIME (   n)    (((n)&0x3FF)<<0)

DESCRIPTION PENDING

Definition at line 116 of file uStepperDriver.h.

◆ DCCTRL

#define DCCTRL   0x6E

DESCRIPTION PENDING

Definition at line 114 of file uStepperDriver.h.

◆ DEDGE

#define DEDGE (   n)    (((n)&0x1UL)<<29)

DESCRIPTION PENDING

Definition at line 85 of file uStepperDriver.h.

◆ DIRECTION

#define DIRECTION (   n)    (((n)&0x1)<<4)

Set motor direction

Definition at line 39 of file uStepperDriver.h.

◆ DISFDCC

#define DISFDCC (   n)    (((n)&0x1)<<12)

DESCRIPTION PENDING

Definition at line 95 of file uStepperDriver.h.

◆ DISS2G

#define DISS2G (   n)    (((n)&0x1UL)<<30)

DESCRIPTION PENDING

Definition at line 84 of file uStepperDriver.h.

◆ DMAX_REG

#define DMAX_REG   0x28

Deceleration between VMAX and V1

Definition at line 60 of file uStepperDriver.h.

◆ DRIVER_POSITION

#define DRIVER_POSITION   2

DESCRIPTION PENDING

Definition at line 136 of file uStepperDriver.h.

◆ DRIVER_STOP

#define DRIVER_STOP   0

DESCRIPTION PENDING

Definition at line 134 of file uStepperDriver.h.

◆ DRIVER_VELOCITY

#define DRIVER_VELOCITY   1

DESCRIPTION PENDING

Definition at line 135 of file uStepperDriver.h.

◆ DRV_STATUS

#define DRV_STATUS   0x6F

stallGuard2 value and driver error flags

Definition at line 118 of file uStepperDriver.h.

◆ EN_PWM_MODE

#define EN_PWM_MODE (   n)    (((n)&0x1)<<2)

Enable stealthMode

Definition at line 40 of file uStepperDriver.h.

◆ FREEWHEEL

#define FREEWHEEL (   n)    (((n)&0x3UL)<<20)

DESCRIPTION PENDING

Definition at line 73 of file uStepperDriver.h.

◆ GCONF

#define GCONF   0x00

Global configuration flags

Definition at line 37 of file uStepperDriver.h.

◆ GSTAT

#define GSTAT   0x01

DESCRIPTION PENDING

Definition at line 43 of file uStepperDriver.h.

◆ HEND

#define HEND (   n)    (((n)&0xF)<<7)

DESCRIPTION PENDING

Definition at line 97 of file uStepperDriver.h.

◆ HOLD_MODE

#define HOLD_MODE   0x03

velocity remains unchanged, unless stop event occurs

Definition at line 132 of file uStepperDriver.h.

◆ HSTRT_TFD

#define HSTRT_TFD (   n)    (((n)&0x7)<<4)

DESCRIPTION PENDING

Definition at line 98 of file uStepperDriver.h.

◆ I_SCALE_ANALOG

#define I_SCALE_ANALOG (   n)    (((n)&0x1)<<0)

Use external current reference

Definition at line 41 of file uStepperDriver.h.

◆ IHOLD

#define IHOLD (   n)    (((n)&0x1F)<<0)

DESCRIPTION PENDING

Definition at line 122 of file uStepperDriver.h.

◆ IHOLD_IRUN

#define IHOLD_IRUN   0x10

Driver current control

Definition at line 45 of file uStepperDriver.h.

◆ IHOLDDELAY

#define IHOLDDELAY (   n)    (((n)&0xFUL)<<16)

DESCRIPTION PENDING

Definition at line 120 of file uStepperDriver.h.

◆ INTPOL

#define INTPOL (   n)    (((n)&0x1UL)<<28)

DESCRIPTION PENDING

Definition at line 86 of file uStepperDriver.h.

◆ IRUN

#define IRUN (   n)    (((n)&0x1F)<<8)

DESCRIPTION PENDING

Definition at line 121 of file uStepperDriver.h.

◆ MRES

#define MRES (   n)    (((n)&0xFUL)<<24)

DESCRIPTION PENDING

Definition at line 87 of file uStepperDriver.h.

◆ POSITIONING_MODE

#define POSITIONING_MODE   0x00

Modes for RAMPMODE register using all A, D and V parameters)

Definition at line 129 of file uStepperDriver.h.

◆ PWM_AMPL

#define PWM_AMPL (   n)    (((n)&0xFF)<<0)

DESCRIPTION PENDING

Definition at line 77 of file uStepperDriver.h.

◆ PWM_AUTOSCALE

#define PWM_AUTOSCALE (   n)    (((n)&0x1UL)<<18)

DESCRIPTION PENDING

Definition at line 74 of file uStepperDriver.h.

◆ PWM_FREQ

#define PWM_FREQ (   n)    (((n)&0x3UL)<<16)

DESCRIPTION PENDING

Definition at line 75 of file uStepperDriver.h.

◆ PWM_GRAD

#define PWM_GRAD (   n)    (((n)&0xFF)<<8)

DESCRIPTION PENDING

Definition at line 76 of file uStepperDriver.h.

◆ PWMCONF

#define PWMCONF   0x70

DESCRIPTION PENDING

Definition at line 71 of file uStepperDriver.h.

◆ RAMP_STAT

#define RAMP_STAT   0x35

Ramp status and switch event status

Definition at line 67 of file uStepperDriver.h.

◆ RAMPMODE

#define RAMPMODE   0x20

Driving mode (Velocity, Positioning, Hold)

Definition at line 50 of file uStepperDriver.h.

◆ RNDTF

#define RNDTF (   n)    (((n)&0x1)<<13)

DESCRIPTION PENDING

Definition at line 94 of file uStepperDriver.h.

◆ SEDN

#define SEDN (   n)    (((n)&0x3)<<13)

DESCRIPTION PENDING

Definition at line 108 of file uStepperDriver.h.

◆ SEIMIN

#define SEIMIN (   n)    (((n)&0x1UL)<<15)

DESCRIPTION PENDING

Definition at line 107 of file uStepperDriver.h.

◆ SEMAX

#define SEMAX (   n)    (((n)&0xF)<<8)

DESCRIPTION PENDING

Definition at line 109 of file uStepperDriver.h.

◆ SEMIN

#define SEMIN (   n)    (((n)&0xF)<<0)

DESCRIPTION PENDING

Definition at line 111 of file uStepperDriver.h.

◆ SEUP

#define SEUP (   n)    (((n)&0x3)<<5)

DESCRIPTION PENDING

Definition at line 110 of file uStepperDriver.h.

◆ SFILT

#define SFILT (   n)    (((n)&0x1UL)<<24)

DESCRIPTION PENDING

Definition at line 105 of file uStepperDriver.h.

◆ SGT

#define SGT (   n)    (((n)&0x7FUL)<<16)

DESCRIPTION PENDING

Definition at line 106 of file uStepperDriver.h.

◆ SW_MODE

#define SW_MODE   0x34

Switch mode configuration

Definition at line 66 of file uStepperDriver.h.

◆ SYNC

#define SYNC (   n)    (((n)&0xFUL)<<20)

DESCRIPTION PENDING

Definition at line 88 of file uStepperDriver.h.

◆ TBL

#define TBL (   n)    (((n)&0x3UL)<<15)

DESCRIPTION PENDING

Definition at line 92 of file uStepperDriver.h.

◆ TCOOLTHRS

#define TCOOLTHRS   0x14

This is the lower threshold velocity for switching on smart energy coolStep and stallGuard feature.

Definition at line 48 of file uStepperDriver.h.

◆ TFD3

#define TFD3 (   n)    (((n)&0x1)<<11)

DESCRIPTION PENDING

Definition at line 96 of file uStepperDriver.h.

◆ THIGH

#define THIGH   0x15

DESCRIPTION PENDING

Definition at line 49 of file uStepperDriver.h.

◆ TOFF

#define TOFF (   n)    (((n)&0xF)<<0)

DESCRIPTION PENDING

Definition at line 99 of file uStepperDriver.h.

◆ TPOWERDOWN

#define TPOWERDOWN   0x11

DESCRIPTION PENDING

Definition at line 46 of file uStepperDriver.h.

◆ TPWMTHRS

#define TPWMTHRS   0x13

DESCRIPTION PENDING

Definition at line 47 of file uStepperDriver.h.

◆ TZEROWAIT

#define TZEROWAIT   0x2C

Defines the waiting time after ramping down

Definition at line 63 of file uStepperDriver.h.

◆ V1_REG

#define V1_REG   0x25

First acceleration / deceleration phase target velocity

Definition at line 57 of file uStepperDriver.h.

◆ VACTUAL

#define VACTUAL   0x22

Actual motor velocity from ramp generator

Definition at line 52 of file uStepperDriver.h.

◆ VDCMIN

#define VDCMIN   0x33

DESCRIPTION PENDING

Definition at line 65 of file uStepperDriver.h.

◆ VELOCITY_MODE_NEG

#define VELOCITY_MODE_NEG   0x02

negativ VMAX, using AMAX acceleration

Definition at line 131 of file uStepperDriver.h.

◆ VELOCITY_MODE_POS

#define VELOCITY_MODE_POS   0x01

positiv VMAX, using AMAX acceleration

Definition at line 130 of file uStepperDriver.h.

◆ VELOCITYCONVERSION

#define VELOCITYCONVERSION   1.0/0.953674316

page 74 datasheet

Definition at line 139 of file uStepperDriver.h.

◆ VHIGHCHM

#define VHIGHCHM (   n)    (((n)&0x1UL)<<19)

DESCRIPTION PENDING

Definition at line 89 of file uStepperDriver.h.

◆ VHIGHFS

#define VHIGHFS (   n)    (((n)&0x1UL)<<18)

DESCRIPTION PENDING

Definition at line 90 of file uStepperDriver.h.

◆ VMAX_REG

#define VMAX_REG   0x27

This is the target velocity in velocity mode. It can be changed any time during a motion.

Definition at line 59 of file uStepperDriver.h.

◆ VSENSE

#define VSENSE (   n)    (((n)&0x1UL)<<17)

DESCRIPTION PENDING

Definition at line 91 of file uStepperDriver.h.

◆ VSTART_REG

#define VSTART_REG   0x23

Ramp curves Motor start velocity

Definition at line 55 of file uStepperDriver.h.

◆ VSTOP_REG

#define VSTOP_REG   0x2B

Motor stop velocity (unsigned)

Definition at line 62 of file uStepperDriver.h.

◆ WRITE_ACCESS

#define WRITE_ACCESS   0x80

Write access for spi communication

Definition at line 125 of file uStepperDriver.h.

◆ X_COMPARE

#define X_COMPARE   0x05

Position comparison register

Definition at line 44 of file uStepperDriver.h.

◆ XACTUAL

#define XACTUAL   0x21

Actual motor position

Definition at line 51 of file uStepperDriver.h.

◆ XLATCH

#define XLATCH   0x36

Latches XACTUAL upon a programmable switch event

Definition at line 68 of file uStepperDriver.h.

◆ XTARGET

#define XTARGET   0x2D

Target position for ramp mode

Definition at line 64 of file uStepperDriver.h.