stepRocker servo Open Source TMCL  1.00
 All Data Structures Files Functions Variables Typedefs Enumerations Macros
Macros | Functions
TMC429.h File Reference

TMC429 library definitions. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MOTOR0   0
 
#define MOTOR1   0x20
 
#define MOTOR2   0x40
 
#define IDX_XTARGET   0x00
 
#define IDX_XACTUAL   0x02
 
#define IDX_VMIN   0x04
 
#define IDX_VMAX   0x06
 
#define IDX_VTARGET   0x08
 
#define IDX_VACTUAL   0x0A
 
#define IDX_AMAX   0x0C
 
#define IDX_AACTUAL   0x0E
 
#define IDX_AGTAT_ALEAT   0x10
 
#define IDX_PMUL_PDIV   0x12
 
#define IDX_REFCONF_RM   0x14
 
#define IDX_IMASK_IFLAGS   0x16
 
#define IDX_PULSEDIV_RAMPDIV   0x18
 
#define IDX_DX_REFTOLERANCE   0x1A
 
#define IDX_XLATCHED   0x1C
 
#define IDX_USTEP_COUNT_429   0x1E
 
#define IDX_LOW_WORD   0x60
 
#define IDX_HIGH_WORD   0x62
 
#define IDX_COVER_POS_LEN   0x64
 
#define IDX_COVER_DATA   0x66
 
#define IDX_IF_CONFIG_429   0x68
 
#define IDX_POS_COMP_429   0x6A
 
#define IDX_POS_COMP_INT_429   0x6C
 
#define IDX_TYPE_VERSION_429   0x72
 
#define IDX_REF_SWITCHES   0x7c
 
#define IDX_SMGP   0x7e
 
#define TMC429_READ   0x01
 
#define RM_RAMP   0
 
#define RM_SOFT   1
 
#define RM_VELOCITY   2
 
#define RM_HOLD   3
 
#define NO_REF   0x03
 
#define SOFT_REF   0x04
 
#define NO_LIMIT   0
 
#define HARD_LIMIT   1
 
#define SOFT_LIMIT   2
 
#define REFSW_LEFT   0x02
 
#define REFSW_RIGHT   0x01
 
#define M0_POS_REACHED   0x01
 
#define M1_POS_REACHED   0x04
 
#define M2_POS_REACHED   0x10
 
#define TMC429_STATUS_CDGW   0x40
 
#define TMC429_STATUS_INT   0x80
 
#define IFLAG_POS_REACHED   0x01
 
#define IFLAG_REF_WRONG   0x02
 
#define IFLAG_REF_MISS   0x04
 
#define IFLAG_STOP   0x08
 
#define IFLAG_STOP_LEFT_LOW   0x10
 
#define IFLAG_STOP_RIGHT_LOW   0x20
 
#define IFLAG_STOP_LEFT_HIGH   0x40
 
#define IFLAG_STOP_RIGHT_HIGH   0x80
 
#define IFCONF_INV_REF   0x0001
 
#define IFCONF_SDO_INT   0x0002
 
#define IFCONF_STEP_HALF   0x0004
 
#define IFCONF_INV_STEP   0x0008
 
#define IFCONF_INV_DIR   0x0010
 
#define IFCONF_EN_SD   0x0020
 
#define IFCONF_POS_COMP_0   0x0000
 
#define IFCONF_POS_COMP_1   0x0040
 
#define IFCONF_POS_COMP_2   0x0080
 
#define IFCONF_POS_COMP_OFF   0x00C0
 
#define IFCONF_EN_REFR   0x0100
 

Functions

void ReadWrite429 (UCHAR *Read, UCHAR *Write)
 32 bit SPI communication with TMC429 More...
 
void Write429Zero (UCHAR Address)
 Write zero to a TMC429 register. More...
 
void Write429Bytes (UCHAR Address, UCHAR *Bytes)
 TMC429 write access. More...
 
void Write429Datagram (UCHAR Address, UCHAR HighByte, UCHAR MidByte, UCHAR LowByte)
 TMC429 write access. More...
 
void Write429Short (UCHAR Address, int Value)
 Write 16 bit value to a TMC429 register. More...
 
void Write429Int (UCHAR Address, int Value)
 Write 24 bit value to a TMC429 register. More...
 
UCHAR Read429Status (void)
 Read TMC429 status byte. More...
 
UCHAR Read429Bytes (UCHAR Address, UCHAR *Bytes)
 Read TMC429 register. More...
 
UCHAR Read429SingleByte (UCHAR Address, UCHAR Index)
 Read TMC429 register. More...
 
int Read429Short (UCHAR Address)
 Read TMC429 register (12 bit) More...
 
int Read429Int (UCHAR Address)
 Read TMC429 register (24 bit) More...
 
void Set429RampMode (UCHAR Axis, UCHAR RampMode)
 Set the ramping mode of an axis. More...
 
void Set429SwitchMode (UCHAR Axis, UCHAR SwitchMode)
 Set the end switch mode. More...
 
UCHAR SetAMax (UCHAR Motor, UINT AMax)
 Set the maximum acceleration. More...
 
void HardStop (UINT Motor)
 Stop a motor immediately. More...
 
void Init429 (void)
 TMC429 initialization. More...
 

Detailed Description

TMC429 library definitions.

Author
Trinamic Motion Control GmbH & Co KG
Version
2.20

This file contains all macro and function definitions of the TMC429 library.

Function Documentation

void HardStop ( UINT  Motor)

Stop a motor immediately.

Parameters
Motormotor number (0, 1, 2)

This function stops a motor immediately (hard stop) by switching to velocity mode and then zeroing the V_TARGT and V_ACTUAL registers of that axis.

Here is the call graph for this function:

Here is the caller graph for this function:

void Init429 ( void  )

TMC429 initialization.

This function does all necessary initializations of the TMC429.

Here is the call graph for this function:

Here is the caller graph for this function:

UCHAR Read429Bytes ( UCHAR  Address,
UCHAR Bytes 
)

Read TMC429 register.

Parameters
AddressTMC429 register address (see TMC429.h)
BytesPointer at array of three bytes
Returns
TMC429 status byte

This functions reads a TMC429 register and puts the result into an array of bytes. It also returns the TMC429 status bytes.

Here is the call graph for this function:

Here is the caller graph for this function:

int Read429Int ( UCHAR  Address)

Read TMC429 register (24 bit)

Parameters
AddressTMC429 register address (see TMC429.h)
Returns
TMC429 register value (sign extended)

This functions reads a TMC429 24 bit register and sign-extends the register value to 32 bit.

Here is the call graph for this function:

Here is the caller graph for this function:

int Read429Short ( UCHAR  Address)

Read TMC429 register (12 bit)

Parameters
AddressTMC429 register address (see TMC429.h)
Returns
TMC429 register value (sign extended)

This functions reads a TMC429 12 bit register and sign-extends the register value to 32 bit.

Here is the call graph for this function:

Here is the caller graph for this function:

UCHAR Read429SingleByte ( UCHAR  Address,
UCHAR  Index 
)

Read TMC429 register.

Parameters
AddressTMC429 register address (see TMC429.h)
IndexTMC429 register byte to be returned (0..3)
Returns
TM429 register byte

This functions reads a TMC429 register and returns the desired byte of that register.

Here is the call graph for this function:

Here is the caller graph for this function:

UCHAR Read429Status ( void  )

Read TMC429 status byte.

Returns
TMC429 status byte

This functions reads just the status byte of the TMC429 using a single byte SPI access which makes this a little bit faster.

Here is the caller graph for this function:

void ReadWrite429 ( UCHAR Read,
UCHAR Write 
)

32 bit SPI communication with TMC429

Parameters
Readfour byte array holding the data read from the TMC428
Writefour byte array holding the data to write to the TMC428

This is the low-level function that does all SPI communication with the TMC429. It sends a 32 bit SPI telegramme to the TMC429 and receives the 32 bit answer telegramme from the TMC429. It also raises the motor current when there is write access to a register that could cause motor movement.

Here is the call graph for this function:

Here is the caller graph for this function:

void Set429RampMode ( UCHAR  Axis,
UCHAR  RampMode 
)

Set the ramping mode of an axis.

Parameters
AxisMotor number (0, 1 or 2)
RampModeramping mode (RM_RAMP/RM_SOFT/RM_VELOCITY/RM_HOLD)

This functions changes the ramping mode of a motor in the TMC429. It is some TMC429 register bit twiddling.

Here is the call graph for this function:

Here is the caller graph for this function:

void Set429SwitchMode ( UCHAR  Axis,
UCHAR  SwitchMode 
)

Set the end switch mode.

Parameters
AxisMotor number (0, 1 or 2)
SwitchModeend switch mode

This functions changes the end switch mode of a motor in the TMC429. It is some TMC429 register bit twiddling.

Here is the call graph for this function:

UCHAR SetAMax ( UCHAR  Motor,
UINT  AMax 
)

Set the maximum acceleration.

Parameters
Motormotor number (0, 1, 2)
AMaxmaximum acceleration (1..2047)

This function sets the maximum acceleration and also calculates the PMUL and PDIV value according to all other parameters (please see the TMC429 data sheet for more info about PMUL and PDIV values).

Here is the call graph for this function:

Here is the caller graph for this function:

void Write429Bytes ( UCHAR  Address,
UCHAR Bytes 
)

TMC429 write access.

Parameters
AddressTMC429 register address (see also TMC429.h)
BytesArray holding three bytes to be written to the TMC429 register.

This function writes an array of three bytes to a TMC429 register.

Here is the call graph for this function:

Here is the caller graph for this function:

void Write429Datagram ( UCHAR  Address,
UCHAR  HighByte,
UCHAR  MidByte,
UCHAR  LowByte 
)

TMC429 write access.

Parameters
AddressTMC429 register address
HighByteMSB of the TMC429 register
MidBytemid byte of the TMC429 register
LowByteLSB of the TMC429 register

This function write three bytes to a TMC429 register.

Here is the call graph for this function:

Here is the caller graph for this function:

void Write429Int ( UCHAR  Address,
int  Value 
)

Write 24 bit value to a TMC429 register.

Parameters
AddressTMC429 register address
ValueValue to be written

This function writes a 24 bit value to a TMC429 register.

Here is the call graph for this function:

Here is the caller graph for this function:

void Write429Short ( UCHAR  Address,
int  Value 
)

Write 16 bit value to a TMC429 register.

Parameters
AddressTMC429 register address
ValueValue to be written

This function writes a 16 bit value to a TMC429 register.

Here is the call graph for this function:

Here is the caller graph for this function:

void Write429Zero ( UCHAR  Address)

Write zero to a TMC429 register.

Parameters
AddressTMC429 register address

This function sets a TMC429 register to zero. This can be useful e.g. to stop a motor quickly.

Here is the call graph for this function:

Here is the caller graph for this function: