Trinamic TMCM-1021 TMCL, TMCM-1211 TMCL, TMCL TMCM-6212, TMCM-3351, TMCM-3314 User Manual

Module for Stepper Motors
928
V DC
ARM
Cortex
M
3
TM
microcontroller
TMCL™
Memory
4
add
.
I/Os
Step
Motor
RS
485
MOSFET
Stage
Energy Efficient
TMC
262
TMC
262
Pre
Driver
with
2
TM
coolStep™
sensOstep™
SPI
TMCM
S
/
SPI
I
2
C
MODULE
TMCM-1021 TMCL™Firmware Manual
Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
The TMCM-1021 is a single axis controller/driver module for 2-phase bipolar stepper motors. The TMCM-1021 TMCL rmware allows to control the module using TMCLcommands, supporting standalone operation as well as direct mode control, making use of the Trinamic TMC262 motor driver. Dynamic current control, and quiet, smooth and ecient operation are combined with stallGuardand coolStepfeatures.
Features
Single Axis Stepper motor control
Supply voltage 24V DC
TMCL
RS485 interface
Step/Direction input
Additional inputs and outputs
coolStep
stallGuard2
sensOstepencoder
Applications
Laboratory Automation
Manufacturing
Semiconductor Handling
Simplied Block Diagram
Robotics
Factory Automation
Test & Measurement
Life Science
Biotechnology
Liquid Handling
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at: www.trinamic.com
Read entire documentation.
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
2 / 109
Contents
1 Features 5
1.1 stallGuard2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 coolStep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 First Steps with TMCL 7
2.1 Basic Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Using the TMCL Direct Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Changing Axis Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Testing with a simple TMCL Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 TMCL and the TMCL-IDE An Introduction 10
3.1 Binary Command Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1 Checksum Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Reply Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.1 Status Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Standalone Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 The ASCII Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4.1 Entering and leaving the ASCII Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4.2 Format of the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4.3 Format of a Reply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4.4 Conguring the ASCII Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 TMCL Command Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.5.1 TMCL Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.6 TMCL Commands by Subject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.6.1 Motion Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.6.2 Parameter Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6.3 Branch Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6.4 I/O Port Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.6.5 Calculation Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.6.6 Interrupt Processing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.7 Detailed TMCL Command Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7.1 ROR (Rotate Right) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7.2 ROL (Rotate Left) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.7.3 MST (Motor Stop) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.7.4 MVP (Move to Position) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.7.5 SAP (Set Axis Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.7.6 GAP (Get Axis Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7.7 STAP (Store Axis Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.7.8 RSAP (Restore Axis Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.7.9 SGP (Set Global Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.7.10 GGP (Get Global Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.7.11 STGP (Store Global Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.7.12 RSGP (Restore Global Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.7.13 RFS (Reference Search) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.7.14 SIO (Set Output) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.7.15 GIO (Get Input) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.7.16 CALC (Calculate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.7.17 COMP (Compare) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.7.18 JC ( Jump conditional) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.7.19 JA ( Jump always) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.7.20 CSUB (Call Subroutine) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.7.21 RSUB (Return from Subroutine) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
3 / 109
3.7.22 WAIT (Wait for an Event to occur) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.7.23 STOP (Stop TMCL Program Execution – End of TMCL Program) . . . . . . . . . . . . . . 54
3.7.24 SCO (Set Coordinate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.7.25 GCO (Get Coordinate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.7.26 CCO (Capture Coordinate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.7.27 ACO (Accu to Coordinate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.7.28 CALCX (Calculate using the X Register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.7.29 AAP (Accu to Axis Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.7.30 AGP (Accu to Global Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.7.31 CLE (Clear Error Flags) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
3.7.32 EI (Enable Interrupt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.7.33 DI (Disable Interrupt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.7.34 VECT (Dene Interrupt Vector) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.7.35 RETI (Return from Interrupt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3.7.36 Customer specic Command Extensions (UF0. . . UF7 – User Functions) . . . . . . . . . 71
3.7.37 Request Target Position reached Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.7.38 TMCL Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4 Axis Parameters 76
5 Global Parameters 85
5.1 Bank 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.2 Bank 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.3 Bank 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.4 Bank 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6 Module Specic Hints 90
6.1 Conversion between PPS, RPM and RPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.2 The sensOstepEncoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6.2.1 Matching Encoder Resolution and Motor Resolution . . . . . . . . . . . . . . . . . . . . 91
6.2.2 Special Encoder Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7 Hints and Tips 92
7.1 Reference Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.1.1 Mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.2 Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.3 Mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1.4 Mode 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.1.5 Mode 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.1.6 Mode 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.1.7 Mode 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.1.8 Mode 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.2 stallGuard2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.3 coolStep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8 TMCL Programming Techniques and Structure 100
8.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.2 Main Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.3 Using Symbolic Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.4 Using Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.5 Using Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.6 Combining Direct Mode and Standalone Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.7 Make the TMCL Program start automatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
9 Figures Index 104
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
4 / 109
10 Tables Index 105
11 Supplemental Directives 106
11.1 Producer Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.2 Copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.3 Trademark Designations and Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.4 Target User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.5 Disclaimer: Life Support Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.6 Disclaimer: Intended Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
11.7 Collateral Documents & Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
12 Revision History 108
12.1 Firmware Revision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
12.2 Document Revision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
5 / 109

1 Features

The TMCM-1021 is a single axis controller/driver module for 2-phase bipolar stepper motors with state of the art feature set. It is highly integrated, oers a convenient handling and can be used in many decentralized applications. The module can be mounted on the back of NEMA 11 (28mm ange size) stepper motors and has been designed for coil currents of up to 0.7A RMS and 24V DC supply voltage. With its high energy eciency from Trinamics coolStep™technology cost for power consumption is kept down. The TMCL rmware allows for standalone operation and direct mode control.
Main characteristics
Motion controller & stepper motor driver:
On the y alteration of motion parameters (e.g. position, velocity, acceleration).
High performance microcontroller for overall system control and communication protocol handling.
Up to 256 microsteps per full step.
High-ecient operation, low power dissipation.
Dynamic current control.
Integrated protection.
stallGuard2feature for stall detection.
coolStepfeature for reduced power consumption and heat dissipation.
Encoder
sensOstepmagnetic encoder with 1024 increments per round.
Usable for example for step-loss detection under all operating conditions and positioning supervision.
Interfaces
RS485 bus.
Up to four general-purpose digital inputs (two shared with general purpose outputs).
Two general purpose outputs.
Step/Direction input (shared with the general purpose inputs).
Software
TMCL remote controlled operation via RS485 interface and/or stand-alone operation via TMCL program­ming. PC-based application development software TMCL-IDE available for free.
Electrical data
Supply voltage: +24V DC nominal (10. . . 27V DC supply range).
Motor current: up to 0.7A RMS / 1A peak (programmable). Since hardware V1.4 also 1.4A RMS / 2A peak programmable (new extended range since hardware V1.4).
Please see also the separate Hardware Manual.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Load [Nm]
stallGuard2
Initial stallGuard2 (SG) value: 100%
stallGuard2 (SG) value: 0 Maximum load reached. Motor close to stall.
Motor stalls
0
0,1
0,2
0,3
0,4
0,5
0,6
0,7
0,8
0,9
0 50 100 150 200 250 300 350
Velocity [RPM]
Efficiency with coolStep
Efficiency with 50% torque reserve
6 / 109

1.1 stallGuard2

stallGuard2 is a high-precision sensorless load measurement using the back EMF of the coils. It can be used for stall detection as well as other uses at loads below those which stall the motor. The stallGuard2 measurement value changes linearly over a wide range of load, velocity, and current settings. At maximum motor load, the value reaches zero or is near zero. This is the most energy-ecient point of operation for the motor.
Figure 1: stallGuard2 Load Measurement as a Function of Load

1.2 coolStep

coolStep is a load-adaptive automatic current scaling based on the load measurement via stallGuard2 adapting the required current to the load. Energy consumption can be reduced by as much as 75%. coolStep allows substantial energy savings, especially for motors which see varying loads or operate at a high duty cycle. Because a stepper motor application needs to work with a torque reserve of 30% to 50%, even a constant-load application allows signicant energy savings because coolStep automatically enables torque reserve when required. Reducing power consumption keeps the ystem cooler, increases motor life, and allows cost reduction.
Figure 2: Energy Eciency Example with coolStep
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
7 / 109

2 First Steps with TMCL

In this chapter you can nd some hints for your rst steps with the TMCM-1021 and TMCL. You may skip this chapter if you are already familiar with TMCL and the TMCL-IDE.
Things that you will need
Your TMCM-1021 module.
An RS485 interface connected to your PC.
A power supply (24V DC) for your TMCM-1021 module.
The TMCL-IDE 3.x already installed on your PC.
A two-phase bipolar stepper motor.

2.1 Basic Setup

First of all, you will need a PC with Windows (at least Windows 7) and the TMCL-IDE 3.x installed on it. If you do not have the TMCL-IDE installed on your PC then please download it from the TMCL-IDE product page of Trinamics website (http://www.trinamic.com) and install it on your PC.
Please also ensure that your TMCM-1021 is properly connected to your power supply and that the stepper motor is properly connected to the module. Please see the TMCM-1021 hardware manual for instructions on how to do this.
module is powered!
Then, please start up the TMCL-IDE. After that you can connect your TMCM-1021 via RS485 and switch on the power supply for the module (while the TMCL-IDE is running on your PC). When the module is connected properly via RS485 then it will be recognized by the TMCL-IDE so that it can be used.
Do not connect or disconnect a stepper motor to or from the module while the

2.2 Using the TMCL Direct Mode

At rst try to use some TMCL commands in direct mode. In the TMCL-IDE a tree view showing the TMCM­1021 and all tools available for it is displayed. Click on the Direct Mode entry of the tool tree. Now, the Direct Mode tool will pop up.
In the Direct Mode tool you can choose a TMCL command, enter the necessary parameters and execute the command. For example, choose the command ROL (rotate left). Then choose the appropriate motor (motor 0 if your motor is connected to the motor 0 connector). Now, enter the desired speed. Try entering 51200 (pps) as the value and then click the Execute button. The motor will now run. Choose the MST (motor stop) command and click Execute again to stop the motor.

2.3 Changing Axis Parameters

Next you can try changing some settings (also called axis parameters) using the SAP command in direct mode. Choose the SAP command. Then choose the parameter type and the motor number. Last, enter the desired value and click execute to execute the command which then changes the desired parameter. The following table points out the most important axis parameters. Please see chapter 4 for a complete list of all axis parameters.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Most important axis parameters
8 / 109
Number Axis Parameter Description Range
[Units]
4 Maximum
positioning speed
5 Maximum
acceleration
6 Maximum
current
The maximum speed used for positioning ramps.
Maximum acceleration in positioning ramps. Ac­celeration and deceleration value in velocity mode.
Motor current used when motor is running. The maximum value is 255 which means 100% of the
1. . . 2147483647 [pps]
1. . . 2147483647 [pps2]
0. . . 255 RW
maximum current of the module. The current can be adjusted in 32 steps:
0. . . 7 79. . . 87 160. . . 167 240. . . 247
8. . . 15 88. . . 95 168. . . 175 248. . . 255
16. . . 23 96. . . 103 176. . . 183
24. . . 31 104. . . 111 184. . . 191
32. . . 39 112. . . 119 192. . . 199
40. . . 47 120. . . 127 200. . . 207
48. . . 55 128. . . 135 208. . . 215
Access
RW
RW
56. . . 63 136. . . 143 216. . . 223
64. . . 71 144. . . 151 224. . . 231
72. . . 79 152. . . 159 232. . . 239
The most important setting, as too high values can cause motor damage.
7 Standby
current
The current used when the motor is not running. The maximum value is 255 which means 100% of
0. . . 255 RW
the maximum current of the module. This value should be as low as possible so that the motor can cool down when it is not moving. Please see also parameter 214.
Table 1: Most important Axis Parameters

2.4 Testing with a simple TMCL Program

Now, test the TMCL stand alone mode with a simple TMCL program. To type in, assemble and download the program, you will need the TMCL creator. This is also a tool that can be found in the tool tree of the TMCL-IDE. Click the TMCL creator entry to open the TMCL creator. In the TMCL creator, type in the following little TMCL program:
1
3
5
ROL 0, 51200 //Rotate motor 0 with speed 51200 pps (1rps) WAIT TICKS , 0, 500 MST 0 ROR 0, 5120 //Rotate motor 0 with 5120 pps (0.1 rps) WAIT TICKS , 0, 500
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
MST 0
7
SAP 4, 0, 51200 //Set max. Velocity
9
SAP 5, 0, 51200 //Set max. Acceleration
Loop:
11
MVP ABS , 0, 512000 //Move to Position 512000 WAIT POS , 0 , 0 //Wait until position reached
13
MVP ABS , 0, -512000 //Move to Position -512000 WAIT POS , 0 , 0 //Wait until position reached
15
JA Loop //Infinite Loop
After you have done that, take the following steps:
1.
Click the Assemble icon (or choose Assemble from the TMCL menu) in the TMCL creator to assemble the program.
2.
Click the Download icon (or choose Download from the TMCL menu) in the TMCL creator to donwload the program to the module.
3.
Click the Run icon (or choose Run from the TMCL menu) in the TMCL creator to run the program on the module.
Also try out the debugging functions in the TMCL creator:
9 / 109
1. Click on the Bug icon to start the debugger.
2. Click the Animate button to see the single steps of the program.
3. You can at any time pause the program, set or reset breakpoints and resume program execution.
4. To end the debug mode click the Bug icon again.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
10 / 109

3 TMCL and the TMCL-IDE An Introduction

As with most TRINAMIC modules the software running on the microprocessor of the TMCM-1021 consists of two parts, a boot loader and the rmware itself. Whereas the boot loader is installed during production and testing at TRINAMIC and remains untouched throughout the whole lifetime, the rmware can be updated by the user. New versions can be downloaded free of charge from the TRINAMIC website (http://www.trinamic.com). The TMCM-1021 supports TMCL direct mode (binary commands). It also implements standalone TMCL program execution. This makes it possible to write TMCL programs using the TMCL-IDE and store them in the memory of the module. In direct mode the TMCL communication over RS-232, RS-485, CAN and USB follows a strict master/slave relationship. That is, a host computer (e.g. PC/PLC) acting as the interface bus master will send a command to the TMCM-1021. The TMCL interpreter on the module will then interpret this command, do the initialization of the motion controller, read inputs and write outputs or whatever is necessary according to the specied command. As soon as this step has been done, the module will send a reply back over the interface to the bus master. Only then should the master transfer the next command. Normally, the module will just switch to transmission and occupy the bus for a reply, otherwise it will stay in receive mode. It will not send any data over the interface without receiving a command rst. This way, any collision on the bus will be avoided when there are more than two nodes connected to a single bus. The Trinamic Motion Control Language [TMCL] provides a set of structured motion control commands. Every motion control command can be given by a host computer or can be stored in an EEPROM on the TMCM module to form programs that run standalone on the module. For this purpose there are not only motion control commands but also commands to control the program structure (like conditional jumps, compare and calculating). Every command has a binary representation and a mnemonic. The binary format is used to send com­mands from the host to a module in direct mode, whereas the mnemonic format is used for easy usage of the commands when developing standalone TMCL applications using the TMCL-IDE (IDE means Integrated Development Environment). There is also a set of conguration variables for the axis and for global parameters which allow individual conguration of nearly every function of a module. This manual gives a detailed description of all TMCL commands and their usage.

3.1 Binary Command Format

Every command has a mnemonic and a binary representation. When commands are sent from a host to a module, the binary format has to be used. Every command consists of a one-byte command eld, a one-byte type eld, a one-byte motor/bank eld and a four-byte value eld. So the binary representation of a command always has seven bytes. When a command is to be sent via RS-232, RS-485, RS-422 or USB interface, it has to be enclosed by an address byte at the beginning and a checksum byte at the end. In these cases it consists of nine bytes.
The binary command format with RS-232, RS-485, RS-422 and USB is as follows:
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
TMCL Command Format
Bytes Meaning
1 Module address
1 Command number
1 Type number
1 Motor or Bank number
4 Value (MSB rst!)
1 Checksum
Table 2: TMCL Command Format
11 / 109
Info
The checksum is calculated by accumulating all the other bytes using an 8-bit
addition.
Note
When using the CAN interface, leave out the address byte and the checksum byte. With CAN, the CAN-ID is used as the module address and the checksum is not
needed because CAN bus uses hardware CRC checking.

3.1.1 Checksum Calculation

As mentioned above, the checksum is calculated by adding up all bytes (including the module address byte) using 8-bit addition. Here are two examples which show how to do this:
Checksum calculation in C:
1
unsigned char i , Checksum; unsigned char Command [9];
3
//Set the Command array to the desired command
5
Checksum = Command [0];
for(i=1; i<8; i++)
7
9
Checksum += Command [i ];
Command [8]= Checksum; // insert checksum as last byte of the command
//Now , send it to the module
Checksum calculation in Delphi:
var
2
i, Checksum : byte ;
Command: array [0..8] of byte ;
4
//Set the Command array to the desired command
6
//Calculate the Checksum :
8
Checksum := Command [0];
for i :=1 to 7 do Checksum := Checksum + Command [i ];
10
Command [8]:= Checksum; //Now , send the Command array (9 bytes) to the module
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09

3.2 Reply Format

Every time a command has been sent to a module, the module sends a reply. The reply format with RS-232, RS-485, RS-422 and USB is as follows:
TMCL Reply Format
Bytes Meaning
1 Reply address
1 Module address
1 Status (e.g. 100 means no error)
1 Command number
4 Value (MSB rst!)
1 Checksum
Table 3: TMCL Reply Format
12 / 109
Info
The checksum is also calculated by adding up all the other bytes using an 8-bit
addition. Do not send the next command before having received the reply!
Note
When using CAN interface, the reply does not contain an address byte and a
checksum byte. With CAN, the CAN-ID is used as the reply address and the checksum is not needed because the CAN bus uses hardware CRC checking.

3.2.1 Status Codes

The reply contains a status code. The status code can have one of the following values:
TMCL Status Codes
Code Meaning
100 Successfully executed, no error
101 Command loaded into TMCL program EEPROM
1 Wrong checksum
2 Invalid command
3 Wrong type
4 Invalid value
5 Conguration EEPROM locked
6 Command not available
Table 4: TMCL Status Codes
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
13 / 109

3.3 Standalone Applications

The module is equipped with a TMCL memory for storing TMCL applications. You can use the TMCL-IDE for developing standalone TMCL applications. You can download a program into the EEPROM and afterwards it will run on the module. The TMCL-IDE contains an editor and the TMCL assembler where the commands can be entered using their mnemonic format. They will be assembled automatically into their binary representations. Afterwards this code can be downloaded into the module to be executed there.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
14 / 109

3.4 The ASCII Interface

There is also an ASCII interface that can be used to communicate with the module and to send some direct mode commands as text strings. Only the following commands can be used in ASCII mode: ROL, ROR, MST, MVP, SAP, GAP, STAP, RSAP, SGP, GGP, STGP, RSGP, RFS, SIO, GIO, SCO, GCO, CCO, UF0, UF1, UF2, UF3, UF4, UF5, UF6, UF7.
Note
Note
Only direct mode commands can be entered in ASCII mode.
The TMCL-IDE does not support communicating with the module in ASCII mode.
So, in order to be able to use the TMCL-IDE with a module the module must be in binary mode. We normally recommend using the binary mode as this has some advantages over the ASCII mode. The ASCII mode is only provided here for compatibility. For new applications it is strongly recommended to use the binary mode.
There are also some special commands that are only available in ASCII mode:
BIN: This command quits ASCII mode and returns to binary mode.
RUN: This command can be used to start a TMCL program stored in memory.
STOP: Stops a TMCL program which is currently running on the module.

3.4.1 Entering and leaving the ASCII Mode

The ASCII command line interface is entered by sending the binary command 139 (enter ASCII mode).
Afterwards the commands can be entered in their mnemonic form (e.g. via a terminal program).
For leaving the ASCII mode and re-entering the binary mode enter the command BIN.

3.4.2 Format of the Command Line

As the rst character, the address character has to be sent. The address character is A when the module address is 1, B for modules with address 2 and so on. After the address character there may be spaces (but this is not necessary). Then, send the command with its parameters. At the end of a command line a
<CR> character has to be sent. Here are some examples for valid ASCII mode command lines (assuming
that the module address is 1):
AMVP ABS, 1, 50000
A MVP ABS, 1, 50000
AROL 2, 500
A MST 1
ABIN
The last command line shown above will make the module return to binary mode.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
15 / 109

3.4.3 Format of a Reply

After executing the command the module sends back a reply in ASCII format which consists of the following things:
The address character of the host (host address that can be set in the module) .
The address character of the module.
The status code as a decimal number.
The return value of the command as a decimal number.
A <CR> character.
So, after sending AGAP 0, 1 the reply would be BA 100 -5000 if the actual position of axis 1 is -5000, the host address is set to 2 and the module address is 1. The value 100 is the status code 100 which means that the command has been executed successfully.
3.4.4 Conguring the ASCII Interface
The module can be congured so that it starts up either in binary mode or in ASCII mode. Global parameter 67 is used for this purpose (please see also chapter 5).
Bit 0 determines the startup mode: if this bit is set, the module will start up in ASCII mode, else the module will start up in binary mode (default).
Bit 4 and bit 5 determine how the characters that are entered are echoed back. Normally, both bits are set to zero. In this case every character that is entered will be echoed back when the module is addressed. Characters can also be erased using the backspace character (press the backspace key in a terminal program).
When bit 4 is set and bit 5 is clear the characters that are entered are not echoed back immediately but the entire line will be echoed back after the <CR> character has been sent.
When bit 5 is set and bit 4 is clear there will be no echo, only the reply will be sent. This may be useful in RS485 systems.
Note
When trying the ASCII mode for the rst time it is strongly recommended not to
use global parameter 67 but the direct mode command 139 to enter the ASCII mode. Then the module can also be switched back to binary mode by a power cycle if there should be trouble with the ASCII mode communication.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09

3.5 TMCL Command Overview

This sections gives a short overview of all TMCL commands.

3.5.1 TMCL Commands

Overview of all TMCL Commands
Command Number Parameter Description
ROR 1 <motor number>, <velocity> Rotate right with specied velocity
ROL 2 <motor number>, <velocity> Rotate left with specied velocity
MST 3 <motor number> Stop motor movement
16 / 109
MVP 4
ABS|REL|COORD, <motor number>,
<position|oset>
SAP 5
<parameter>, <motor number>,
<value>
GAP 6 <parameter>, <motor number>
STAP 7
<parameter>, <motor number>,
<value>
RSAP 8 <parameter>, <motor number>
SGP 9
<parameter>, <bank number>,
<value>
GGP 10 <parameter>, <bank number>
STGP 11 <parameter>, <bank number>
RSGP 12 <parameter>, <bank number>
Move to position (absolute or relative)
Set axis parameter (motion control specic settings)
Get axis parameter (read out motion control specic settings)
Store axis parameter (store motion control specic settings)
Restore axis parameter (restore mo­tion control specic settings)
Set global parameter (module specic settings e.g. communication settings or TMCL user variables)
Get global parameter (read out mod­ule specic settings e.g. communica­tion settings or TMCL user variables)
Store global parameter (TMCL user variables only)
Restore global parameter (TMCL user variables only)
RFS 13
<START|STOP|STATUS>, <motor num-
Reference search
ber>
SIO 14
<port number>, <bank number>,
Set digital output to specied value
<value>
GIO 15 <port number>, <bank number> Get value of analog/digital input
CALC 19 <operation>, <value> Process accumulator and value
COMP 20 <value> Compare accumulator with value
JC 21 <condition>, <jump address> Jump conditional
JA 22 <jump address> Jump absolute
CSUB 23 <subroutine address> Call subroutine
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Command Number Parameter Description
RSUB 24 Return from subroutine
EI 25 <interrupt number> Enable interrupt
DI 26 <interrupt number> Disable interrupt
17 / 109
WAIT 27
<condition>, <motor number>,
Wait with further program execution
<ticks>
STOP 28 Stop program execution
SCO 30
<coordinate number>, <motor num-
Set coordinate
ber>, <position>
GCO 31
<coordinate number>, <motor num-
Get coordinate
ber>
CCO 32
<coordinate number>, <motor num-
Capture coordinate
ber>
CALCX 33 <operation> Process accumulator and X-register
AAP 34 <parameter>, <motor number> Accumulator to axis parameter
AGP 35 <parameter>, <bank number> Accumulator to global parameter
CLE 36 <ag> Clear an error ag
VECT 37 <interrupt number>, <address> Dene interrupt vector
RETI 38 Return from interrupt
ACO 39
<coordinate number>, <motor num-
Accu to coordinate
ber>
Table 5: Overview of all TMCL Commands

3.6 TMCL Commands by Subject

3.6.1 Motion Commands

These commands control the motion of the motor. They are the most important commands and can be used in direct mode or in standalone mode.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
18 / 109
Motion Commands
Mnemonic Command number Meaning
ROL 2 Rotate left
ROR 1 Rotate right
MVP 4 Move to position
MST 3 Motor stop
SCO 30 Store coordinate
CCO 32 Capture coordinate
GCO 31 Get coordinate
Table 6: Motion Commands

3.6.2 Parameter Commands

These commands are used to set, read and store axis parameters or global parameters. Axis parameters can be set independently for each axis, whereas global parameters control the behavior of the module itself. These commands can also be used in direct mode and in standalone mode.
Parameter Commands
Mnemonic Command number Meaning
SAP 5 Set axis parameter
GAP 6 Get axis parameter
STAP 7 Store axis parameter
RSAP 8 Restore axis parameter
SGP 9 Set global parameter
GGP 10 Get global parameter
STGP 11 Store global parameter
RSGP 12 Restore global parameter
Table 7: Parameter Commands

3.6.3 Branch Commands

These commands are used to control the program ow (loops, conditions, jumps etc.). Using them in direct mode does not make sense. They are intended for standalone mode only.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
19 / 109
Branch Commands
Mnemonic Command number Meaning
JA 22 Jump always
JC 21 Jump conditional
COMP 20 Compare accumulator with constant value
CSUB 23 Call subroutine
RSUB 24 Return from subroutine
WAIT 27 Wait for a specied event
STOP 28 End of a TMCL program
Table 8: Branch Commands

3.6.4 I/O Port Commands

These commands control the external I/O ports and can be used in direct mode as well as in standalone mode.
I/O Port Commands
Mnemonic Command number Meaning
SIO 14 Set output
GIO 15 Get input
Table 9: I/O Port Commands

3.6.5 Calculation Commands

These commands are intended to be used for calculations within TMCL applications. Although they could also be used in direct mode it does not make much sense to do so.
Calculation Commands
Mnemonic Command number Meaning
CALC 19 Calculate using the accumulator and a constant value
CALCX 33 Calculate using the accumulator and the X register
AAP 34 Copy accumulator to an axis parameter
AGP 35 Copy accumulator to a global parameter
ACO 39 Copy accu to coordinate
Table 10: Calculation Commands
For calculating purposes there is an accumulator (also called accu or A register) and an X register. When executed in a TMCL program (in standalone mode), all TMCL commands that read a value store the result
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
20 / 109
in the accumulator. The X register can be used as an additional memory when doing calculations. It can be loaded from the accumulator. When a command that reads a value is executed in direct mode the accumulator will not be aected. This means that while a TMCL program is running on the module (standalone mode), a host can still send commands like GAP and GGP to the module (e.g. to query the actual position of the motor) without aecting the ow of the TMCL program running on the module.

3.6.6 Interrupt Processing Commands

TMCL also contains functions for a simple way of interrupt processing. Using interrupts, many tasks can be programmed in an easier way. The following commands are use to dene and handle interrupts:
Interrupt Processing Commands
Mnemonic Command number Meaning
EI 25 Enable interrupt
DI 26 Disable interrupt
VECT 37 Set interrupt vector
RETI 38 Return from interrupt
Table 11: Interrupt Processing Commands
3.6.6.1 Interrupt Types
There are many dierent interrupts in TMCL, like timer interrupts, stop switch interrupts, position reached interrupts, and input pin change interrupts. Each of these interrupts has its own interrupt vector. Each interrupt vector is identied by its interrupt number. Please use the TMCL include le Interrupts.inc in order to have symbolic constants for the interrupt numbers. Table 12 show all interrupts that are available on the TMCM-1021.
Interrupt Vectors
Interrupt number Interrupt type
0 Timer 0
1 Timer 1
2 Timer 2
3 Target position reached 0
15 stallGuard axis 0
21 Deviation axis 0
27 Left stop switch 0
28 Right stop switch 0
39 Input change 0
40 Input change 1
41 Input change 2
42 Input change 3
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
21 / 109
Interrupt number Interrupt type
255 Global interrupts
Table 12: Interrupt Vectors
3.6.6.2 Interrupt Processing
When an interrupt occurs and this interrupt is enabled and a valid interrupt vector has been dened for that interrupt, the normal TMCL program ow will be interrupted and the interrupt handling routine will be called. Before an interrupt handling routine gets called, the context of the normal program (i.e. accumulator register, X register, ags) will be saved automatically. There is no interrupt nesting, i.e. all other interrupts are disabled while an interrupt handling routine is being executed. On return from an interrupt handling routine (RETI command), the context of the normal program will automatically be restored and the execution of the normal program will be continued.
3.6.6.3 Further Conguration of Interrupts
Some interrupts need further conguration (e.g. the timer interval of a timer interrupt). This can be done using SGP commands with parameter bank 3 (SGP <type> , 3, <value>). Please refer to the SGP command (chapter 3.7.9) for further information about that.
3.6.6.4 Using Interrupts in TMCL
To use an interrupt the following things have to be done:
Dene an interrupt handling routine using the VECT command.
If necessary, congure the interrupt using an SGP <type>, 3, <value> command.
Enable the interrupt using an EI <interrupt> command.
Globally enable interrupts using an EI 255 command.
An interrupt handling routine must always end with a RETI command.
Do not allow the normal program ow to run into an interrupt handling routine.
The following example shows the use of a timer interrupt:
1
VECT 0, Timer0Irq // define the interrupt vector SGP 0, 3, 1000 // configure the interrupt : set its period to 1000ms
3
EI 0 // enable this interrupt EI 255 // globally switch on interrupt processing
5
//Main program: toggles output 3, using a WAIT command for the delay
7
Loop:
SIO 3, 2, 1
9
WAIT TICKS , 0, 50 SIO 3, 2, 0
11
WAIT TICKS , 0, 50 JA Loop
13
//Here is the interrupt handling routine
15
Timer0Irq :
GIO 0, 2 //check if OUT0 is high
17
JC NZ , Out0Off // jump if not
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
22 / 109
SIO 0, 2, 1 //switch OUT0 high
19
RETI // end of interrupt
Out0Off:
21
SIO 0, 2, 0 //switch OUT0 low RETI // end of interrupt
In the example above, the interrupt numbers are being used directly. To make the program better readable use the provided include le Interrupts.inc. This le denes symbolic constants for all interrupt numbers which can be used in all interrupt commands. The beginning of the program above then looks as follows:
#include Interrupts . inc
2
VECT TI_TIMER0 , Timer0Irq SGP TI_TIMER0 , 3, 1000
4
EI TI_TIMER0 EI TI_GLOBAL
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
23 / 109

3.7 Detailed TMCL Command Descriptions

The module specic commands are explained in more detail on the following pages. They are listed according to their command number.

3.7.1 ROR (Rotate Right)

The motor is instructed to rotate with a specied velocity in right direction (increasing the position counter). The velocity is given in microsteps per second (pulse per second [pps]).
Internal function:
First, velocity mode is selected.
Then, the velocity value is transferred to axis parameter #2 (target velocity).
Related commands: ROL, MST, SAP, GAP.
Mnemonic: ROR <axis>, <velocity>
Binary Representation
Instruction Type Motor/Bank Value
1 0 0 -2147483648. . . 2147583647
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Rotate right motor 0, velocity 51200. Mnemonic: ROR 0, 51200.
Binary Form of ROR 0, 51200
Field Value
Target address 01
Instruction number 01
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) C8
Value (Byte 0) 00
Checksum CA
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
24 / 109

3.7.2 ROL (Rotate Left)

The motor is instructed to rotate with a specied velocity in left direction (decreasing the position counter). The velocity is given in microsteps per second (pulse per second [pps]).
Internal function:
First, velocity mode is selected.
Then, the velocity value is transferred to axis parameter #2 (target velocity).
Related commands: ROR, MST, SAP, GAP.
Mnemonic: ROL <axis>, <velocity>
Binary Representation
Instruction Type Motor/Bank Value
2 0 0 -2147483648. . . 2147583647
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Rotate left motor 0, velocity 51200. Mnemonic: ROL 0, 51200.
Binary Form of ROL 0, 51200
Field Value
Target address 01
Instruction number 02
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) C8
Value (Byte 0) 00
Checksum CB
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09

3.7.3 MST (Motor Stop)

The motor is instructed to stop with a soft stop.
25 / 109
Internal function:
The velocity mode is selected. Then, the target speed (axis parameter #0) is set to zero.
Related commands: ROR, ROL, SAP, GAP.
Mnemonic: MST <axis>
Binary Representation
Instruction Type Motor/Bank Value
3 0 0 0
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Stop motor 0. Mnemonic: MST 0.
Binary Form of MST 0
Field Value
Target address 01
Instruction number 03
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 04
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
26 / 109

3.7.4 MVP (Move to Position)

With this command the motor will be instructed to move to a specied relative or absolute position. It will use the acceleration/deceleration ramp and the positioning speed programmed into the unit. This command is non-blocking - that is, a reply will be sent immediately after command interpretation and initialization of the motion controller. Further commands may follow without waiting for the motor reaching its end position. The maximum velocity and acceleration as well as other ramp parameters are dened by the appropriate axis parameters. For a list of these parameters please refer to section 4. The range of the MVP command is 32 bit signed (-2147483648. . . 2147483647). Positioning can be inter­rupted using MST, ROL or ROR commands.
Three operation types are available:
Moving to an absolute position in the range from -2147483648. . . 2147483647 (231...231− 1).
Starting a relative movement by means of an oset to the actual position. In this case, the new resulting position value must not exceed the above mentioned limits, too.
Moving the motor to a (previously stored) coordinate (refer to SCO for details).
Note
The distance between the actual position and the new position must not be
more than 2147483647 (231−
1) microsteps. Otherwise the motor will run in the opposite direction in order to take the shorter distance (caused by 32 bit overow).
Internal function: A new position value is transferred to the axis parameter #0 (target position). Related commands: SAP, GAP, SCO, GCO, CCO, ACO, MST.
Mnemonic: MVP <ABS|REL|COORD>, <axis>, <position|oset|coordinate>
Binary Representation
Instruction Type Motor/Bank Value
0 – ABS – absolute 0 <position>
4
1 – REL – relative 0 <oset>
2 – COORD – coordinate 0. . . 255 <coordinate number (0..20)>
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Move motor 0 to position 90000. Mnemonic: MVP ABS, 0, 90000
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary Form of MVP ABS, 0, 90000
Field Value
27 / 109
Target address 01
Instruction number 04
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 01
Value (Byte 1) 5F
Value (Byte 0) 90
Checksum F5
h
h
h
h
h
h
h
h
h
Example
Move motor 0 from current position 10000 microsteps backward. Mnemonic: MVP REL, 0, -10000
Binary Form of MVP REL, 0, -10000
Field Value
Target address 01
Instruction number 04
Type 01
Motor/Bank 00
Value (Byte 3) FF
Value (Byte 2) FF
Value (Byte 1) D8
Value (Byte 0) F0
Checksum CC
h
h
h
h
h
h
h
h
h
Example
Move motor 0 to stored coordinate #8.
Mnemonic: MVP COORD, 0, 8
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary Form of MVP COORD, 0, 8
Field Value
28 / 109
Target address 01
Instruction number 04
Type 02
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 08
Checksum 0F
Note
h
h
h
h
h
h
h
h
h
Before moving to a stored coordinate, the coordinate has to be set using an SCO, CCO or ACO command.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
29 / 109

3.7.5 SAP (Set Axis Parameter)

With this command most of the motion control parameters of the module can be specied. The settings will be stored in SRAM and therefore are volatile. That is, information will be lost after power o.
Info
For a table with parameters and values which can be used together with this command please refer to section 4.
Internal function:
The specied value is written to the axis parameter specied by the parameter number.
Related commands: GAP, AAP.
Mnemonic: SAP <parameter number>, <axis>, <value>
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
5 see chapter 4 0 <value>
Reply in Direct Mode
Status Value
100 - OK dont care
Example Set the maximum positioning speed for motor 0 to 51200 pps. Mnemonic: SAP 4, 0, 51200.
Binary Form of SAP 4, 0, 51200
Field Value
Target address 01
Instruction number 05
Type 04
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) C8
Value (Byte 0) 00
Checksum D2
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
30 / 109

3.7.6 GAP (Get Axis Parameter)

Most motion / driver related parameters of the TMCM-1021 can be adjusted using e.g. the SAP command. With the GAP parameter they can be read out. In standalone mode the requested value is also transferred to the accumulator register for further processing purposes (such as conditional jumps). In direct mode the value read is only output in the value eld of the reply, without aecting the accumulator.
Info
For a table with parameters and values that can be used together with this command please refer to section 4.
Internal function: The specied value gets copied to the accumulator. Related commands: SAP, AAP.
Mnemonic: GAP <parameter number>, <axis>
Binary Representation
Instruction Type Motor/Bank Value
6 see chapter 4 0 <value>
Reply in Direct Mode
Status Value
100 - OK value read by this command
Example
Get the actual position of motor 0. Mnemonic: GAP 1, 0.
Binary Form of GAP 1, 0
Field Value
Target address 01
Instruction number 06
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 08
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
31 / 109

3.7.7 STAP (Store Axis Parameter)

This command is used to store TMCL axis parameters permanently in the EEPROM of the module. This command is mainly needed to store the default conguration of the module. The contents of the user variables can either be automatically or manually restored at power on.
Info
For a table with parameters and values which can be used together with this command please refer to dection 4.
Internal function:
The axis parameter specied by the type and bank number will be stored in the
EEPROM.
Related commands: SAP, AAP, GAP, RSAP.
Mnemonic: STAP <parameter number>, <bank>
Binary Representation
Instruction Type Motor/Bank Value
7 see chapter 4 0 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK 0 (dont care)
Example
Store axis parameter #6. Mnemonic: STAP 7, 6.
Binary Form of STAP 6, 12
Field Value
Target address 01
Instruction number 07
Type 06
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 0E
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
32 / 109

3.7.8 RSAP (Restore Axis Parameter)

With this command the contents of an axis parameter can be restored from the EEPROM. By default, all axis parameters are automatically restored after power up. An axis parameter that has been changed before can be reset to the stored value by this instruction.
Info
For a table with parameters and values which can be used together with this command please refer to section 4.
Internal function:
The axis parameter specied by the type and bank number will be restored from the
EEPROM.
Related commands: SAP, AAP, GAP, RSAP.
Mnemonic: RSAP <parameter number>, <bank>
Binary Representation
Instruction Type Motor/Bank Value
8 see chapter 4 0 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK 0 (dont care)
Example
Restore axis parameter #6. Mnemonic: RSAP 8, 6.
Binary Form of RSAP 8, 6
Field Value
Target address 01
Instruction number 08
Type 06
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 0A
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
33 / 109

3.7.9 SGP (Set Global Parameter)

With this command most of the module specic parameters not directly related to motion control can be specied and the TMCL user variables can be changed. Global parameters are related to the host interface, peripherals or application specic variables. The dierent groups of these parameters are organized in banks to allow a larger total number for future products. Currently, bank 0 is used for global parameters, and bank 2 is used for user variables. Bank 3 is used for interrupt conguration. All module settings in bank 0 will automatically be stored in non-volatile memory (EEPROM).
Info
For a table with parameters and values which can be used together with this command please refer to section 5.
Internal function:
The specied value will be copied to the global parameter specied by the type and
bank number. Most parameters of bank 0 will automatically be stored in non-volatile memory.
Related commands: GGP, AGP.
Mnemonic: SGP <parameter number>, <bank>, <value>
Binary Representation
Instruction Type Motor/Bank Value
9 see chapter 5 0/2/3 <value>
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Set the serial address of the device to 3. Mnemonic: SGP 66, 0, 3.
Binary Form of SGP 66, 0, 3
Field Value
Target address 01
Instruction number 09
Type 42
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 03
Checksum 4F
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
34 / 109

3.7.10 GGP (Get Global Parameter)

All global parameters can be read with this function. Global parameters are related to the host interface, peripherals or application specic variables. The dierent groups of these parameters are organized in banks to allow a larger total number for future products. Currently, bank 0 is used for global parameters, and bank 2 is used for user variables. Bank 3 is used for interrupt conguration.
Info
For a table with parameters and values which can be used together with this command please refer to section 5.
Internal function:
The global parameter specied by the type and bank number will be copied to the
accumulator register.
Related commands: SGP, AGP.
Mnemonic: GGP <parameter number>, <bank>
Binary Representation
Instruction Type Motor/Bank Value
10 see chapter 5 0/2/3 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK value read by this command
Example
Get the serial address of the device. Mnemonic: GGP 66, 0.
Binary Form of GGP 66, 0
Field Value
Target address 01
Instruction number 0A
Type 42
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 4D
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
35 / 109

3.7.11 STGP (Store Global Parameter)

This command is used to store TMCL global parameters permanently in the EEPROM of the module. This command is mainly needed to store the TMCL user variables (located in bank 2) in the EEPROM of the module, as most other global parameters (located in bank 0) are stored automatically when being modied. The contents of the user variables can either be automatically or manually restored at power on.
Info
For a table with parameters and values which can be used together with this command please refer to dection 5.3.
Internal function:
The global parameter specied by the type and bank number will be stored in the
EEPROM.
Related commands: SGP, AGP, GGP, RSGP.
Mnemonic: STGP <parameter number>, <bank>
Binary Representation
Instruction Type Motor/Bank Value
11 see chapter 5.3 2 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK 0 (dont care)
Example
Store user variable #42. Mnemonic: STGP 42, 2.
Binary Form of STGP 42, 2
Field Value
Target address 01
Instruction number 0B
Type 2A
Motor/Bank 02
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 38
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
36 / 109

3.7.12 RSGP (Restore Global Parameter)

With this command the contents of a TMCL user variable can be restored from the EEPROM. By default, all user variables are automatically restored after power up. A user variable that has been changed before can be reset to the stored value by this instruction.
Info
For a table with parameters and values which can be used together with this command please refer to section 5.3.
Internal function:
The global parameter specied by the type and bank number will be restored from
the EEPROM.
Related commands: SGP, AGP, GGP, STGP.
Mnemonic: RSGP <parameter number>, <bank>
Binary Representation
Instruction Type Motor/Bank Value
12 see chapter 5.3 2 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK 0 (dont care)
Example
Restore user variable #42. Mnemonic: RSGP 42, 2.
Binary Form of RSGP 42, 2
Field Value
Target address 01
Instruction number 0C
Type 2A
Motor/Bank 02
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 39
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
37 / 109

3.7.13 RFS (Reference Search)

The TMCM-1021 has a built-in reference search algorithm. The reference search algorithm provides dierent refrence search modes. This command starts or stops the built-in reference search algorithm. The status of the reference search can also be queried to see if it already has nished. (In a TMCL program it mostly is better to use the WAIT RFS command to wait for the end of a reference search.) Please see the appropriate parameters in the axis parameter table to congure the reference search algorithm to meet your needs (please see chapter 4).
Internal function:
The internal reference search state machine is started or stoped, or its state is queried.
Related commands: SAP, GAP, WAIT.
Mnemonic: RFS <START|STOP|STATUS>, <motor>
Binary Representation
Instruction Type Motor/Bank Value
0 START start reference search
13 1 STOP stop reference search 0 0 (dont care)
2 STATUS get status
Reply in Direct Mode (RFS START or RFS STOP)
Status Value
100 - OK 0 (dont care)
Reply in Direct Mode (RFS STATUS)
Status Value
0 no ref. search active
100 - OK
other values reference search active
Example
Start reference search of motor 0. Mnemonic: RFS START, 0.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary Form of RFS START
Field Value
38 / 109
Target address 01
Instruction number 0D
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 0E
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09

3.7.14 SIO (Set Output)

This command sets the states of the general purpose digital outputs.
39 / 109
Internal function:
The state of the output line specied by the type parameter is set according to the
value passed to this command.
Related commands: GIO.
Mnemonic: SIO <port number>, <bank number>, <value>
Binary Representation
Instruction Type Motor/Bank Value
14 <port number> <bank number> (2) 0/1
Reply in Direct Mode
Status Value
100 - OK 0 (dont care)
Example
Set output 0 (bank 2) to high. Mnemonic: SIO 0, 2, 1.
Binary Form of SIO 0, 2, 1
Field Value
Target address 01
Instruction number 0E
Type 00
Motor/Bank 02
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 01
Checksum 12
h
h
h
h
h
h
h
h
h
Bank 2 – Digital Outputs
The following output lines can be set by the SIO commands) using bank 2.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
40 / 109
Digital Outputs in Bank 2
Port Command Range
OUT0 SIO 0, 2, <value> 0/1
OUT1 SIO 1, 2, <value> 0/1
Special case: SIO 255, 2, <x> can be used to change all general purpose digital output lines simulaneously. The value <x> will then be interpreted as a bit vector where each of the lower eight bits represents one of the digital outputs. So the range for <x> is 0. . . 255. The value <x> can also be -1. In this case, the value will be taken from the accumulator register. The following program can be used to copy the states of the input lines to the output lines:
1
Loop:
GIO 255, 0
3
SIO 255, 2, -1 JA Loop
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
41 / 109

3.7.15 GIO (Get Input)

With this command the status of the available general purpose outputs of the module can be read. The function reads a digital or an analog input port. Digital lines will read as 0 or 1, while the ADC channels deliver their 12 bit result in the range of 0. . . 4095. In standalone mode the requested value is copied to the accumulator register for further processing purposes such as conditional jumps. In direct mode the value is only output in the value eld of the reply, without aecting the accumulator. The actual status of a digital output line can also be read.
Internal function:
The state of the i/o line specied by the type parameter and the bank parameter is read.
Related commands: SIO.
Mnemonic: GIO <port number>, <bank number>
Binary Representation
Instruction Type Motor/Bank Value
15 <port number> <bank number> (0/1/2) 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK status of the port
Example
Get the value of ADC channel 0. Mnemonic: GIO 0, 1.
Binary Form of GIO 0, 1
Field Value
Target address 01
Instruction number 0F
Type 00
Motor/Bank 01
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 11
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Reply (Status=no error, Value=302)
Field Value
42 / 109
Host address 02
Target address 01
Status 64
Instruction 0F
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 01
Value (Byte 0) 2E
Checksum A5
h
h
h
h
h
h
h
h
h
Bank 0 – Digital Inputs
The analog input lines can be read as digital or analog inputs at the same time. The digital input states can be accessed in bank 0.
Digital Inputs in Bank 0
Port Command Range
IN0 GIO 0, 0 0/1
IN1 GIO 1, 0 0/1
IN2 (same pin as OUT0) GIO 2, 0 0/1
IN3 (same pin as OUT1) GIO 3, 0 0/1
Special case: GIO 255, 0 reads all general purpose inputs simulataneously and puts the result into the lower eight bits of the accumulator register.
Special case: GIO 11, 0 checks if the sensOstepencoder is near its absolute zero position.
Bank 1 – Analog Inputs
The analog input lines can be read back as digital or analog inputs at the same time. The analog values can be accessed in bank 1.
Analog Inputs in Bank 1
Port Command Range / Units
IN3 GIO 0, 1 0. . . 4095
Temperature GIO 9, 1 [°C]
Bank 2 – States of the Digital Outputs
The states of the output lines (that have been set by SIO commands) can be read back using bank 2.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Digital Outputs in Bank 2
Port Command Range
OUT0 GIO 0, 2 0/1
OUT1 GIO 1, 2 0/1
43 / 109
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
44 / 109

3.7.16 CALC (Calculate)

A value in the accumulator variable, previously read by a function such as GAP (get axis parameter) can be modied with this instruction. Nine dierent arithmetic functions can be chosen and one constant operand value must be specied. The result is written back to the accumulator, for further processing like comparisons or data transfer. This command is mainly intended for use in standalone mode.
Related commands: CALCX, COMP, AAP, AGP, GAP, GGP, GIO.
Mnemonic: CALC <operation>, <operand>
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
19 0 ADD – add to accumulator 0 (dont care) <operand>
1 SUB – subtract from accumulator
2 MUL – multiply accumulator by
3 DIV – divide accumulator by
4 MOD – modulo divide accumulator by
5 AND – logical and accumulator with
6 OR – logical or accumulator with
7 XOR – logical exor accumulator with
8 NOT – logical invert accumulator
9 LOAD – load operand into accumulator
Reply in Direct Mode
Status Value
100 - OK the operand (dont care)
Example
Multiply accumulator by -5000. Mnemonic: CALC MUL, -5000
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary Form of CALC MUL, -5000
Field Value
45 / 109
Target address 01
Instruction number 13
Type 02
Motor/Bank 00
Value (Byte 3) FF
Value (Byte 2) FF
Value (Byte 1) EC
Value (Byte 0) 78
Checksum 78
h
h
h
h
h
h
h
h
h
Reply (Status=no error, value=-5000:
Field Value
Host address 02
Target address 01
Status 64
Instruction 13
Value (Byte 3) FF
Value (Byte 2) FF
Value (Byte 1) EC
Value (Byte 0) 78
Checksum DC
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
46 / 109

3.7.17 COMP (Compare)

The specied number is compared to the value in the accumulator register. The result of the comparison can for example be used by the conditional jump (JC) instruction. This command is intended for use in
standalone operation only.
Internal function:
The accumulator register is compared with the sepcied value. The internal arithmetic status ags are set according to the result of the comparison. These can then control e.g. a conditional jump.
Related commands: JC, GAP, GGP, GIO, CALC, CALCX.
Mnemonic: COMP <operand>
Binary Representation
Instruction Type Motor/Bank Value
20 0 (dont care) 0 (dont care) <operand>
Example
Jump to the address given by the label when the position of motor #0 is greater than or equal to 1000.
GAP 1, 0 // get actual position of motor 0
2
COMP 1000 //compare actual value with 1000 JC GE , Label // jump to Lable if greter or equal to 1000
Binary Form of COMP 1000
Field Value
Target address 01
Instruction number 14
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 03
Value (Byte 0) E8
Checksum 00
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
47 / 109

3.7.18 JC (Jump conditional)

The JC instruction enables a conditional jump to a xed address in the TMCL program memory, if the specied condition is met. The conditions refer to the result of a preceding comparison. Please refer to COMP instruction for examples. This command is intended for standalone operation only.
Internal function:
The TMCL program counter is set to the value passed to this command if the status ags are in the appropriate states.
Related commands: JA, COMP, WAIT, CLE.
Mnemonic: JC <condition>, <label>
Binary Representation
Instruction Type Motor/Bank Value
21 0 ZE - zero 0 (dont care) <jump address>
1 NZ - not zero
2 EQ - equal
3 NE - not equal
4 GT - greater
5 GE - greater/equal
6 LT - lower
7 LE - lower/equal
8 ETO - time out error
9 EAL - external alarm
10 EDV - deviation error
11 EPO - position error
Example
Jump to the address given by the label when the position of motor #0 is greater than or equal to 1000.
1
GAP 1, 0 // get actual position of motor 0 COMP 1000 //compare actual value with 1000
3
JC GE , Label // jump to Lable if greter or equal to 1000 ...
5
Label : ROL 0, 1000
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary form of JC GE, Label as­suming Label at address 10
Field Value
48 / 109
Target address 01
Instruction number 15
Type 05
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 0A
Checksum 25
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
49 / 109

3.7.19 JA (Jump always)

Jump to a xed address in the TMCL program memory. This command is intended for standalone operation only.
Internal function: The TMCL program counter is set to the value passed to this command.
Related commands: JC, WAIT, CSUB.
Mnemonic: JA <label>
Binary Representation
Instruction Type Motor/Bank Value
22 0 (dont care) 0 (dont care) <jump address>
Example
An innite loop in TMCL:
1
Loop:
MVP ABS , 0, 51200
3
WAIT POS , 0 , 0 MVP ABS , 0, 0
5
WAIT POS , 0 , 0 JA Loop
Binary form of the JA Loop command when the label Loop is at address 10:
Binary Form of JA Loop (assum­ing Loop at address 10)
Field Value
Target address 01
Instruction number 16
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 0A
Checksum 21
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
50 / 109

3.7.20 CSUB (Call Subroutine)

This function calls a subroutine in the TMCL program memory. It is intended for standalone operation only.
Internal function:
the actual TMCL program counter value is saved to an internal stack, afterwards overwritten with the passed value. The number of entries in the internal stack is limited to 8. This also limits nesting of subroutine calls to 8. The command will be ignored if there is no more stack space left.
Related commands: RSUB, JA.
Mnemonic: CSUB <label>
Binary Representation
Instruction Type Motor/Bank Value
23 0 (dont care) 0 (dont care) <subroutine address>
Example
Call a subroutine:
Loop:
2
MVP ABS , 0, 10000 CSUB SubW //Save program counter and jump to label SubW
4
MVP ABS , 0, 0 CSUB SubW //Save program counter and jump to label SubW
6
8
JA Loop
SubW:
WAIT POS , 0 , 0
10
WAIT TICKS , 0, 50 RSUB //Continue with the command following the CSUB command
Binary form of CSUB SubW (assuming SubW at address
100)
Field Value
Target address 01
Instruction number 17
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 64
Checksum 7C
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
51 / 109

3.7.21 RSUB (Return from Subroutine)

Return from a subroutine to the command after the CSUB command. This command is intended for use in standalone mode only.
Internal function:
the TMCL program counter is set to the last value saved on the stack. The command
will be ignored if the stack is empty.
Related commands: CSUB.
Mnemonic: RSUB
Binary Representation
Instruction Type Motor/Bank Value
24 0 (dont care) 0 (dont care) 0 (dont care)
Example
Please see the CSUB example (section 3.7.20).
Binary form:
Binary Form of RSUB
Field Value
Target address 01
Instruction number 18
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 19
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
52 / 109

3.7.22 WAIT (Wait for an Event to occur)

This instruction interrupts the execution of the TMCL program until the specied condition is met. This command is intended for standalone operation only.
There are ve dierent wait conditions that can be used:
TICKS: Wait until the number of timer ticks specied by the <ticks> parameter has been reached.
POS: Wait until the target position of the motor specied by the <motor> parameter has been reached. An optional timeout value (0 for no timeout) must be specied by the <ticks> parameter.
REFSW: Wait until the reference switch of the motor specied by the <motor> parameter has been triggered. An optional timeout value (0 for no timeout) must be specied by the <ticks> parameter.
LIMSW: Wait until a limit switch of the motor specied by the <motor> parameter has been triggered. An optional timeout value (0 for no timeout) must be specied by the <ticks> parameter.
RFS: Wait until the reference search of the motor specied by the <motor> eld has been reached. An optional timeout value (0 for no timeout) must be specied by the <ticks> parameter.
Special case for the <ticks> parameter: When this parameter is set to -1 the contents of the accumulator register will be taken for this value. So for example WAIT TICKS, 0, -1 will wait as long as specied by the value store in the accumulator. The accumulator must not contain a negative value when using this option.
The timeout ag (ETO) will be set after a timeout limit has been reached. You can then use a JC ETO command to check for such errors or clear the error using the CLE command.
Internal function:
the TMCL program counter will be held at the address of this WAIT command until the
condition is met or the timeout has expired.
Related commands: JC, CLE.
Mnemonic: WAIT <condition>, <motor number>, <ticks>
Binary Representation
Instruction Type Motor/Bank Value
0 TICKS – timer ticks 0 (dont care) <no. of ticks to wait1>
1 POS – target position reached <motor number> <no. of ticks for timeout1>
0 for no timeout
2 REFSW – reference switch <motor number> <no. of ticks for timeout1>
27 0 for no timeout
3 LIMSW – limit switch <motor number> <no. of ticks for timeout1>
0 for no timeout
4 RFS – reference search completed <motor number> <no. of ticks for timeout1>
Example
1
one tick is 10 milliseconds
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
0 for no timeout
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Wait for motor 0 to reach its target position, without timeout. Mnemonic: WAIT POS, 0, 0
Binary Form of WAIT POS, 0, 0
Field Value
53 / 109
Target address 01
Instruction number 1B
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 1D
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
54 / 109

3.7.23 STOP (Stop TMCL Program Execution – End of TMCL Program)

This command stops the execution of a TMCL program. It is intended for use in standalone operation only.
Internal function: Execution of a TMCL program in standalone mode will be stopped.
Related commands: none.
Mnemonic: STOP
Binary Representation
Instruction Type Motor/Bank Value
28 0 (dont care) 0 (dont care) 0 (dont care)
Example
Mnemonic: STOP
Binary Form of STOP
Field Value
Target address 01
Instruction number 1C
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 1D
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
55 / 109

3.7.24 SCO (Set Coordinate)

Up to 20 position values (coordinates) can be stored for every axis for use with the MVP COORD command. This command sets a coordinate to a specied value. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only).
Note
Coordinate #0 is always stored in RAM only.
Internal function: the passed value is stored in the internal position array.
Related commands: GCO, CCO, ACO, MVP COORD.
Mnemonic: SCO <coordinate number>, <motor number>, <position>
Binary Representation
Instruction Type Motor/Bank Value
30 <coordinate number> <motor number> <position>
0. . . 20 0 231. . . 231− 1
Example
Set coordinate #1 of motor #0 to 1000. Mnemonic: SCO 1, 0, 1000
Binary Form of SCO 1, 0, 1000
Field Value
Target address 01
Instruction number 1E
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 03
Value (Byte 0) E8
Checksum 0B
h
h
h
h
h
h
h
h
h
Two special functions of this command have been introduced that make it possible to copy all coordinates or one selected coordinate to the EEPROM. These functions can be accessed using the following special forms of the SCO command:
SCO 0, 255, 0 copies all coordinates (except coordinate number 0) from RAM to the EEPROM.
SCO <coordinate number>, 255, 0 copies the coordinate selected by <coordinate number> to the EEPROM. The coordinate number must be a value between 1 and 20.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
56 / 109

3.7.25 GCO (Get Coordinate)

Using this command previously stored coordinate can be read back. In standalone mode the requested value is copied to the accumulator register for further processing purposes such as conditional jumps. In direct mode, the value is only output in the value eld of the reply, without aecting the accumulator. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only).
Note
Internal function:
Coordinate #0 is always stored in RAM only.
the desired value is read out of the internal coordinate array, copied to the accumulator
register and – in direct mode – returned in the value eld of the reply.
Related commands: SCO, CCO, ACO, MVP COORD.
Mnemonic: GCO <coordinate number>, <motor number>
Binary Representation
Instruction Type Motor/Bank Value
31 <coordinate number> <motor number> 0 (dont care)
0. . . 20 0
Reply in Direct Mode
Status Value
100 - OK value read by this command
Example
Get coordinate #1 of motor #0. Mnemonic: GCO 1, 0
Binary Form of GCO 1, 0
Field Value
Target address 01
Instruction number 1F
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 21
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
57 / 109
Two special functions of this command have been introduced that make it possible to copy all coordinates or one selected coordinate from the EEPROM to the RAM. These functions can be accessed using the following special forms of the GCO command:
GCO 0, 255, 0 copies all coordinates (except coordinate number 0) from the EEPROM to the RAM.
GCO <coordinate number>, 255, 0 copies the coordinate selected by <coordinate number> from the EEPROM to the RAM. The coordinate number must be a value between 1 and 20.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
58 / 109

3.7.26 CCO (Capture Coordinate)

This command copies the actual position of the axis to the selected coordinate variable. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only). Please see the SCO and GCO commands on how to copy coordinates between RAM and EEPROM.
Note
Internal function:
Coordinate #0 is always stored in RAM only.
the actual position of the selected motor is copied to selected coordinate array entry.
Related commands: SCO, GCO, ACO, MVP COORD.
Mnemonic: CCO <coordinate number>, <motor number>
Binary Representation
Instruction Type Motor/Bank Value
32 <coordinate number> <motor number> 0 (dont care)
0. . . 20 0
Reply in Direct Mode
Status Value
100 - OK value read by this command
Example
Store current position of motor #0 to coordinate array entry #3.
Mnemonic: CCO 3, 0
Binary Form of CCO 3, 0
Field Value
Target address 01
Instruction number 20
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 22
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
59 / 109

3.7.27 ACO (Accu to Coordinate)

With the ACO command the actual value of the accumulator is copied to a selected coordinate of the motor. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only).
Note
Internal function:
Coordinate #0 is always stored in RAM only.
the actual position of the selected motor is copied to selected coordinate array entry.
Related commands: SCO, GCO, CO, MVP COORD.
Mnemonic: ACO <coordinate number>, <motor number>
Binary Representation
Instruction Type Motor/Bank Value
39 <coordinate number> <motor number> 0 (dont care)
0. . . 20 0
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Copy the actual value of the accumulator to coordinate #1 of motor #0.
Mnemonic: ACO 1, 0
Binary Form of ACO 1, 0
Field Value
Target address 01
Instruction number 27
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 29
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
60 / 109

3.7.28 CALCX (Calculate using the X Register)

This instruction is very similar to CALC, but the second operand comes from the X register. The X register can be loaded with the LOAD or the SWAP type of this instruction. The result is written back to the accumulator for further processing like comparisons or data transfer. This command is mainly intended for
use in standalone mode.
Related commands: CALC, COMP, JC, AAP, AGP, GAP, GGP, GIO.
Mnemonic: CALCX <operation>
Binary Representation
Instruction Type Motor/Bank Value
33 0 ADD – add X register to accumulator 0 (dont care) 0 (dont care)
1 SUB – subtract X register from accumulator
2 MUL – multiply accumulator by X register
3 DIV – divide accumulator by X register
4 MOD – modulo divide accumulator by X register
5 AND – logical and accumulator with X register
6 OR – logical or accumulator with X register
7 XOR – logical exor accumulator with X register
8 NOT – logical invert X register
9 LOAD – copy accumulator to X register
10 SWAP – swap accumulator and X register
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Multiply accumulator and X register. Mnemonic: CALCX MUL
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary Form of CALCX MUL
Field Value
61 / 109
Target address 01
Instruction number 21
Type 02
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 24
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
62 / 109

3.7.29 AAP (Accu to Axis Parameter)

The content of the accumulator register is transferred to the specied axis parameter. For practical usage, the accumulator has to be loaded e.g. by a preceding GAP instruction. The accumulator may have been modied by the CALC or CALCX (calculate) instruction. This command is mainly intended for use in standalone
mode.
Info
For a table with parameters and values which can be used together with this command please refer to section 4.
Related commands: AGP, SAP, GAP, SGP, GGP, GIO, GCO, CALC, CALCX.
Mnemonic: AAP <parameter number>, <motor number>
Binary Representation
Instruction Type Motor/Bank Value
34 see chapter 4 0 <value>
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Position motor #0 by a potentiometer connected to analog input #0:
1
Start :
GIO 0 ,1 // get value of analog input line 0
3
CALC MUL , 4 // multiply by 4 AAP 0 ,0 // transfer result to target position of motor 0
5
JA Start // jump back to start
Binary Form of AAP 0, 0
Field Value
Target address 01
Instruction number 22
Type 00
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 23
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
63 / 109

3.7.30 AGP (Accu to Global Parameter)

The content of the accumulator register is transferred to the specied global parameter. For practical usage, the accumulator has to be loaded e.g. by a preceding GAP instruction. The accumulator may have been modied by the CALC or CALCX (calculate) instruction. This command is mainly intended for use in
standalone mode.
Info
For an overview of parameter and bank indices that can be used with this com­mand please see section 5.
Related commands: AAP, SGP, GGP, SAP, GAP, GIO.
Mnemonic: AGP <parameter number>, <bank number>
Binary Representation
Instruction Type Motor/Bank Value
35 <parameter number> 0/2/3 <bank number> 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Copy accumulator to user variable #42: Mnemonic: AGP 42, 2
Binary Form of AGP 42, 2
Field Value
Target address 01
Instruction number 23
Type 2A
Motor/Bank 02
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 50
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09

3.7.31 CLE (Clear Error Flags)

This command clears the internal error ags. It is mainly intended for use in standalone mode. The following error ags can be cleared by this command (determined by the <ag> parameter):
ALL: clear all error ags.
ETO: clear the timeout ag.
EAL: clear the external alarm ag.
EDV: clear the deviation ag.
EPO: clear the position error ag.
Related commands: JC, WAIT.
Mnemonic: CLE <ags>
Binary Representation
Instruction Type Motor/Bank Value
36 0 ALL – all ags 0 (dont care) 0 (dont care)
64 / 109
1 – (ETO) timeout ag
2 – (EAL) alarm ag
3 – (EDV) deviation ag
4 – (EPO) position ag
5 – (ESD) shutdown ag
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Reset the timeout ag. Mnemonic: CLE ETO
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary Form of CLE ETO
Field Value
65 / 109
Target address 01
Instruction number 24
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 26
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
66 / 109

3.7.32 EI (Enable Interrupt)

The EI command enables an interrupt. It needs the interrupt number as parameter. Interrupt number 255 globally enables interrupt processing. This command is mainly intended for use in standalone mode.
Info
Please see table 12 for a list of interrupts that can be used on the TMCM-1021 module.
Related commands: DI, VECT, RETI.
Mnemonic: EI <interrupt number>
Binary Representation
Instruction Type Motor/Bank Value
25 <interrupt number> 0 (dont care) 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Globally enable interrupt processing: Mnemonic: EI 255
Binary form of EI 255
Field Value
Target address 01
Instruction number 19
Type FF
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 19
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
67 / 109

3.7.33 DI (Disable Interrupt)

The DI command disables an interrupt. It needs the interrupt number as parameter. Interrupt number 255 globally disables interrupt processing. This command is mainly intended for use in standalone mode.
Info
Please see table 12 for a list of interrupts that can be used on the TMCM-1021 module.
Related commands: EI, VECT, RETI.
Mnemonic: DI <interrupt number>
Binary Representation
Instruction Type Motor/Bank Value
26 <interrupt number> 0 (dont care) 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Globally disable interrupt processing: Mnemonic: DI 255
Binary Form of DI 255
Field Value
Target address 01
Instruction number 1A
Type FF
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 1A
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
68 / 109
3.7.34 VECT (Dene Interrupt Vector)
The VECT command denes an interrupt vector. It takes an interrupt number and a label (just like with JA, JC and CSUB commands) as parameters. The label must be the entry point of the interrupt handling routine for this interrupts. Interrupt vectors can also be re-dened. This command is intended for use in
standalone mode only.
Info
Please see table 12 for a list of interrupts that can be used on the TMCM-1021 module.
Related commands: EI, DI, RETI.
Mnemonic: VECT <interrupt number>, <label>
Binary Representation
Instruction Type Motor/Bank Value
37 <interrupt number> 0 (dont care) <label>
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Dene interrupt vector for timer #0 interrupt:
1
VECT 0, Timer0Irq ...
3
Loop:
...
5
JA Loop ...
7
Timer0Irq :
SIO 0, 2, 1
9
RETI
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Binary form of VECT (assuming label is at 50)
Field Value
69 / 109
Target address 01
Instruction number 25
Type FF
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 32
Checksum 58
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
70 / 109

3.7.35 RETI (Return from Interrupt)

This command terminates an interrupt handling routine. Normal program ow will be continued then.
This command is intended for use in standalone mode only.
An interrupt routine must always end with a RETI command. Do not allow the normal program ow to run into an interrupt routine.
Internal function:
The saved registers (accumulator, X registers, ags and program counter) are copied
back so that normal program ow will continue.
Related commands: EI, DI, VECT.
Mnemonic: RETI
Binary Representation
Instruction Type Motor/Bank Value
38 <interrupt number> 0 (dont care) 0 (dont care)
Reply in Direct Mode
Status Value
100 - OK dont care
Example
Return from an interrup handling routine. Mnemonic: RETI
Binary Form of RETI
Field Value
Target address 01
Instruction number 26
Type FF
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 00
Checksum 27
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
h
h
h
h
h
h
h
h
h
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
71 / 109
3.7.36 Customer specic Command Extensions (UF0. . . UF7 – User Functions)
These commands are used for customer specic extensions of TMCL. They will be implemented in C by Trinamic. Please contact the sales department of Trinamic Motion Control GmbH & Co KG if you need a customized TMCL rmware.
Related commands: none.
Mnemonic: UF0. . . UF7
Binary Representation
Instruction Type Motor/Bank Value
64. . . 71 <user dened> 0 <user dened> 0 <user dened>
Reply in Direct Mode
Status Value
100 - OK user dened
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
72 / 109

3.7.37 Request Target Position reached Event

This command is the only exception to the TMCL protocol, as it sends two replies: One immediately after the command has been executed (like all other commands also), and one additional reply that will be sent when the motor has reached its target position. This instruction can only be used in direct mode (in
standalone mode, it is covered by the WAIT command) and hence does not have a mnemonic.
Internal function: send an additional reply when a motor has reached its target position.
Related commands: none.
Binary Representation
Instruction Type Motor/Bank Value
138 0/1 0 (dont care) always 1
With command 138 the value eld is a bit vector. It shows for which motors one would like to have a position reached message. The value eld contains a bit mask where every bit stands for one motor. For one motor modules like the TMCM-1021 it only makes sense to have bit 0 set. So, always set this parameter to 1 with the TMCM-1021 module. With the type eld set to 0, only for the next MVP command that follows this command a position reached message will be generated. With type set to 1 a position reached message will be generated for every MVP command that follows this command. It is recommended to use the latter option.
Example
Get a target position reached message for each MVP command that follows.
Binary Form for this example
Field Value
Target address 01
Instruction number 8A
Type 01
Motor/Bank 00
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
Value (Byte 0) 01
Checksum 8D
h
h
h
h
h
h
h
h
h
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Reply in Direct Mode
Field Value
73 / 109
Target address 01
Host address 02
h
h
Status 64h(100)
Command 8Ah(138)
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
h
h
h
Value (Byte 0) Motor bit mask
Checksum depends also on motor bit mask
Additional Reply after Motor has reached Target Position
Field Value
Target address 01
Host address 02
h
h
Status 80h(128)
Command 8Ah(138)
Value (Byte 3) 00
Value (Byte 2) 00
Value (Byte 1) 00
h
h
h
Value (Byte 0) Motor bit mask
Checksum depends also on motor bit mask
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
74 / 109

3.7.38 TMCL Control Commands

There is a set of TMCL commands which are called TMCL control commands. These commands can only be used in direct mode and not in a standalone program. For this reason they only have opcodes, but no mnemonics. Most of these commands are only used by the TMCL-IDE (in order to implement e.g. the debugging functions in the TMCL creator). Some of them are also interesting for use in custom host applications, for example to start a TMCL routine on a module, when combining direct mode and standalone mode (please see also section 8.6. The following table lists all TMCL control commands.
The motor/bank parameter is not used by any of these functions and thus is not listed in the table. It should always be set to 0 with these commands.
TMCL Control Commands
Instruction Description Type Value
128 – stop application stop a running TMCL
application
129 – run application start or continue
TMCL program execution
130 – step application execute only the next
TMCL command
131 – reset application Stop a running TMCL
program. Reset program counter and stack pointer to zero. Reset accumulator and X register to zero. Reset all ags.
132 – enter download mode All following
commands (except control commands) are not executed but stored in the TMCL memory.
0 (dont care) 0 (dont care)
0 – from current
0 (dont care)
address
1 – from specic address
starting ad­dress
0 (dont care) 0 (dont care)
0 (dont care) 0 (dont care)
0 (dont care)
start address for download
133 – exit download mode End the download
mode. All following commands are executed normally again.
134 – read program memory Return contents of
the specied program memory location (special reply format).
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
0 (dont care) 0 (dont care)
0 (dont care)
address of memory loca­tion
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Instruction Description Type Value
75 / 109
135 – get application status Return information
about the current status, depending on the type eld.
136 – get rmware version Return rmware
version in string format (special reply) or binary format).
137 – restore factory settings Reset all settings in
the EEPROM to their factory defaults. This command does not send a reply.
255 – software reset Restart the CPU of
the module (like a power cycle). The reply of this command might not always get through.
0 - return mode,
0 (dont care) wait ag, memory pointer 1 - return mode, wait ag, program counter 2 - return accumulator 3 - return X register
0 - string format
0 (dont care) 1 - binary format
0 (dont care) set to 1234
0 (dont care) set to 1234
Table 13: TMCL Control Commands
Especially the commands 128, 129, 131, 136 and 255 are interesting for use in custom host applications. The other control commands are mainly being used by the TMCL-IDE.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
76 / 109

4 Axis Parameters

Most motor controller features of the TMCM-1021 module are controlled by axis parameters. Axis parameters can be modied or read using SAP, GAP and AAP commands. Some axis parameters can also be stored to or restored from the EEPROM using STAP and RSAP commands. This chapter describes all axis parameters that can be used on the TMCM-1021 module.
Meaning of the Letters in the Access Column
Access type Command Description
R GAP Parameter readable
W SAP, AAP Parameter writable
E STAP, RSAP Parameter can be stored in the EEPROM
Table 14: Meaning of the Letters in the Access Column
All Axis Parameters of the TMCM-1021 Module
Number Axis Parameter Description Range [Units] Access
0 Target position The desired target position in position mode -2147483648
. . . 2147483647 [µsteps]
1 Actual position
2 Target speed
The actual position of the motor. Stop the motor before overwriting it. Should normally only be overwritten for reference position setting.
The desired speed in velocity mode. Not valid in position mode.
-2147483648 . . . 2147483647 [µsteps]
-2147483648 . . . 2147483647 [pps]
3 Actual speed The actual speed of the motor. -2147483648
. . . 2147483647 [pps]
4 Maximum
positioning speed
5 Maximum
acceleration
The maximum speed used for positioning ramps.
1. . . 2147483647 [pps]
Maximum acceleration during ramp-up. 1.. .
2147483647 [pps2]
RW
RW
RW
RW
RWE
RWE
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
77 / 109
Number Axis Parameter Description Range [Units] Access
6 Maximum
current
7 Standby
current
Motor current used when motor is running. The maximum value is 255 which means 100% of the maximum current of the module. The current can be adjusted in 32 steps:
0. . . 7 79. . . 87 160. . . 167 240. . . 247
8. . . 15 88. . . 95 168. . . 175 248. . . 255
16. . . 23 96. . . 103 176. . . 183
24. . . 31 104. . . 111 184. . . 191
32. . . 39 112. . . 119 192. . . 199
40. . . 47 120. . . 127 200. . . 207
48. . . 55 128. . . 135 208. . . 215
56. . . 63 136. . . 143 216. . . 223
64. . . 71 144. . . 151 224. . . 231
72. . . 79 152. . . 159 232. . . 239
The most important setting, as too high values can cause motor damage.
The current used when the motor is not running. The maximum value is 255 which means 100% of the maximum current of the module. This value should be as low as possible so that the motor can cool down when it is not moving. Please see also parameter 214.
0. . . 255 RW
0. . . 255 RW
8 Position
reached ag
9 Home switch
state
10 Right limit
switch state
11 Left limit
switch state
12 Right limit
switch disable
13 Left limit
switch disable
This ag is always set when target position and
0/1 R
actual position are equal.
The logical state of the home switch input. 0/1 R
The logical state of the right limit switch input. 0/1 R
The logical state of the left limit switch input. 0/1 R
0 - switch activated
0/1 RWE
1 - switch deactivated
0 - switch activated
0/1 RWE
1 - switch deactivated
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
78 / 109
Number Axis Parameter Description Range [Units] Access
128 Ramp mode
130 Minimum
speed
140 Microstep
resolution
Automatically set when using ROR, ROL, MST and MVP. 0: Position mode. Steps are generated, when the parameters actual position and target position dier. Trapezoidal speed ramps are provided. 1: Velocity mode. The motor will run continu­ously and the speed will be changed using the maximum acceleration parameter when the tar­get speed gets changed.
Ramp generation for acceleration and deceler­ation begins and ends with this start and stop value. Default: 0.
Microstep resolutions per full step:
0 fullstep
1 halfstep
2 4 microsteps
3 8 microsteps
4 16 microsteps
5 32 microsteps
0/1 RW
0. . .
RWE 2147483647 [pps]
0. . . 8 RW
160 Step
interpolation enable
161 Double step
enable
162 Chopper blank
time
6 64 microsteps
7 128 microsteps
8 256 microsteps
Step interpolation is supported with 16 mi­crostep setting only. With this option activated, each microstepstep will internally be executed as 16 1/256 microsteps. This causes the mo­tor to run as smooth as with 256 microsteps resolution.
This only works for step/direction
mode.
0 - step interpolation o 1 - step interpolation on
With this option turned on, each microstep will be executed twice.
step/direction mode
This option only works for
. Every edge of the step signal then causes a microstep to be executed. 0 - double step o 1 - double step on
Selects the comparator blank time. This time needs to safely cover the switching event and the duration of the ringing on the sense resistor. Normally leave at the default value.
0/1 RW
0/1 RW
0. . . 3 RW
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
79 / 109
Number Axis Parameter Description Range [Units] Access
163 Constant TO
mode
164 Disable fast
decay comperator
165 Chopper
hysteresis end / fast decay time
166 Chopper
hysteresis start / sine wave oset
167 Chopper o
time (TO)
Selection of the chopper mode: 0 – spread cycle 1 – classic constant otime
See parameter 163. For classic const. otime setting this parameter to 1will disable current comparator usage for termination of fast decay cycle.
See parameter 163. For spread cyclechopper mode this parameter will set / return the hys­teresis end setting (hysteresis end value after a number of decrements). For classic const. o timechopper mode this parameter will set / return the fast decay time.
See parameter 163. For spread cyclechopper mode this parameter will set / return the Hys­teresis start setting (please note that this value is an oset to the hysteresis end value). For clas­sic const. otimechopper mode this parameter will set / return the sine wave oset.
The otime setting controls the minimum chopper frequency. An otime within the range of 5µs to 20µs will t.
0/1 RW
0/1 RW
0. . . 15 RW
0. . . 8 RW
0. . . 15 RW
168 smartEnergy
current minimum (SEIMIN)
169 smartEnergy
current down step
170 smartEnergy
hysteresis
Otime setting for constant t Ochopper:
N
= 12 + 32 ∗ tOF F (Minimum is 64 clocks)
CLK
Setting this parameter to zero completely dis­ables all driver transistors and the motor can free-wheel.
Sets the lower motor current limit for coolStep operation by scaling the maximum current (see axis parameter 6) value. Minimum motor current:
1
0 -
of CS
2 1
1 -
of CS
4
Sets the number of stallGuard2 readings above the upper threshold necessary for each current decrement of the motor current. Number of stallGuard2 measurements per decrement: Scaling: 0. . . 3: 32, 8, 2, 1 0: slow decrement 3: fast decrement
Sets the distance between the lower and the upper threshold for stallGuard2 reading. Above the upper threshold the motor current becomes decreased. Hysteresis: ([AP 172] + 1) 32 Upper stallGuard threshold: ([AP172]+[AP170]+
1) 32
0/1 RW
0. . . 3 RW
0. . . 15 RW
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
80 / 109
Number Axis Parameter Description Range [Units] Access
171 smart Energy
current up step
172 smart Energy
hysteresis start
173 stallGuard2
lter enable
174 stallGuard2
threshold
Sets the current increment step. The current becomes incremented for each measured stall­Guard2 value below the lower threshold see smartEnergy hysteresis start). Current incre­ment step size: Scaling: 0. . . 3: 1, 2, 4, 8 0: slow increment 3: fast increment / fast reaction to rising load
The lower threshold for the stallGuard2 value (see smart Energy current up step).
Enables the stallGuard2 lter for more precision of the measurement. If set, reduces the mea­surement frequency to one measurement per four fullsteps. In most cases it is expedient to set the ltered mode before using coolStep. Use the standard mode for step loss detection. 0 - standard mode 1 - ltered mode
This signed value controls stallGuard2 threshold level for stall output and sets the optimum mea­surement range for readout. A lower value gives a higher sensitivity. Zero is the starting value. A higher value makes stallGuard2 less sensitive and requires more torque to indicate a stall.
0. . . 3 RW
0..15 RW
0/1 RW
-64. . . +63 RW
175 Slope control
high side
176 Slope control
low side
177 Short
protection disable
Determines the slope of the motor driver out­puts. Leave at default value unless dierently recommended by Trinamic customer support. 0 - lowest slope 3 - fastest slope
Determines the slope of the motor driver out­puts. Leave at default value unless dierently recommended by Trinamic customer support. 0 - lowest slope 3 - fastest slope
Switches short to ground protection of the mo­tor driver on or o. Leave at default value unless dierently recommended by Trinamic customer support. 0 - Short to GND protection on 1 - Short to GND protection o
0. . . 3 RW
0. . . 3 RW
0/1 RW
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
81 / 109
Number Axis Parameter Description Range [Units] Access
178
Short detection timer
Timer value for short circuit protection of the motor driver. Leave at default value unless dif­ferently recommended by Trinamic customer support. 0 - 3.2µs 1 - 1.6µs 2 - 1.2µs 3 - 0.8µs
179 Vsense Sense resistor voltage based current scaling.
0 - High current range: up to 1.4A RMS / 2A peak. 1 - Low current range: up to 0.7A RMS / 1A peak. Default value: 1. Please note: this parameter cannot be changed for hardware V1.2! The high current range is available for hardware V1.4 or higher only!
180 smartEnergy
actual current
This status value provides the actual motor cur­rent setting as controlled by coolStep. The value goes up to the CS value and down to the portion of CS as specied by SEIMIN. Actual motor current scaling factor:
0. . . 31: 1/32, 2/32, . . . 32/32
181 Stop on stall
Below this speed motor will not be stopped. Above this speed motor will stop in case stall­Guard2 load value reaches zero.
182 smartEnergy
Above this speed coolStep becomes enabled. 0. . .
threshold speed
0. . . 3 RW
0/1 RW
0. . . 31 R
0. . .
RW 2147483647 [pps]
RW 2147483647 [pps]
183 smartEnergy
slow run current
184 Random TO
mode
Sets the motor current which is used below the threshold speed. A value of 255 means 100% of the maximum current of the module.
0 - Chopper otime is xed 1 - Chopper otime is random
0. . . 255 RW
0/1 RW
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
82 / 109
Number Axis Parameter Description Range [Units] Access
1 Search left stop switch only.
2
Search right stop switch, then search left stop switch.
3
Search right stop switch, then search left stop switch from both sides.
4
Search left stop switch from both sides.
5
193 Reference
search mode
Search home switch in negative di­rection, reverse the direction when
1. . . 8 RW
left stop switch reached.
6
Search home switch in positive di­rection, reverse the direction when right stop switch reached.
7
Search home switch in positive di­rection, ignore end switches.
194 Reference
search speed
195 Reference
switch speed
196 End switch
distance
197 Last reference
position
8
Search home switch in negative di­rection, ignore end switches.
Additional functions:
Add 128 to a mode value for inverting the home switch (can be used with mode
5. . . 8).
Add 64 to a mode for searching the right instead of the left reference switch (can be used with mode 1. . . 4).
This value species the speed for roughly search­ing the reference switch.
This parameter species the speed for searching the switching point. It should be slower than parameter 194.
This parameter provides the distance between the end switches after executing the RFS com­mand (with reference search mode 2 or 3).
This parameter contains the last position value before the position counter is set to zero during reference search.
0. . . 2147483647 [pps]
0. . . 2147483647 [pps]
-2147483648 . . . 2147483647 [µsteps]
-2147483648 . . . 2147483647 [µsteps]
RW
RW
R
R
200 Boost current
Current used for acceleration and deceleration phases. If set to 0 the same current as set by axis parameter #6 will be used. Same scaling as with axis parameter #6.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
0. . . 255 RW
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
83 / 109
Number Axis Parameter Description Range [Units] Access
204 Freewheeling
delay
206 Actual load
value
207 Extended error
ags
208 TMC262 error
ags
Time after which the power to the motor will be cut when its velocity has reached zero (a value of 0 (default setting) means never).
Readout of the actual load value used for stall detection (stallGuard2).
A combination of the following values:
1 stallGuard error
2 deviation error
These error ags are cleared automatically when this parameter has been read out or when a motion command has been executed.
A combination of the following values:
Bit 0 stallGuard2 status
(1: threshold reached)
Bit 1 Overtemperature
(1: driver is shut down due to overtemper­ature)
Bit 2 Overtemperature pre-warning
(1: temperature threshold is exceeded)
Bit 3 Short to ground A
(1: short condition detected, driver cur­rently shut down)
Bit 4 Short to ground B
(1: short condition detected, driver cur­rently shut down)
Bit 5 Open load A
(1: no chopper event has happened during the last period with constant coil polarity)
Bit 6 Open load B
(1: no chopper event has happened during the last period with constant coil polarity)
Bit 7 Stand still
(1: no step impulse occurred on the step
input during the last 220clock cycles) Please also refer to the TMC262 Datasheet for more information.
0. . . 65535 [10ms]
0. . . 1023 R
0. . . 3 R
0. . . 255 R
RWE
209 Encoder
Encoder counter value. -2147483648
position
210 Encoder
prescaler
212 Maximum
encoder deviation
Prescaler for the encoder. Please see section
6.2.
When the actual position (parameter #1) and the encoder position (parameter #209) dier more than set here the motor will be stopped. This function is switched owhen the maximum deviation is set to zero.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
. . . 2147483647 [µsteps]
See section
6.2
0 . . . 2147483647 [encoder steps]
RW
RW
RW
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
84 / 109
Number Axis Parameter Description Range [Units] Access
214 Power down
delay
215 Absolute
resolver value
254 Step/direction
mode
Standstill period before the motor current will be switched to standby current. The default value is 200 which means 2000ms.
Absolute position of the internal sensOstep en­coder. The absolute position is within one motor rotation.
0 Normal mode. Step/dir mode o.
1
Use of the ENABLE inputs on step/dir connector to switch between hold cur­rent and run current (no automatic switching) .
2
Automatic switching between hold and run current: after the rst step pulse the module automatically switches over to run current, and a congurable time af­ter the last step pulse the module auto-
matically switches back to hold current. The ENABLE inputs on the step/dir con­nector do not have any functionality.
3
Always use run current, never switch to hold current. The ENABLE inputs on the step/dir connector do not have any func­tionality.
1. . . 65535
RWE
[10ms]
0. . . 1023 R
0. . . 5 RWE
4
Automatic current switching like (2), but the ENABLE inputs are used to switch the driver stages completely oor on.
5
Always use run current like (3), but the ENABLE pins are used to switch the driver stages completely oor on.
Table 15: All Axis Parameters of the TMCM-1021 Module
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
85 / 109

5 Global Parameters

The following sections describe all global parameters that can be used with the SGP, GGP, AGP, STGP and RSGP commands. Global parameters are grouped into banks:
Bank 0: Global conguration of the module.
Bank 1: Not used.
Bank 2: TMCL user variables.
Bank 3: TMCL interrupt conguration.

5.1 Bank 0

Parameters with numbers from 64 on congure all settings that aect the overall behaviour of a module. These are things like the serial address, the RS485 baud rate or the CAN bit rate (where appropriate). Change these parameters to meet your needs. The best and easiest way to do this is to use the appropriate functions of the TMCL-IDE. The parameters with numbers between 64 and 128 are automatically stored in the EEPROM.
Note
An SGP command on such a parameter will always store it permanently and no extra STGP command is needed.
Take care when changing these parameters, and use the appropriate func­tions of the TMCL-IDE to do it in an interactive way.
Some congurations of the interface (for example baud rates that are not supported by the PC) may leed to the fact that the module cannot be reached any more. In such a case please see the TMCM-1021 Hardware Manual on how to reset all parameters to factory default settings.
Some settings (especially interface bit rate settings) do not take eect im­mediately. For those settings, power cycle the module after changing them to make the changes take eect.
There are dierent parameter access types, like read only or read/write. Table 16 shows the dierent parameter access types used in the global parameter tables.
Meaning of the Letters in the Access Column
Access type Command Description
R GGP Parameter readable
W SGP, AGP Parameter writable
E STGP, RSGP Parameter can be stored in the EEPROM
A SGP Automatically stored in the EEPROM
Table 16: Meaning of the Letters in the Access Column
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
86 / 109
All Global Parameters of the TMCM-1021 Module in Bank 0
Number Global Parameter Description Range [Units] Access
0 9600 Default
1 14400
2 19200
3 28800
65 RS485 baud rate
4 38400
0. . . 8 RWA
5 57600
6 76800
7 115200
8 230400
66 Serial address Module (target) address for RS485. 1. . . 255 RWA
67 ASCII Mode Congure the TMCL ASCII interface:
68 Serial heartbeat
Bit 0 0 - start up in binary (normal) mode
Bits 4 & 5 00 - Echo back each character
Serial heartbeat for RS485 interface. If this
1 - start up in ASCII mode
01 - Echo back complete command 10 - Do not send echo, only send com­mand reply
0. . . 63 RWA
0. . . 65535 RWA time limit is up and no further command is received by the module the motor will be stopped. Setting this parameter to 0 (de­fault) turns othe serial heartbeat function.
75 Telegram pause
time
Pause time before the reply via RS485 is sent. For use with older RS485 interfaces it
0. . . 255 RWA
is often necessary to set this parameter to
15 or more (e.g. RS485 adapters controlled
by the RTS pin). For CAN interface this pa­rameter has no eect!
76 Serial host
address
77 Auto start mode
Host address used in the reply telegrams sent back via RS485.
0 - Do not start TMCL application after power up (default).
1 - Start TMCL application automatically af-
ter power up.
79 End switch
polarity
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
0 - normal polarity
1 - reverse polarity
0. . . 255 RWA
0/1 RWA
0/1 RWA
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
87 / 109
Number Global Parameter Description Range [Units] Access
81 TMCL code
protection
84 Coordinate
storage
85 Do not restore
user variables
87 Serial secondary
address
Protect a TMCL program against disassem­bling or overwriting. 0 - no protection
1 - protection against disassembling
2 - protection against overwriting 3 - protection against disassembling and overwriting
When switching othe protection
against disassembling (changing this parameter from 1 or 3 to 0 or 2, the program will be erased rst!
0 - coordinates are stored in RAM only (but can be copied explicitly between RAM and EEPROM)
1 - coordinates are always also stored in the
EEPROM
Determines if TMCL user variables are to be restored from the EEPROM automatically on startup. 0 - user variables are restored (default)
1 - user variables are not restored
Second module (target) address for RS485. Setting this parameter to 0 switches othe secondary address.
0/1/2/3 RWA
0/1 RWA
0/1 RWA
0. . . 255 RWA
90 Reverse shaft Reverse motor and encoder direction.
0 - normal direction (default)
1 - reverse direction
Reversing the motor direction only works for normal mode, not for step/direction mode.
128 TMCL application
status
0 - stop
1 - run
2 - step 3 - reset
129 Download mode 0 - normal mode
1 - download mode
130 TMCL program
counter
132 TMCL tick timer
Contains the address of the currently exe­cuted TMCL command.
A 32 bit counter that gets incremented by one every millisecond. It can also be reset to any start value.
133 Random number
Returns a random number. The seed value can be set by writing to this parameter.
0/1 RWA
0. . . 3 R
0/1 R
R
0. . . 2147483647
0. . . 2147483647
RW
RW
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
88 / 109
Number Global Parameter Description Range [Units] Access
255 Suppress reply
The reply in direct mode will be suppressed
0/1 RW
when this parameter is set to 1. This pa-
rameter cannot be stored to EEPROM and
will be reset to 0 on startup. The reply will
not be suppressed for GAP, GGP and GIO commands.
Table 17: All Global Parameters of the TMCM-1021 Module in Bank 0

5.2 Bank 1

The global parameter bank 1 is normally not available. It may be used for customer specic extensions of the rmware. Together with user denable commands these variables form the interface between extensions of the rmware (written by Trinamic in C) and TMCL applications.

5.3 Bank 2

Bank 2 contains general purpose 32 bit variables for use in TMCL applications. They are located in RAM and the rst 56 variables can also be stored permanently in the EEPROM. After booting, their values are automatically restored to the RAM. Up to 256 user variables are available. Please see table 16 for an explanation of the dierent parameter access types.
User Variables in Bank 2
Number Global Parameter Description Range [Units] Access
0. . . 55
56. . . 255
user variables #0. . . #55
user variables #56. . . #255
TMCL user variables
TMCL user variables
-2147483648 . . . 2147483647
-2147483648 . . . 2147483647
RWE
RWE
Table 18: User Variables in Bank 2

5.4 Bank 3

Bank 3 contains interrupt parameters. Some interrupts need conguration (e.g. the timer interval of a timer interrupt). This can be done using the SGP commands with parameter bank 3 (SGP <type>, 3,
<value>).
a higher priority.
Table 19 shows all interrupt parameters that can be set. Please see table 16 for an explanation of the parameter access types.
Number Global Parameter Description Range [Units] Access
0 Timer 0 period
The priority of an interrupt depends on its number. Interrupts with a lower number have
Interrupt Parameters in Bank 3
Time between two interrupts
(ms)
0. . . 4294967295
[ms]
RW
1 Timer 1 period
Time between two interrupts
(ms)
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
0. . . 4294967295
[ms]
RW
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
89 / 109
Number Global Parameter Description Range [Units] Access
2 Timer 2 period
(ms)
27 Stop left 0 trigger
transition
28
Stop right 0 trigger transition
39 Input 0 trigger
transition
40 Input 1 trigger
transition
41 Input 2 trigger
transition
42 Input 3 trigger
transition
Time between two interrupts
0. . . 4294967295
RW
[ms]
0=o, 1=low-high, 2=high-low, 3=both 0. . . 3 RW
0=o, 1=low-high, 2=high-low, 3=both 0. . . 3 RW
0=o, 1=low-high, 2=high-low, 3=both 0. . . 3 RW
0=o, 1=low-high, 2=high-low, 3=both 0. . . 3 RW
0=o, 1=low-high, 2=high-low, 3=both 0. . . 3 RW
0=o, 1=low-high, 2=high-low, 3=both 0. . . 3 RW
Table 19: Interrupt Parameters in Bank 3
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
90 / 109
6 Module Specic Hints
This section contains some hints that are specic to the TMCM-1021 module.

6.1 Conversion between PPS, RPM and RPS

In order to convert between pps units and units like rounds per second (rps) or rounds per minute (rpm), one has to know the fullstep resolution of the motor (full steps per round) and the microstep resolution setting of the module (axis parameter #140, default setting is 256 microsteps per full step). So to convert from pps to rps, use the following formula:
v
= v
pps
· r
rps
microstep
· 60
To convert from rps to rpm, use:
With the following symbols:
v
: velocity in rounds per second
rps
v
: velocity in rounds per minute
rpm
v
=
rps
r
fullstep
v
rpm
v
: velocity in pulses (microsteps) per second
pps
r
r
: fullstep resolution of the motor (with most motors 200 (1.8°))
fullstep
microstep
: microstep setting of the module (default 256)
So, with a 200 fullsteps motor and a microstep setting of 256 (axis parameter #140 = 8), a velocity of 51200pps will result in 1rps (60rpm).

6.2 The sensOstepEncoder

The TMCM-1021 module oers an integrated sensOstep encoder. This built-in encoder has a resolution of 1024 steps per rotation. Please consider the following hints when using the built-in encoder:
The encoder counter can be read by software and can be used to monitor the current position of the motor.
To read out or to change the position value of the encoder use axis parameter #209. To read out the position of the internal encoder use GAP 209, 0. The encoder position register can also be changed using command SAP 209, 0, <n>, with n = -2147483648 . . . 2147483647.
Axis parameter #210 is used to change the encoder settings. This also includes the prescaler of the encoder. The prescaler is used to match motor resolution and encoder resolution.
The motor can be stopped automatically if motor position and encoder position dier too much (deviation error). This can be set using axis parameter #212 (maximum deviation). Setting this parameter to 0 turns othis feature.
As the built-in encoder is a magnetic encoder, the absolute position value can also be read. Use GAP 215, 0 to read the absolute (single-turn) position value. This always is a value between 0 and 1023 (independent of the prescaler setting).
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
91 / 109

6.2.1 Matching Encoder Resolution and Motor Resolution

When choosing a dierent microstep resolution than the factory default setting, the encoder prescaler also has to be adapted so that functions using the built-in encoder still work properly. Table 20 shows which prescaler settings are to be used with which microstep resolution settings. The factory default setting is 256 microsteps and prescaler 50.
Internal Encoder Settings
Microstep Encoder
Resolution SAP command Prescaler SAP command
256 SAP 140, 0, 8 50 SAP 210, 0, 25600
128 SAP 140, 0, 7 25 SAP 210, 0, 12800
64 SAP 140, 0, 6 12.5 SAP 210, 0, 6400
32 SAP 140, 0, 5 6.25 SAP 210, 0, 3200
16 SAP 140, 0, 4 3.125 SAP 210, 0, 1600
8 SAP 140, 0, 3 1.5625 SAP 210, 0, 800
4 SAP 140, 0, 2 0.78125 SAP 210, 0, 400
2 SAP 140, 0, 1 0.390625 SAP 210, 0, 200
Table 20: Internal Encoder Settings
Other encoder prescalers than those shown in table 20 can also be used, but are mostly not needed for the internal encoder. The formula for the prescaler setting isp=
prescaler ·
512 where <p> is the value passed to axis parameter #210. Hence, a setting of SAP 210, 0, 512 would for example result in a prescaler of 1. The lower four bits of the <p> value must not be used for the prescaler setting as they are reserved for activating special encoder functions.

6.2.2 Special Encoder Functions

The only special function of the internal sensOstep™encoder is the clear-on-null function. This will clear the encoder position each time the encoder passes its absolute zero point. This can be useful for nding a reference position. To activate this function, add the value of 4 to the value passed to axis parameter #210.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
92 / 109

7 Hints and Tips

This chapter gives some hints and tips on using the functionality of TMCL, for example how to use and parameterize the built-in reference search algorithm. You will also nd basic information about stallGuard2and coolStepin this chapter.

7.1 Reference Search

The built-in reference search features switching point calibration and support for a home switch and/or one or two end switches. The internal operation is based on a state machine that can be started, stopped and monitored (instruction RFS, opcode 13). The settings of the automatic stop functions corresponding to the end switches (axis parameters 12 and 13) do not inuence the reference search.
Notes:
Until the reference switch is found for the rst time, the searching speed set by axis parameter 194 is used.
After hitting the reference switch, the motor slowly moves until the switch is released. Finally the switch is re-entered in the other direction, setting the reference point to the center of the two switching points. The speed used for this calibration is dened by axis parameter 195.
Axis parameter 193 denes the reference search mode to be used. Choose one of the reference search modes shown in table 21 and in the following subsections:
Reference Search Modes
Value Description
1 search left stop switch only
2
search right stop switch, then search left stop switch
3
search right stop switch, then search left stop switch from both sides
4 search left stop switch from both sides
5
search home switch in negative direction, reverse the direction when left stop switch reached
6
search home switch in positive direction, reverse the direction when right stop switch reached
7
search home switch in positive direction, ignore end switches
8
search home switch in negative direction, ignore end switches
Table 21: Reference Search Modes
The drawings in the following subsections show how each reference search mode works. A linear stage with two end points and a moving slider is used as example.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
left limit / end / stop switch
start
stop
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
left limit / end / stop switch
right limit / end / stop switch
start
stop
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
93 / 109
7.1.1 Mode 1
Reference search mode 1 only searches the left end switch. Select this mode by setting axis parameter #193 to 1. Figure 3 illustrates this.
Add 64 to the mode number (i.e. set axis parameter #193 to 65) to search the right end switch instead of the left end switch.
Figure 3: Reference search Mode 1

7.1.2 Mode 2

Reference search mode 2 rst searches the right end switch and then the left end switch. The left end switch is then used as the zero point. Figure 4 illustrates this. Select this mode by setting axis parameter #193 to 2. After the reference search has nished, axis parameter #196 contains the distance between the two reference switches in microsteps.
Add 64 to the mode number (i.e. set axis parameter #193 to 66) to search the left end switch rst and then use the right end switch as the zero point.
Figure 4: Reference search Mode 2

7.1.3 Mode 3

Reference search mode 3 rst searches the right end switch and then the left end switch. The left end switch is then searched from both sides, to nd the middle of the left end switch. This is then used as the zero point. Figure 5 illustrates this. Select this mode by setting axis parameter #193 to 3. After the reference search has nished, axis parameter #196 contains the distance between the right end switch and the middle of the left end switch in microsteps.
Add 64 to the mode number (i.e. set axis parameter #193 to 67) to search the left end switch rst and then use the middle of the right end switch as the zero point.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
left limit / end / stop switch
right limit / end / stop switch
start
stop
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
left limit / end / stop switch
stop
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
start
94 / 109
Figure 5: Reference search Mode 3

7.1.4 Mode 4

Reference search mode 4 searches the left end switch only, but from both sides so that the middle of the switch will be found and used as the zero point. This is shown in gure 6.
Add 64 to the mode number (i.e. set axis parameter #193 to 68) to search the right end switch instead.
Figure 6: Reference search Mode 4

7.1.5 Mode 5

Refeerence search mode 5 searches the home switch in negative direction. The search direction will be reversed if the left limit switch is reached. This is shown in gure 7. Add 128 to the mode number (i.e. set axis parameter #193 to 129) to reverse the polarity of the home switch input.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
left limit / end / stop switch
start
stop
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
Home
home switch
right limit / end / stop switch
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
start
stop
home switch
95 / 109
Figure 7: Reference search Mode 5

7.1.6 Mode 6

Reference search mode 6 searches the home switch in positive direction. The search direction will be reversed if the right limit switch is reached. This is shown in gure 8. Add 128 to the mode number (i.e. set axis parameter #193 to 130) to reverse the polarity of the home switch input.
Figure 8: Reference search Mode 6

7.1.7 Mode 7

Reference search mode 7 searches the home switch in positive direction, ignoring the limit switch inputs. It is recommende mainly for use with a circular axis. The exact middle of the switch will be found and used as the zero point. Figure 9 illustrates this. Add 128 to the mode number (i.e. set axis parameter #193 to 131) to reverse the polarity of the home switch input.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
start
stop
home switch
: reference search speed (axis parameter 194)
: reference switch speed (axis parameter 195)
start
stop
home switch
96 / 109
Figure 9: Reference search Mode 7

7.1.8 Mode 8

Reference search mode 8 searches the home switch in positive direction, ignoring the limit switch inputs. It is recommende mainly for use with a circular axis. The exact middle of the switch will be found and used as the zero point. Figure 10 illustrates this. Add 128 to the mode number (i.e. set axis parameter #193 to 132) to reverse the polarity of the home switch input.
Figure 10: Reference search Mode 8
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
97 / 109

7.2 stallGuard2

The module is equipped with motor driver chips that feature load measurement. This load measurement can be used for stall detection. stallGuard2 delivers a sensorless load measurement of the motor as well as a stall detection signal. The measured value changes linear with the load on the motor in a wide range of load, velocity and current settings. At maximum motor load the stallGuard value goes to zero. This corresponds to a load angle of 90°between the magnetic eld of the stator and magnets in the rotor. This also is the most energy ecient point of operation for the motor.
Stall detection means that the motor will be stopped automatically when the load gets too high. This function is congured mainly using axis parameters #174 and #181.
Stall detection can for example be used for nding the reference point without the need for reference switches. A short routine written in TMCL is needed to use stallGuard for reference searching.
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
Velocity
Time
T
214
coolStep™ area
I
7
I
7
area w ithout coolStep™
SG
170
SG
181
V
182
I 6
I
183
I
183
Current
V
123 Velocity and parameter
I
123 Current and parameter
T
123 Time parameter
I
7
I
6
I
183
I6/2*
* The lower threshold of the coolStep™ current can be adjusted up to I 6/4. Refer to parameter 168.
The current depends on the load of the motor.
SG
123 stallGuard2™ parameter
98 / 109

7.3 coolStep

This section gives an overview of the coolStep related parameters. Please bear in mind that the gure only shows one example for a drive. There are parameters which concern the conguration of the current. Other parameters are there for velocity regulation and for time adjustment.
Figure 11 shows all the adjustment points for coolStep. It is necessary to identify and congure the thresholds for current (I6, I7 and I183) and velocity (V182). Furthermore the stallGuard2 feature has to be adjusted (SG170). It can also be enabled if needed (SG181).
The reduction or increasing of the current in the coolStep area (depending on the load) has to be congured using parameters I169 and I171.
In this chapter only basic axis parameters are mentioned which concern coolStep and stallGuard2. The complete list of axis parameters in chapter 4 contains further parameters which oer more conguration options.
Figure 11: coolStep Adjustment Points and Thresholds
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
coolStep Adjustment Points and Thresholds
Number Axis Parameter Description
99 / 109
I6 Absolute maximum current
I7 Standby current
I168 smartEnergy current minimum
I169 smartEnergy current down step
The maximum value is 255. This value means 100% of the maximum current of the module. The current adjustment is within the range 0. . . 255 and can be adjusted in 32 steps (0. . . 255 divided by eight; e.g. step 0 =
0. . . 7, step 1 = 8. . . 15 and so on).
Too high values may cause motor damage!
The current limit two seconds after the mo­tor has stopped.
Sets the lower motor current limit for cool­Step operation by scaling the CS (Current Scale, see axis parameter 6) value. Minimum motor current: 0 - 1/2 of CS 1 - 1/4 of CS
Sets the number of stallGuard2 readings above the upper threshold necessary for each current decrement of the motor cur­rent. Number of stallGuard2 measurements per decrement: Scaling: 0. . . 3: 32, 8, 2, 1 0: slow decrement 3: fast decrement
I171 smartEnergy current up step
SG170 smartEnergy hysteresis
SG181 Stop on stall
V182 smartEnergy threshold speed
T214 Power down delay
Sets the current increment step. The current becomes incremented for each measured stallGuard2 value below the lower threshold (see smartEnergy hystere­sis start). current increment step size: Scaling: 0. . . 3: 1, 2, 4, 8 0: slow increment 3: fast increment
Sets the distance between the lower and the upper threshold for stallGuard2 read­ing. Above the upper threshold the motor current becomes decreased.
Below this speed motor will not be stopped. Above this speed motor will stop in case stallGuard2 load value reaches zero.
Above this speed coolStep becomes en­abled.
Standstill period before the current is changed down to standby current. The stan­dard value is 200 (which means 2000msec).
Table 22: coolStep Adjustment Points and Thresholds
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
TMCM-1021 TMCL™Firmware Manual Firmware Version V1.42 | Document Revision V1.10 2018-JAN-09
100 / 109

8 TMCL Programming Techniques and Structure

8.1 Initialization

The rst task in a TMCL program (like in other programs also) is to initialize all parameters where dierent values than the default values are necessary. For this purpose, SAP and SGP commands are used.

8.2 Main Loop

Embedded systems normally use a main loop that runs innitely. This is also the case in a TMCL application that is running stand alone. Normally the auto start mode of the module should be turned on. After power up, the module then starts the TMCL program, which rst does all necessary initializations and then enters the main loop, which does all necessary tasks end never ends (only when the module is powered oor reset).
There are exceptions to this, e.g. when TMCL routines are called from a host in direct mode.
So most (but not all) stand alone TMCL programs look like this:
1
//Initialization
SAP 4, 0, 50000 //define maximum positioning speed
3
SAP 5, 0, 10000 //define maximum acceleration
5
MainLoop :
//do something , in this example just running between two positions
7
MVP ABS , 0, 5000 WAIT POS , 0 , 0
9
MVP ABS , 0, 0 WAIT POS , 0 , 0
11
JA MainLoop // end of the main loop => run infinitely

8.3 Using Symbolic Constants

To make your program better readable and understandable, symbolic constants should be taken for all important numerical values that are used in the program. The TMCL-IDE provides an include le with symbolic names for all important axis parameters and global parameters. Please consider the following example:
1
//Define some constants
#include TMCLParam .tmc
3
MaxSpeed = 50000 MaxAcc = 10000
5
Position0 = 0 Position1 = 500000
7
//Initialization
9
SAP APMaxPositioningSpeed , Motor0 , MaxSpeed SAP APMaxAcceleration , Motor0 , MaxAcc
11
MainLoop :
13
MVP ABS , Motor0 , Position1 WAIT POS , Motor0 , 0
15
MVP ABS , Motor0 , Position0
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.com
Loading...