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 firmware allows to control the module using TMCL™ commands, supporting
standalone operation as well as direct mode control, making use of the Trinamic TMC262 motor
driver. Dynamic current control, and quiet, smooth and efficient operation are combined with
stallGuard™ and coolStep™ 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, offers a convenient handling and can be used in many
decentralized applications. The module can be mounted on the back of NEMA 11 (28mm flange 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 efficiency from Trinamic’s coolStep™technology cost for power consumption is kept
down. The TMCL firmware allows for standalone operation and direct mode control.
Main characteristics
• Motion controller & stepper motor driver:
– On the fly 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-efficient operation, low power dissipation.
– Dynamic current control.
– Integrated protection.
– stallGuard2™ feature for stall detection.
– coolStep™ feature for reduced power consumption and heat dissipation.
• Encoder
– sensOstep™ magnetic 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 programming. 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).
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-efficient point of operation for
the motor.
Figure 1: stallGuard2 Load Measurement as a Function of Load
1.2coolStep
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 significant energy savings because coolStep automatically enables
torque reserve when required. Reducing power consumption keeps the ystem cooler, increases motor life,
and allows cost reduction.
In this chapter you can find some hints for your first 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.1Basic 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 Trinamic’s 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.2Using the TMCL Direct Mode
At first try to use some TMCL commands in direct mode. In the TMCL-IDE a tree view showing the TMCM1021 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.3Changing 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.
Maximum acceleration in positioning ramps. Acceleration 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. . . 255RW
maximum current of the module.
The current can be adjusted in 32 steps:
0. . . 779. . . 87160. . . 167240. . . 247
8. . . 1588. . . 95168. . . 175248. . . 255
16. . . 2396. . . 103176. . . 183
24. . . 31104. . . 111184. . . 191
32. . . 39112. . . 119192. . . 199
40. . . 47120. . . 127200. . . 207
48. . . 55128. . . 135208. . . 215
Access
RW
RW
56. . . 63136. . . 143216. . . 223
64. . . 71144. . . 151224. . . 231
72. . . 79152. . . 159232. . . 239
The most important setting, as too high values can
cause motor damage.
7Standby
current
The current used when the motor is not running.
The maximum value is 255 which means 100% of
0. . . 255RW
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.4Testing 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:
As with most TRINAMIC modules the software running on the microprocessor of the TMCM-1021 consists
of two parts, a boot loader and the firmware itself. Whereas the boot loader is installed during production
and testing at TRINAMIC and remains untouched throughout the whole lifetime, the firmware 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 specified 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 first. 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 commands 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 configuration variables for the axis and for global parameters which allow individual
configuration of nearly every function of a module. This manual gives a detailed description of all TMCL
commands and their usage.
3.1Binary 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 field, a
one-byte type field, a one-byte motor/bank field and a four-byte value field. 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:
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:
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.
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 first 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.
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 Configuring the ASCII Interface
The module can be configured 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 first 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.
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
MnemonicCommand numberMeaning
SAP5Set axis parameter
GAP6Get axis parameter
STAP7Store axis parameter
RSAP8Restore axis parameter
SGP9Set global parameter
GGP10Get global parameter
STGP11Store global parameter
RSGP12Restore global parameter
Table 7: Parameter Commands
3.6.3 Branch Commands
These commands are used to control the program flow (loops, conditions, jumps etc.). Using them in direct
mode does not make sense. They are intended for standalone mode only.
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
MnemonicCommand numberMeaning
SIO14Set output
GIO15Get 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
MnemonicCommand numberMeaning
CALC19Calculate using the accumulator and a constant value
CALCX33Calculate using the accumulator and the X register
AAP34Copy accumulator to an axis parameter
AGP35Copy accumulator to a global parameter
ACO39Copy 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
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 affected.
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
affecting the flow 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 define and handle interrupts:
Interrupt Processing Commands
MnemonicCommand numberMeaning
EI25Enable interrupt
DI26Disable interrupt
VECT37Set interrupt vector
RETI38Return from interrupt
Table 11: Interrupt Processing Commands
3.6.6.1 Interrupt Types
There are many different 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 identified by its interrupt number. Please use the TMCL include file Interrupts.inc in
order to have symbolic constants for the interrupt numbers. Table 12 show all interrupts that are available
on the TMCM-1021.
When an interrupt occurs and this interrupt is enabled and a valid interrupt vector has been defined
for that interrupt, the normal TMCL program flow 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, flags) 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 Configuration of Interrupts
Some interrupts need further configuration (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:
• Define an interrupt handling routine using the VECT command.
• If necessary, configure 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 flow to run into an interrupt handling routine.
The following example shows the use of a timer interrupt:
In the example above, the interrupt numbers are being used directly. To make the program better readable
use the provided include file Interrupts.inc. This file defines symbolic constants for all interrupt numbers
which can be used in all interrupt commands. The beginning of the program above then looks as follows:
The module specific 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 specified 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
InstructionTypeMotor/BankValue
100-2147483648. . . 2147583647
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example
Rotate right motor 0, velocity 51200.
Mnemonic: ROR 0, 51200.
The motor is instructed to rotate with a specified 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
InstructionTypeMotor/BankValue
200-2147483648. . . 2147583647
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example
Rotate left motor 0, velocity 51200.
Mnemonic: ROL 0, 51200.
With this command the motor will be instructed to move to a specified 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
defined 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 interrupted 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 offset 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
overflow).
Internal function: A new position value is transferred to the axis parameter #0 (target position).
Related commands: SAP, GAP, SCO, GCO, CCO, ACO, MST.
With this command most of the motion control parameters of the module can be specified. The settings
will be stored in SRAM and therefore are volatile. That is, information will be lost after power off.
Info
For a table with parameters and values which can be used together with this
command please refer to section 4.
Internal function:
The specified value is written to the axis parameter specified by the parameter number.
Related commands: GAP, AAP.
Mnemonic: SAP <parameter number>, <axis>, <value>
Binary representation
Binary Representation
InstructionTypeMotor/BankValue
5see chapter 40<value>
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example Set the maximum positioning speed for motor 0 to 51200 pps.
Mnemonic: SAP 4, 0, 51200.
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 field of the reply, without affecting 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 specified value gets copied to the accumulator.
Related commands: SAP, AAP.
Mnemonic: GAP <parameter number>, <axis>
Binary Representation
InstructionTypeMotor/BankValue
6see chapter 40<value>
Reply in Direct Mode
StatusValue
100 - OKvalue read by this command
Example
Get the actual position of motor 0.
Mnemonic: GAP 1, 0.
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 configuration 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 specified by the type and bank number will be stored in the
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 specified by the type and bank number will be restored from the
With this command most of the module specific parameters not directly related to motion control can be
specified and the TMCL user variables can be changed. Global parameters are related to the host interface,
peripherals or application specific variables. The different 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 configuration.
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 specified value will be copied to the global parameter specified 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
InstructionTypeMotor/BankValue
9see chapter 50/2/3<value>
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example
Set the serial address of the device to 3.
Mnemonic: SGP 66, 0, 3.
All global parameters can be read with this function. Global parameters are related to the host interface,
peripherals or application specific variables. The different 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 configuration.
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 specified by the type and bank number will be copied to the
accumulator register.
Related commands: SGP, AGP.
Mnemonic: GGP <parameter number>, <bank>
Binary Representation
InstructionTypeMotor/BankValue
10see chapter 50/2/30 (don’t care)
Reply in Direct Mode
StatusValue
100 - OKvalue read by this command
Example
Get the serial address of the device.
Mnemonic: GGP 66, 0.
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 modified.
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 specified by the type and bank number will be stored in the
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 specified by the type and bank number will be restored from
The TMCM-1021 has a built-in reference search algorithm. The reference search algorithm provides
different 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 finished. (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 configure 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
InstructionTypeMotor/BankValue
0 START — start reference search
131 STOP — stop reference search00 (don’t care)
2 STATUS — get status
Reply in Direct Mode (RFS START or RFS STOP)
StatusValue
100 - OK0 (don’t care)
Reply in Direct Mode (RFS STATUS)
StatusValue
0no ref. search active
100 - OK
other valuesreference search active
Example
Start reference search of motor 0.
Mnemonic: RFS START, 0.
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:
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 field of the reply, without affecting the accumulator. The actual status of a
digital output line can also be read.
Internal function:
The state of the i/o line specified by the type parameter and the bank parameter is read.
A value in the accumulator variable, previously read by a function such as GAP (get axis parameter) can
be modified with this instruction. Nine different arithmetic functions can be chosen and one constant
operand value must be specified. 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
InstructionTypeMotor/BankValue
190 ADD – add to accumulator0 (don’t 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
StatusValue
100 - OKthe operand (don’t care)
Example
Multiply accumulator by -5000.
Mnemonic: CALC MUL, -5000
The specified 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 sepcified value. The internal arithmetic
status flags 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
InstructionTypeMotor/BankValue
200 (don’t care)0 (don’t care)<operand>
Example
Jump to the address given by the label when the position of motor #0 is greater than or equal to 1000.
The JC instruction enables a conditional jump to a fixed address in the TMCL program memory, if the
specified 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
flags are in the appropriate states.
Related commands: JA, COMP, WAIT, CLE.
Mnemonic: JC <condition>, <label>
Binary Representation
InstructionTypeMotor/BankValue
210 ZE - zero0 (don’t 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.
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.
This instruction interrupts the execution of the TMCL program until the specified condition is met. This
command is intended for standalone operation only.
There are five different wait conditions that can be used:
• TICKS: Wait until the number of timer ticks specified by the <ticks> parameter has been reached.
•
POS: Wait until the target position of the motor specified by the <motor> parameter has been
reached. An optional timeout value (0 for no timeout) must be specified by the <ticks> parameter.
•
REFSW: Wait until the reference switch of the motor specified by the <motor> parameter has been
triggered. An optional timeout value (0 for no timeout) must be specified by the <ticks> parameter.
•
LIMSW: Wait until a limit switch of the motor specified by the <motor> parameter has been triggered.
An optional timeout value (0 for no timeout) must be specified by the <ticks> parameter.
•
RFS: Wait until the reference search of the motor specified by the <motor> field has been reached.
An optional timeout value (0 for no timeout) must be specified 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 specified by the
value store in the accumulator. The accumulator must not contain a negative value when using this option.
The timeout flag (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
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 specified 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.
Set coordinate #1 of motor #0 to 1000.
Mnemonic: SCO 1, 0, 1000
Binary Form of SCO 1, 0, 1000
FieldValue
Target address01
Instruction number1E
Type01
Motor/Bank00
Value (Byte 3)00
Value (Byte 2)00
Value (Byte 1)03
Value (Byte 0)E8
Checksum0B
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.
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 field of the reply, without affecting 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 field of the reply.
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.
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
InstructionTypeMotor/BankValue
32<coordinate number><motor number>0 (don’t care)
0. . . 200
Reply in Direct Mode
StatusValue
100 - OKvalue read by this command
Example
Store current position of motor #0 to coordinate array entry #3.
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
InstructionTypeMotor/BankValue
39<coordinate number><motor number>0 (don’t care)
0. . . 200
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example
Copy the actual value of the accumulator to coordinate #1 of motor #0.
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
InstructionTypeMotor/BankValue
330 ADD – add X register to accumulator0 (don’t care)0 (don’t 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
StatusValue
100 - OKdon’t care
Example
Multiply accumulator and X register.
Mnemonic: CALCX MUL
The content of the accumulator register is transferred to the specified axis parameter. For practical usage,
the accumulator has to be loaded e.g. by a preceding GAP instruction. The accumulator may have been
modified 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.
The content of the accumulator register is transferred to the specified global parameter. For practical
usage, the accumulator has to be loaded e.g. by a preceding GAP instruction. The accumulator may have
been modified 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 command please see section 5.
This command clears the internal error flags. It is mainly intended for use in standalone mode.
The following error flags can be cleared by this command (determined by the <flag> parameter):
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
InstructionTypeMotor/BankValue
25<interrupt number>0 (don’t care)0 (don’t care)
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example
Globally enable interrupt processing:
Mnemonic: EI 255
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
InstructionTypeMotor/BankValue
26<interrupt number>0 (don’t care)0 (don’t care)
Reply in Direct Mode
StatusValue
100 - OKdon’t care
Example
Globally disable interrupt processing:
Mnemonic: DI 255
The VECT command defines 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-defined. 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.
These commands are used for customer specific 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 firmware.
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
InstructionTypeMotor/BankValue
1380/10 (don’t care)always 1
With command 138 the value field is a bit vector. It shows for which motors one would like to have a
position reached message. The value field 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 field 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.
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
InstructionDescriptionTypeValue
128 – stop applicationstop a running TMCL
application
129 – run applicationstart or continue
TMCL program
execution
130 – step applicationexecute only the next
TMCL command
131 – reset applicationStop a running TMCL
program.
Reset program
counter and stack
pointer to zero.
Reset accumulator
and X register to zero.
Reset all flags.
132 – enter download modeAll following
commands (except
control commands)
are not executed but
stored in the TMCL
memory.
0 (don’t care)0 (don’t care)
0 – from current
0 (don’t care)
address
1 – from specific
address
startingaddress
0 (don’t care)0 (don’t care)
0 (don’t care)0 (don’t care)
0 (don’t care)
startaddress
for download
133 – exit download modeEnd the download
mode. All following
commands are
executed normally
again.
134 – read program memoryReturn contents of
the specified
program memory
location (special reply
format).
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.
Most motor controller features of the TMCM-1021 module are controlled by axis parameters. Axis
parameters can be modified 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 typeCommandDescription
RGAPParameter readable
WSAP, AAPParameter writable
ESTAP, RSAPParameter can be stored in the EEPROM
Table 14: Meaning of the Letters in the Access Column
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. . . 779. . . 87160. . . 167240. . . 247
8. . . 1588. . . 95168. . . 175248. . . 255
16. . . 2396. . . 103176. . . 183
24. . . 31104. . . 111184. . . 191
32. . . 39112. . . 119192. . . 199
40. . . 47120. . . 127200. . . 207
48. . . 55128. . . 135208. . . 215
56. . . 63136. . . 143216. . . 223
64. . . 71144. . . 151224. . . 231
72. . . 79152. . . 159232. . . 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. . . 255RW
0. . . 255RW
8Position
reached flag
9Home switch
state
10Right limit
switch state
11Left limit
switch state
12Right limit
switch disable
13Left limit
switch disable
This flag is always set when target position and
0/1R
actual position are equal.
The logical state of the home switch input.0/1R
The logical state of the right limit switch input.0/1R
The logical state of the left limit switch input.0/1R
Automatically set when using ROR, ROL, MST
and MVP.
0: Position mode. Steps are generated, when the
parameters actual position and target position
differ. Trapezoidal speed ramps are provided.
1: Velocity mode. The motor will run continuously and the speed will be changed using the
maximum acceleration parameter when the target speed gets changed.
Ramp generation for acceleration and deceleration begins and ends with this start and stop
value. Default: 0.
Microstepresolutionsperfullstep:
0fullstep
1halfstep
24 microsteps
38 microsteps
416 microsteps
532 microsteps
0/1RW
0. . .
RWE
2147483647
[pps]
0. . . 8RW
160Step
interpolation
enable
161Double step
enable
162Chopper blank
time
664 microsteps
7128 microsteps
8256 microsteps
Step interpolation is supported with 16 microstep setting only. With this option activated,
each microstepstep will internally be executed
as 16 1/256 microsteps. This causes the motor to run as smooth as with 256 microsteps
resolution.
This only works for step/direction
mode.
0 - step interpolation off
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 off
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.
Selection of the chopper mode:
0 – spread cycle
1 – classic constant off time
See parameter 163. For ”classic const. off time”
setting this parameter to ”1” will disable current
comparator usage for termination of fast decay
cycle.
See parameter 163. For ”spread cycle” chopper
mode this parameter will set / return the hysteresis end setting (hysteresis end value after a
number of decrements). For ”classic const. off
time” chopper mode this parameter will set /
return the fast decay time.
See parameter 163. For ”spread cycle” chopper
mode this parameter will set / return the Hysteresis start setting (please note that this value is
an offset to the hysteresis end value). For ”classic const. off time” chopper mode this parameter
will set / return the sine wave offset.
The off time setting controls the minimum
chopper frequency. An off time within the range
of 5µs to 20µs will fit.
0/1RW
0/1RW
0. . . 15RW
0. . . 8RW
0. . . 15RW
168smartEnergy
current
minimum
(SEIMIN)
169smartEnergy
current down
step
170smartEnergy
hysteresis
Off time setting for constant t Off chopper:
N
= 12 + 32 ∗ tOF F (Minimum is 64 clocks)
CLK
Setting this parameter to zero completely disables 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]+
Sets the current increment step. The current
becomes incremented for each measured stallGuard2 value below the lower threshold see
smartEnergy hysteresis start). Current increment 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 filter for more precision
of the measurement. If set, reduces the measurement frequency to one measurement per
four fullsteps. In most cases it is expedient to
set the filtered mode before using coolStep. Use
the standard mode for step loss detection.
0 - standard mode
1 - filtered mode
This signed value controls stallGuard2 threshold
level for stall output and sets the optimum measurement 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. . . 3RW
0..15RW
0/1RW
-64. . . +63RW
175Slope control
high side
176Slope control
low side
177Short
protection
disable
Determines the slope of the motor driver outputs. Leave at default value unless differently
recommended by Trinamic customer support.
0 - lowest slope
3 - fastest slope
Determines the slope of the motor driver outputs. Leave at default value unless differently
recommended by Trinamic customer support.
0 - lowest slope
3 - fastest slope
Switches short to ground protection of the motor driver on or off. Leave at default value unless
differently recommended by Trinamic customer
support.
0 - Short to GND protection on
1 - Short to GND protection off
Timer value for short circuit protection of the
motor driver. Leave at default value unless differently recommended by Trinamic customer
support.
0 - 3.2µs 1 - 1.6µs 2 - 1.2µs 3 - 0.8µs
179VsenseSense 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!
180smartEnergy
actual current
This status value provides the actual motor current setting as controlled by coolStep. The value
goes up to the CS value and down to the portion
of CS as specified by SEIMIN.
Actual motor current scaling factor:
0. . . 31: 1/32, 2/32, . . . 32/32
181Stop on stall
Below this speed motor will not be stopped.
Above this speed motor will stop in case stallGuard2 load value reaches zero.
182smartEnergy
Above this speed coolStep becomes enabled.0. . .
threshold
speed
0. . . 3RW
0/1RW
0. . . 31R
0. . .
RW
2147483647
[pps]
RW
2147483647
[pps]
183smartEnergy
slow run
current
184Random TOff
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 off time is fixed
1 - Chopper off time is random
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
193Reference
search mode
Search home switch in negative direction, reverse the direction when
1. . . 8RW
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.
194Reference
search speed
195Reference
switch speed
196End switch
distance
197Last reference
position
8
Search home switch in negative direction, 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 specifies the speed for roughly searching the reference switch.
This parameter specifies 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 command (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
200Boost 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.
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 combinationof thefollowing values:
1stallGuard error
2deviation error
These error flags are cleared automatically
when this parameter has been read out or when
a motion command has been executed.
A combinationof thefollowing values:
Bit 0stallGuard2 status
(1: threshold reached)
Bit 1Overtemperature
(1: driver is shut down due to overtemperature)
Bit 2Overtemperature pre-warning
(1: temperature threshold is exceeded)
Bit 3Short to ground A
(1: short condition detected, driver currently shut down)
Bit 4Short to ground B
(1: short condition detected, driver currently shut down)
Bit 5Open load A
(1: no chopper event has happened during
the last period with constant coil polarity)
Bit 6Open load B
(1: no chopper event has happened during
the last period with constant coil polarity)
Bit 7Stand 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. . . 1023R
0. . . 3R
0. . . 255R
RWE
209Encoder
Encoder counter value.-2147483648
position
210Encoder
prescaler
212Maximum
encoder
deviation
Prescaler for the encoder. Please see section
6.2.
When the actual position (parameter #1) and
the encoder position (parameter #209) differ
more than set here the motor will be stopped.
This function is switched off when the maximum
deviation is set to zero.
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 encoder. The absolute position is within one motor
rotation.
0Normal mode. Step/dir mode off.
1
Use of the ENABLE inputs on step/dir
connector to switch between hold current and run current (no automatic
switching) .
2
Automatic switching between hold and
run current: after the first step pulse the
module automatically switches over to
run current, and a configurable time after the last step pulse the module auto-
matically switches back to hold current.
The ENABLE inputs on the step/dir connector 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 functionality.
1. . . 65535
RWE
[10ms]
0. . . 1023R
0. . . 5RWE
4
Automatic current switching like (2), but
the ENABLE inputs are used to switch the
driver stages completely off or on.
5
Always use run current like (3), but the
ENABLE pins are used to switch the
driver stages completely off or on.
Table 15: All Axis Parameters of the TMCM-1021 Module
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 configuration of the module.
• Bank 1: Not used.
• Bank 2: TMCL user variables.
• Bank 3: TMCL interrupt configuration.
5.1Bank 0
Parameters with numbers from 64 on configure all settings that affect 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 functions of the TMCL-IDE to do it in an interactive way.
•
Some configurations 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 effect immediately. For those settings, power cycle the module after changing them
to make the changes take effect.
There are different parameter access types, like read only or read/write. Table 16 shows the different
parameter access types used in the global parameter tables.
Meaning of the Letters in the Access Column
Access typeCommandDescription
RGGPParameter readable
WSGP, AGPParameter writable
ESTGP, RSGPParameter can be stored in the EEPROM
ASGPAutomatically stored in the EEPROM
Table 16: Meaning of the Letters in the Access Column
66Serial addressModule (target) address for RS485.1. . . 255RWA
67ASCII ModeConfigure the TMCL ASCII interface:
68Serial heartbeat
Bit 00 - start up in binary (normal) mode
Bits 4 & 500 - 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 command reply
0. . . 63RWA
0. . . 65535RWA
time limit is up and no further command is
received by the module the motor will be
stopped. Setting this parameter to 0 (default) turns off the serial heartbeat function.
75Telegram pause
time
Pause time before the reply via RS485 is
sent. For use with older RS485 interfaces it
0. . . 255RWA
is often necessary to set this parameter to
15 or more (e.g. RS485 adapters controlled
by the RTS pin). For CAN interface this parameter has no effect!
76Serial host
address
77Auto start mode
Host address used in the reply telegrams
sent back via RS485.
0 - Do not start TMCL application after
power up (default).
Table 17: All Global Parameters of the TMCM-1021 Module in Bank 0
5.2Bank 1
The global parameter bank 1 is normally not available. It may be used for customer specific extensions
of the firmware. Together with user definable commands these variables form the interface between
extensions of the firmware (written by Trinamic in C) and TMCL applications.
5.3Bank 2
Bank 2 contains general purpose 32 bit variables for use in TMCL applications. They are located in RAM
and the first 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 different parameter access types.
Bank 3 contains interrupt parameters. Some interrupts need configuration (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.
This section contains some hints that are specific to the TMCM-1021 module.
6.1Conversion 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.2The sensOstep™ Encoder
The TMCM-1021 module offers 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 differ too much
(deviation error). This can be set using axis parameter #212 (maximum deviation). Setting this
parameter to 0 turns off this 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).
6.2.1 Matching Encoder Resolution and Motor Resolution
When choosing a different 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
MicrostepEncoder
ResolutionSAP commandPrescalerSAP command
256SAP 140, 0, 850SAP 210, 0, 25600
128SAP 140, 0, 725SAP 210, 0, 12800
64SAP 140, 0, 612.5SAP 210, 0, 6400
32SAP 140, 0, 56.25SAP 210, 0, 3200
16SAP 140, 0, 43.125SAP 210, 0, 1600
8SAP 140, 0, 31.5625SAP 210, 0, 800
4SAP 140, 0, 20.78125SAP 210, 0, 400
2SAP 140, 0, 10.390625SAP 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 finding
a reference position. To activate this function, add the value of 4 to the value passed to axis parameter
#210.
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 find basic information about
stallGuard2™ and coolStep™ in this chapter.
7.1Reference 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 influence the reference search.
Notes:
•
Until the reference switch is found for the first 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 defined by axis parameter 195.
Axis parameter 193 defines 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
ValueDescription
1search 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
4search 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.
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 first 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 finished, 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 first 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 first searches the right end switch and then the left end switch. The left end
switch is then searched from both sides, to find 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 finished, 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 first and then
use the middle of the right end switch as the zero point.
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 figure 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 figure 7.
Add 128 to the mode number (i.e. set axis parameter #193 to 129) to reverse the polarity of the home
switch input.
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 figure 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.
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.
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 field of the stator and magnets in the rotor. This
also is the most energy efficient 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 configured mainly using axis parameters #174 and #181.
Stall detection can for example be used for finding the reference point without the need for reference
switches. A short routine written in TMCL is needed to use stallGuard for reference searching.
* 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.3coolStep
This section gives an overview of the coolStep related parameters. Please bear in mind that the figure only
shows one example for a drive. There are parameters which concern the configuration 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 configure 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 configured
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 offer more configuration
options.
Figure 11: coolStep Adjustment Points and Thresholds
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 motor has stopped.
Sets the lower motor current limit for coolStep 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 current. Number of stallGuard2 measurements
per decrement:
Scaling: 0. . . 3: 32, 8, 2, 1
0: slow decrement
3: fast decrement
I171smartEnergy current up step
SG170smartEnergy hysteresis
SG181Stop on stall
V182smartEnergy threshold speed
T214Power down delay
Sets the current increment step.The
current becomes incremented for each
measured stallGuard2 value below the
lower threshold (see smartEnergy hysteresis 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 reading. 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 enabled.
Standstill period before the current is
changed down to standby current. The standard value is 200 (which means 2000msec).
Table 22: coolStep Adjustment Points and Thresholds
The first task in a TMCL program (like in other programs also) is to initialize all parameters where different
values than the default values are necessary. For this purpose, SAP and SGP commands are used.
8.2Main Loop
Embedded systems normally use a main loop that runs infinitely. 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 first does all necessary initializations and then enters
the main loop, which does all necessary tasks end never ends (only when the module is powered off or
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:
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 file with
symbolic names for all important axis parameters and global parameters. Please consider the following
example: