TMCM-1638-TMCL Firmware Manual fw1.09 Rev1.01
TMCM-1638-TMCL Firmware Manual fw1.09 Rev1.01
TMCM-1638-TMCL Firmware Manual fw1.09 Rev1.01
Features
• Single axis field oriented motor con-
trol
• Supply voltage 48V DC
• TMCL™
• Host interfaces: RS485, CAN
• Step/Direction inputs
• Additional inputs and outputs
• ABN encoder interface
• Hall sensor interface
Applications
©2021 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at: www.trinamic.com
Contents
1 Features 5
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 3 / 111
4 Axis Parameters 85
5 Global Parameters 92
5.1 Bank 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.2 Bank 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.3 Bank 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
6 Motor Regulation 97
6.1 Structure of Cascaded Motor Regulation Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.2 Current Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.2.1 Timing Control Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.2.2 Structure of the Current Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.3 Velocity Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.3.1 Timing Control Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.3.2 Structure of the Velocity Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.4 Velocity Ramp Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.5 Position Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.5.1 Timing Control Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
6.5.2 Structure of the Position Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
6.5.3 Correlation of Axis Parameters 10 and 7, the Target Position and the Position End
Flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 4 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 5 / 111
1 Features
The TMCM-1638 is a single axis field oriented controller/driver module for single phase DC motors, two
phase bipolar stepper motors and three phase BLDC motors with state of the art feature set. It is highly
integrated, offers a convenient handling and can be used in many applications that use a base board.
The module is equipped with a plug that can be plugged into a mating slot. As a mating slot, 98 pin PCIe
sockets can be used. Either Trinamic base boards can be used, or base boards can be designed by the
user. The module can drive stepper motors with up to 7A RMS coil current. The supply voltage can be
up to 48V. With its high energy efficiency using field oriented control 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:
– Ramp generation in real time (trapezoid ramp profile).
– On the fly alteration of motion parameters (e.g. position, velocity, acceleration).
– High performance microcontroller for overall system control and communication protocol han-
dling.
– High-efficient operation, low power dissipation.
– Field oriented control.
– Integrated protection.
– Open loop, hall sensor or encoder commutation.
• Encoder
– Standard ABN encoder interface.
– Usable for encoder based commutation and position control.
• Interfaces
– RS485 bus.
– CAN bus.
– Single ended ABN encoder input.
– Hall sensor inputs.
– Step/Direction inputs.
– Two general-purpose digital inputs.
– One dedicated analog input.
– Two stop switch inputs.
– One home switch input.
– One general purpose digital output.
Software
TMCL remote controlled operation via RS485 or CAN interface and/or stand-alone operation via TMCL
programming. PC-based application development software TMCL-IDE available for free.
Electrical data
• Supply voltage: +24V or +48V DC nominal (10. . . 52V DC supply range).
• Motor current: up to 7A RMS / 10A peak (programmable).
Please see also the separate Hardware Manual.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 6 / 111
Please also ensure that your TMCM-1638 is properly connected to your power supply and that the stepper
motor is properly connected to the module. Please see the TMCM-1638 hardware manual for instructions
on how to do this. Do not connect or disconnect a stepper motor to or from the module while the
module is powered!
Then, please start up the TMCL-IDE. After that you can switch on the power supply for your module and
connect your TMCM-1638 via RS485 or CAN. The module will be recognized by the TMCL-IDE, so that it
can be controlled using the IDE then.
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
500 rpm 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.
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.
Please see chapter 4 for a complete list of all axis parameters.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 7 / 111
19 PositionTest :
MVP ABS , 0 , 0
21 WAIT POS , 0 , 0
MVP ABS , 0 , 655360
23 WAIT POS , 0 , 0
JA PositionTest
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 don-
wload 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:
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.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 8 / 111
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 com-
mand to the TMCM-1638. 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 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 Inte-
grated 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.
The binary command format with RS-232, RS-485, RS-422 and USB is as follows:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 9 / 111
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.
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:
unsigned char i , Checksum ;
2 unsigned char Command [9];
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 10 / 111
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 check-
sum is not needed because the CAN bus uses hardware CRC checking.
The reply contains a status code. The status code can have one of the following values:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 11 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 12 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 13 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 14 / 111
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.
Motion Commands
Mnemonic Command number Meaning
ROL 2 Rotate left
ROR 1 Rotate right
MVP 4 Move to position
MST 3 Motor stop
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
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.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 15 / 111
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 specified event
STOP 28 End of a TMCL program
These commands control the external I/O ports and can be used in direct mode as well as in standalone
mode.
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
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
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 16 / 111
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 com-
mands 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.
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 Vectors
Interrupt number Interrupt type
0 Timer 0
1 Timer 1
2 Timer 2
3 Target position reached 0
27 Left stop switch 0
28 Right stop switch 0
39 Input change ADIN0 (digital mode)
41 Input change GPI0
42 Input change GPI1
255 Global interrupts
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 17 / 111
// 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
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 18 / 111
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 read-
able 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:
# include Interrupts . inc
2 VECT TI_TIMER0 , Timer0Irq
SGP TI_TIMER0 , 3 , 1000
4 EI TI_TIMER0
EI TI_GLOBAL
In order to make several operations easier, the following new commands have been introduced from
firmware version 1.09 on. Using these new commands many taks can be programmed in an easier way.
This can save some code, thus making a TMCL program shorter, faster and easier to understand.
Please note that these commands are not available on TMCM-1638 modules with firmware versions be-
fore 1.09. So please make sure that at least firmware version 1.09 is installed before using them.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 19 / 111
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.
Binary Representation
Instruction Type Motor/Bank Value
1 0 0 -2147483648. . . 2147583647
Example
Rotate right motor 0, velocity 500.
Mnemonic: ROR 0, 500.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 20 / 111
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:
Binary Representation
Instruction Type Motor/Bank Value
2 0 0 -2147483648. . . 2147583647
Example
Rotate left motor 0, velocity 500.
Mnemonic: ROL 0, 500.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 21 / 111
Internal function: The velocity mode is selected. Then, the target speed (axis parameter #0) is set to
zero.
Related commands: ROR, ROL, SAP, GAP.
Binary Representation
Instruction Type Motor/Bank Value
3 0 0 0
Example
Stop motor 0.
Mnemonic: MST 0.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 22 / 111
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 ini-
tialization 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 inter-
rupted using MST, ROL or ROR commands.
• 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.
Note The distance between the actual position and the new position must not be more
than 2147483647 (231 − 1) position steps . Otherwise the motor will run in the op-
posite 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, MST.
Binary Representation
Instruction Type Motor/Bank Value
0 – ABS – absolute 0 <position>
4
1 – REL – relative 0 <offset>
Example
Move motor 0 to position 90000.
Mnemonic: MVP ABS, 0, 90000
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 23 / 111
Example
Move motor 0 from current position 10000 steps backward.
Mnemonic: MVP REL, 0, -10000
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 24 / 111
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 num-
ber.
Related commands: GAP, AAP.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
5 see chapter 4 0 <value>
Example Set the maximum positioning speed for motor 0 to 51200 pps.
Mnemonic: SAP 4, 0, 51200.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 25 / 111
Most motion / driver related parameters of the TMCM-1638 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 com-
mand please refer to section 4.
Binary Representation
Instruction Type Motor/Bank Value
6 see chapter 4 0 <value>
Example
Get the actual position of motor 0.
Mnemonic: GAP 1, 0.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 26 / 111
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 EEP-
ROM.
Binary Representation
Instruction Type Motor/Bank Value
7 see chapter 4 0 0 (don’t care)
Example
Store axis parameter #6.
Mnemonic: STAP 7, 6.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 27 / 111
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
EEPROM.
Binary Representation
Instruction Type Motor/Bank Value
8 see chapter 4 0 0 (don’t care)
Example
Restore axis parameter #6.
Mnemonic: RSAP 8, 6.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 28 / 111
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.
Binary Representation
Instruction Type Motor/Bank Value
9 see chapter 5 0/2/3 <value>
Example
Set the serial address of the device to 3.
Mnemonic: SGP 66, 0, 3.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 29 / 111
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.
Binary Representation
Instruction Type Motor/Bank Value
10 see chapter 5 0/2/3 0 (don’t care)
Example
Get the serial address of the device.
Mnemonic: GGP 66, 0.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 30 / 111
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 mod-
ule, 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.2.
Internal function: The global parameter specified by the type and bank number will be stored in the
EEPROM.
Binary Representation
Instruction Type Motor/Bank Value
11 see chapter 5.2 2 0 (don’t care)
Example
Store user variable #42.
Mnemonic: STGP 42, 2.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 31 / 111
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.2.
Internal function: The global parameter specified by the type and bank number will be restored from
the EEPROM.
Binary Representation
Instruction Type Motor/Bank Value
12 see chapter 5.2 2 0 (don’t care)
Example
Restore user variable #42.
Mnemonic: RSGP 42, 2.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 32 / 111
This command sets the states of the general purpose digital outputs.
Internal function: The state of the output line specified by the type parameter is set according to the
value passed to this command.
Binary Representation
Instruction Type Motor/Bank Value
14 <port number> <bank number> (2) 0/1
Example
Set output 0 (bank 2) to high.
Mnemonic: SIO 0, 2, 1.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 33 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 34 / 111
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.
Binary Representation
Instruction Type Motor/Bank Value
15 <port number> <bank number> (0/1/2) 0 (don’t care)
Example
Get the value of ADC channel 0.
Mnemonic: GIO 0, 1.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 35 / 111
Special case: GIO 255, 0 reads all general purpose inputs simulataneously and puts the result into the
lower eight bits of the accumulator register.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 36 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 37 / 111
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.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
19 0 ADD – add to accumulator 0 (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
Example
Multiply accumulator by -5000.
Mnemonic: CALC MUL, -5000
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 38 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 39 / 111
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 stan-
dalone 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.
Binary Representation
Instruction Type Motor/Bank Value
20 0 (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.
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
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 40 / 111
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.
Binary Representation
Instruction Type Motor/Bank Value
21 0 ZE - zero 0 (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.
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
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 41 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 42 / 111
Jump to a fixed 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.
Mnemonic: JA <label>
Binary Representation
Instruction Type Motor/Bank Value
22 0 (don’t care) 0 (don’t care) <jump address>
Example
An infinite 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:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 43 / 111
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 over-
written 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.
Binary Representation
Instruction Type Motor/Bank Value
23 0 (don’t care) 0 (don’t 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 JA Loop
8 SubW :
WAIT POS , 0 , 0
10 WAIT TICKS , 0 , 50
RSUB // Continue with the command following the CSUB command
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 44 / 111
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.
Mnemonic: RSUB
Binary Representation
Instruction Type Motor/Bank Value
24 0 (don’t care) 0 (don’t care) 0 (don’t care)
Example
Please see the CSUB example (section 3.6.19).
Binary form:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 45 / 111
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.
Special case for the <ticks> parameter: When this parameter is set to -1 the contents of the accumula-
tor 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 com-
mand 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.
Binary Representation
Instruction Type Motor/Bank Value
0 TICKS – timer ticks 0 (don’t 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
Example
Wait for motor 0 to reach its target position, without timeout.
Mnemonic: WAIT POS, 0, 0
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 46 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 47 / 111
This command stops the execution of a TMCL program. It is intended for use in standalone operation only.
Mnemonic: STOP
Binary Representation
Instruction Type Motor/Bank Value
28 0 (don’t care) 0 (don’t care) 0 (don’t care)
Example
Mnemonic: STOP
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 48 / 111
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 accu-
mulator 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.
Binary Representation
Instruction Type Motor/Bank Value
33 0 ADD – add X register to accumulator 0 (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
Example
Multiply accumulator and X register.
Mnemonic: CALCX MUL
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 49 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 50 / 111
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.
Related commands: AGP, SAP, GAP, SGP, GGP, GIO, GCO, CALC, CALCX.
Binary Representation
Instruction Type Motor/Bank Value
34 see chapter 4 0 <value>
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
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 51 / 111
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 com-
mand please see section 5.
Binary Representation
Instruction Type Motor/Bank Value
35 <parameter number> 0/2/3 <bank number> 0 (don’t care)
Example
Copy accumulator to user variable #42:
Mnemonic: AGP 42, 2
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 52 / 111
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):
• ALL: clear all error flags.
• ETO: clear the timeout flag.
Binary Representation
Instruction Type Motor/Bank Value
36 0 ALL – all flags 0 (don’t care) 0 (don’t care)
1 – (ETO) timeout flag
2 – (EAL) alarm flag
3 – (EDV) deviation flag
4 – (EPO) position flag
5 – (ESD) shutdown flag
Example
Reset the timeout flag.
Mnemonic: CLE ETO
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 53 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 54 / 111
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 11 for a list of interrupts that can be used on the TMCM-1638
module.
Binary Representation
Instruction Type Motor/Bank Value
25 <interrupt number> 0 (don’t care) 0 (don’t care)
Example
Globally enable interrupt processing:
Mnemonic: EI 255
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 55 / 111
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 11 for a list of interrupts that can be used on the TMCM-1638
module.
Binary Representation
Instruction Type Motor/Bank Value
26 <interrupt number> 0 (don’t care) 0 (don’t care)
Example
Globally disable interrupt processing:
Mnemonic: DI 255
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 56 / 111
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 11 for a list of interrupts that can be used on the TMCM-1638
module.
Binary Representation
Instruction Type Motor/Bank Value
37 <interrupt number> 0 (don’t care) <label>
Example
Define interrupt vector for timer #0 interrupt:
1 VECT 0 , Timer0Irq
...
3 Loop :
...
5 JA Loop
...
7 Timer0Irq :
SIO 0 , 2 , 1
9 RETI
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 57 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 58 / 111
This command terminates an interrupt handling routine. Normal program flow 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 flow to
run into an interrupt routine.
Internal function: The saved registers (accumulator, X registers, flags and program counter) are copied
back so that normal program flow will continue.
Mnemonic: RETI
Binary Representation
Instruction Type Motor/Bank Value
38 <interrupt number> 0 (don’t care) 0 (don’t care)
Example
Return from an interrup handling routine.
Mnemonic: RETI
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 59 / 111
The CALCVV instruction directly uses the contents of two user variables for an arithmetic operation, stor-
ing the result in the first user variable. This eliminates the need for using the accumulator register and/or
X register for such purposes. The parameters of this command are the arithmetic function, the index of
the first user variable (0. . . 255) and the index of the second user variable (0. . . 255). This command is mainly
intended for use in standalone mode.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
40 0 ADD – add <var2> to <var1> 0 <var1> (0. . . 255) <var2> (0. . . 255)
1 SUB – subtract <var2> from <var1>
2 MUL – multiply <var2> with <var1>
3 DIV – divide <var2> by <var1>
4 MOD – modulo divide <var2> by <var1>
5 AND – logical and <var2> with <var1>
6 OR – logical or <var2> with <var1>
7 XOR – logical exor <var2> with <var1>
8 NOT – copy logical inverted <var2> to <var1>
9 LOAD – copy <var2> to <var1>
10 SWAP – swap contents of <var1> and <var2>
11 COMP – compare <var1> with <var2>
Example
Subtract user variable #42 from user variable #65.
Mnemonic: CALCVV SUB, 65, 42
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 60 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 61 / 111
3.6.32 CALCVA (Calculate using a User Variable and the Accumulator Register)
The CALCVA instruction directly modifies a user variable using an arithmetical operation and the contents
of the accumulator register. The parameters of this command are the arithmetic function and the index
of a user variable (0. . . 255). This command is mainly intended for use in standalone mode.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
41 0 ADD – add accumulator to <var> 0 <var> (0. . . 255) 0 (don’t care)
1 SUB – subtract accumulator from <var>
2 MUL – multiply <var> with accumulator
3 DIV – divide <var> by accumulator
4 MOD – modulo divide <var> by accumulator
5 AND – logical and <var> with accumulator
6 OR – logical or <var> with accumulator
7 XOR – logical exor <var> with accumulator
8 NOT – copy logical inverted accumulator to <var>
9 LOAD – copy accumulator to <var>
10 SWAP – swap contents of <var> and accumulator
11 COMP – compare <var> with accumulator
Example
Subtract accumulator from user variable #27.
Mnemonic: CALCVA SUB, 27
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 62 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 63 / 111
3.6.33 CALCAV (Calculate using the Accumulator Register and a User Variable)
The CALCAV instruction modifies the accumulator register using an arithmetical operation and the con-
tents of a user variable. The parameters of this command are the arithmetic function and the index of a
user variable (0. . . 255). This command is mainly intended for use in standalone mode.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
42 0 ADD – add <var> to accumulator 0 <var> (0. . . 255) 0 (don’t care)
1 SUB – subtract <var> from accumulator
2 MUL – multiply accumulator with <var>
3 DIV – divide accumulator by <var>
4 MOD – modulo divide accumulator by <var>
5 AND – logical and accumulator with <var>
6 OR – logical or accumulator with <var>
7 XOR – logical exor accumulator with <var>
8 NOT – copy logical inverted <var> to accumulator
9 LOAD – copy <var> to accumulator
10 SWAP – swap contents of <var> and accumulator
11 COMP – compare accumulator with <var>
Example
Subtract user variable #27 from accumulator.
Mnemonic: CALCXV SUB, 27
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 64 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 65 / 111
The CALCVX instruction directly modifies a user variable using an arithmetical operation and the contents
of the X register. The parameters of this command are the arithmetic function and the index of a user
variable (0. . . 255). This command is mainly intended for use in standalone mode.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
43 0 ADD – add X register to <var> 0 <var> (0. . . 255) 0 (don’t care)
1 SUB – subtract X register from <var>
2 MUL – multiply <var> with X register
3 DIV – divide <var> by X register
4 MOD – modulo divide <var> by X register
5 AND – logical and <var> with X register
6 OR – logical or <var> with X register
7 XOR – logical exor <var> with X register
8 NOT – copy logical inverted X register to <var>
9 LOAD – copy X register to <var>
10 SWAP – swap contents of <var> and X register
11 COMP – compare <var> with X register
Example
Subtract X register from user variable #27.
Mnemonic: CALCVX SUB, 27
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 66 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 67 / 111
The CALCXV instruction modifies the X register using an arithmetical operation and the contents of a user
variable. The parameters of this command are the arithmetic function and the index of a user variable
(0. . . 255). This command is mainly intended for use in standalone mode.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
44 0 ADD – add <var> to X register 0 <var> (0. . . 255) 0 (don’t care)
1 SUB – subtract <var> from X register
2 MUL – multiply X register with <var>
3 DIV – divide X register by <var>
4 MOD – modulo divide X register by <var>
5 AND – logical and X register with <var>
6 OR – logical or X register with <var>
7 XOR – logical exor X register with <var>
8 NOT – copy logical inverted <var> to X register
9 LOAD – copy <var> to X register
10 SWAP – swap contents of <var> and X register
11 COMP – compare X register with <var>
Example
Subtract user variable #27 from X register.
Mnemonic: CALCXV SUB, 27
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 68 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 69 / 111
The CALCV directly modifies a user variable using an arithmetical operation and a direct value. This elim-
inates the need of using the accumulator register for such a purpose and thus can make the program
shorter and faster. The parameters of this command are the arithmetic function, the index of a user vari-
able (0. . . 255) and a direct value. This command is mainly intended for use in standalone mode.
Binary representation
Binary Representation
Instruction Type Motor/Bank Value
45 0 ADD – add <value> to <var> 0 <var> (0. . . 255) <value>
1 SUB – subtract <value> from <var>
2 MUL – multiply <var> with <value>
3 DIV – divide <var> by <value>
4 MOD – modulo divide <var> by <value>
5 AND – logical and <var> with <value>
6 OR – logical or <var> with <value>
7 XOR – logical exor <var> with <value>
8 NOT – logical invert <var> (<value> ignored)
9 LOAD – copy <value> to <var>
11 COMP – compare <var> with <value>
Example
Subtract 5000 from user variable #27.
Mnemonic: CALCV SUB, 27, 5000
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 70 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 71 / 111
Stop the program, reset the TMCL interpreter and then re-start the program at the given label. This com-
mand can be used to re-start the TMCL program from anywhere in the program, also out of subroutines
or interrupt rotuines. This command is intended for standalone operation only.
Internal function: The TMCL interpreter is reset (the subroutine stack, the interrupt stack and the regis-
ters are cleared) and then the program counter is set to the value passed to this command.
Binary Representation
Instruction Type Motor/Bank Value
48 0 (don’t care) 0 (don’t care) <restart address>
Example
Restart the program from a label, out of a subroutine:
1 Entry :
MVP ABS , 0 , 51200
3 CSUB Subroutine
...
5 ...
Subroutine :
7 RST Entry
RSUB
Binary form of the RST Entry command when the label Entry is at address 10:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 72 / 111
Decrement a given user variable and jump to the given address if the user variable is greater than zero.
This command can for example be used to easily program a counting loop, using any user variable as the
loop counter. This command is intended for standalone operation only.
Internal function: The user variable passed to this command is decremented. If it is not zero then the
TMCL program counter is set to the value passed to this command.
Binary Representation
Instruction Type Motor/Bank Value
49 <user variable> (0. . . 255) 0 (don’t care) <jump address>
Example
A counting loop in TMCL, using user variable #42:
SGP 42 , 2 , 100
2 Loop :
MVP ABS , REL , 51200
4 WAIT POS , 0 , 0
WAIT TICKS , 0 , 500
6 DJNZ 42 , Loop
Binary form of the DJNZ 42, Loop command when the label Loop is at address 1:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 73 / 111
The CALL command calls a subroutine in the TMCL program, but only if the specifed condition is met. Oth-
erwise the program execution will be continued with the next command following the CALL command.
The conditions refer to the result of a preceding comparison or assignment. This command is intended for
standalone operation only.
Internal function: When the condition is met the actual TMCL program counter value will be saved to
an internal stack. Afterwards the program counter will be overwritten with the address supplied to this
command. 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.
Binary Representation
Instruction Type Motor/Bank Value
21 0 ZE - zero 0 (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
Call a subroutine if a condition is met:
Loop :
2 GIO 0 , 1 // read analog value
CALC SUB , 512 // subtract 512
4 COMP 0 // compare with zero
CALL LT , RunLeft // Call routine " RunLeft " if accu <0
6 CALL ZE , MotorStop // Call routine " MotosStop " if accu =0
CALL GT , RunRight // Call routine " RunRight " if accu >0
8 JA Loop
10 RunLeft :
CALC MUL , -1
12 ROLA 0
RSUB
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 74 / 111
14
RunRight :
16 RORA 0
RSUB
18
MotorStop :
20 GAP 2 , 0
JC ZE , MotorIsStopped
22 MST 0
MotorIsStopped :
24 RSUB
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 75 / 111
With this command the motor will be instructed to move to a specified relative or absolute position. The
contents of the accumulator register will be used as the target position. This command is non-blocking
which means that 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.
Positioning can be interrupted using MST, ROL or ROR commands.
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 oppo-
site direction in order to take the shorter distance (caused by 32 bit overflow).
Internal function: The value stored in the accumulator register is copied to the axis parameter #0 (target
position).
Related commands: MVPXA, SAP, GAP, SCO, GCO, CCO, ACO, MST.
Binary Representation
Instruction Type Motor/Bank Value
0 – ABS – absolute 0 0 (don’t care)
46 1 – REL – relative 0 0 (don’t care)
2 – COORD – coordinate 0. . . 255 0 (don’t care)
Example
Move motor 0 to position specified by accumulator.
Mnemonic: MVPA ABS, 0
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 76 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 77 / 111
Rotate in left direction (decreasing the position counter) using the velocity specified by the contents of
the accumulator register. The velocity is given in microsteps per second (pulse per second [pps]).
Internal function:
Binary Representation
Instruction Type Motor/Bank Value
50 0 (don’t care) 0 (don’t care) 0 (don’t care)
Example
Rotate left motor 0, velocity specified by accumulator.
Mnemonic: ROLA 0.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 78 / 111
Rotate in right direction (increasing the position counter) using the velocity specified by the contents of
the accumulator register. The velocity is given in microsteps per second (pulse per second [pps]).
Internal function:
Binary Representation
Instruction Type Motor/Bank Value
51 0 (don’t care) 0 (don’t care) 0 (don’t care)
Example
Rotate right motor 0, velocity specified by accumulator.
Mnemonic: RORA 0.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 79 / 111
This command copies a direct value to a TMCL user variable. The index of the user variable (0. . . 255) is
specified by the content of the X register. Therefore the value in the X register must not be lower than
zero or greater than 255. Otherwise this command will be ignored. This command is mainly intended for
use in standalone mode.
Internal function: The direct value supplied to this command will be copied to the user variable specified
by the X register.
Mnemonic: SIV
Binary Representation
Instruction Type Motor/Bank Value
55 0 (don’t care) 0 (don’t care) <value>
Example
Copy the value 3 to the user variable indexed by the X register.
Mnemonic: SIV 3.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 80 / 111
This command reads a TMCL user variable and copies its content to the accumulator register. The index
of the user variable (0. . . 255) is specified by the X register. Therefore the content of the X register must
not be lower than zero or greater than 255. Otherwise this command will be ignored. This command is
mainly intended for use in standalone mode.
Internal function: The user variable specified by the x register will be copied to the accumulator register.
Mnemonic: GIV
Binary Representation
Instruction Type Motor/Bank Value
55 0 (don’t care) 0 (don’t care) 0 (don’t care)
Example
Read the user variable indexed by the X register.
Mnemonic: GIV.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 81 / 111
This command copies the content of the accumulator to a TMCL user variable. The index of the user vari-
able (0. . . 255) is specified by the content of the X register. Therefore the value in the X register must not
be lower than zero or greater than 255. Otherwise this command will be ignored. This command is mainly
intended for use in standalone mode.
Internal function: The accumulator will be copied to the user variable specified by the X register.
Mnemonic: AIV
Binary Representation
Instruction Type Motor/Bank Value
55 0 (don’t care) 0 (don’t care) <value>
Example
Copy the accumulator to the user variable indexed by the X register.
Mnemonic: AIV.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 82 / 111
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.
Binary Representation
Instruction Type Motor/Bank Value
64. . . 71 <user defined> 0 <user defined> 0 <user defined>
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 83 / 111
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 appli-
cations, for example to start a TMCL routine on a module, when combining direct mode and standalone
mode (please see also section 7.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.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 84 / 111
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.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 85 / 111
4 Axis Parameters
Most motor controller features of the TMCM-1638 module are controlled by axis parameters. Axis param-
eters 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-1638 module.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 86 / 111
30 target torque Get desired target current or set tar- −60000 . . . 60000 0 RW
get current to activate current regu- [mA]
lation mode. (+= turn motor in right
direction; -= turn motor in left direc-
tion)
31 actual torque The actual motor current. −2147483648 0 R
. . . 2147483647
[mA]
32 target flux Get desired target flux or set tar- −60000 . . . 60000 0 RW
get flux to activate current regulation [mA]
mode.
33 actual flux The actual motor flux. −2147483648 0 R
. . . 2147483647
[mA]
40 target velocity The desired target velocity. −200000 0 RW
. . . 200000 [rpm]
41 ramp velocity The actual velocity of the velocity −2147483648 0 R
ramp used for positioning and veloc- . . . 2147483647
ity mode. [rpm]
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 87 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 88 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 89 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 90 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 91 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 92 / 111
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:
5.1 Bank 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 func-
tions 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-1638 Hardware
Manual on how to reset all parameters to factory default settings.
• Some settings (especially interface bit rate settings) do not take effect im-
mediately. 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 15 shows the different
parameter access types used in the global parameter tables.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 93 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 94 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 95 / 111
5.2 Bank 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 15 for an
explanation of the different parameter access types.
5.3 Bank 3
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>). The priority of an interrupt depends on its number. Interrupts with a lower number have
a higher priority.
Table 18 shows all interrupt parameters that can be set. Please see table 15 for an explanation of the
parameter access types.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 96 / 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 97 / 111
6 Motor Regulation
6.1 Structure of Cascaded Motor Regulation Modes
The TMCM-1638 supports a current, velocity, and position PID regulation mode for motor control in dif-
ferent application areas. These regulation modes are cascaded as shown in Figure 1. Individual modes
are explained in the following subsections.
The timing control value (current regulation loop multiplier, axis parameter 134) determines how often
the current regulation is invoked. The value is given in multiple of 50µs, following the next formula:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 98 / 111
For all tests, set the motor current limitation to a realistic value, so that your power supply does not
become overloaded during acceleration phases. If your power supply reaches current limitation, the unit
may reset or undetermined regulation results may occur.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 99 / 111
The velocity PI regulator uses a timing control value (velocity regulation loop multiplier, axis parameter
133) which determines how often the PID regulator is invoked. The value is given in multiple of 50µs,
following the next formula:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 100 / 111
The PID regulation uses two basic parameters: the P regulation parameter and a timing control value.
The timing control value PID regulation loop parameter (axis parameter 133) determines how often the
PID regulator is invoked. The value is given in multiple of 50µs, following the next formula:
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 101 / 111
1. Disable the velocity ramp generator and set position P parameter to zero.
2. Choose a target position and increase the position P parameter until the motor reaches the target
position approximately.
3. Switch on the velocity ramp generator. Based on the max. positioning velocity (axis parameter 4)
and the acceleration value (axis parameter 11) the ramp generator automatically calculates the slow
down point, i.e. the point at which the velocity has to be reduced in order to stop at the desired
target position.
4. Reaching the target position is signaled by setting the position end flag.
In order to minimize the time until this flag becomes set, the positioning tolerance MVP target reached
distance can be chosen with axis parameter 10.
Since the motor typically is assumed not to signal target reached when the target was just passed in a
short moment at a high velocity, additionally the maximum target reached velocity (MVP target reached
velocity) can be defined by axis parameter 7.
A value of zero for axis parameter 7 is the most universal, since it implies that the motor stands still at the
target. But when a fast rising of the position end flag is desired, a higher value for the MVP target reached
velocity parameter will save a lot of time. The best value should be tried out in the actual application.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 102 / 111
6.5.3 Correlation of Axis Parameters 10 and 7, the Target Position and the Position End Flag
Depending on motor and mechanics, a low oscillation is normal. This can be reduced to at least +/-1 steps.
Without oscillation the regulation cannot keep the position!
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 103 / 111
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:
// Initialization
2 SAP 4 , 0 , 50000 // define maximum positioning speed
SAP 5 , 0 , 10000 // define maximum acceleration
4
MainLoop :
6 // do something , in this example just running between two positions
MVP ABS , 0 , 5000
8 WAIT POS , 0 , 0
MVP ABS , 0 , 0
10 WAIT POS , 0 , 0
JA MainLoop // end of the main loop = > run infinitely
// 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
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 104 / 111
Using constants for other values makes it easier to change them when they are used more than once in
a program. You can change the definition of the constant and do not have to change all occurrences of it
in your program.
• SGP is used to set a variable to a constant value (e.g. during initialization phase).
• GGP is used to read the contents of a user variable and to copy it to the accumulator register for
further usage.
• AGP can be used to copy the contents of the accumulator register to a user variable, e.g. to store
the result of a calculation.
• The STGP command stores the contents of a user varaible in the EEPROM.
• The RSGP command copies the value stored in the EEPROM back to the user variable.
• Global parameter 85 controls if user variables will be restored from the EEPROM automatically on
startup (default setting) or not (user variables will then be initialized with 0 instead).
5 SGP MyVariable , 2 , 1234 // Initialize the variable with the value 1234
...
7 ...
GGP MyVariable , 2 // Copy contents of variable to accumulator register
9 CALC MUL , 2 // Multiply accumulator register with two
AGP MyVariable , 2 // Store contents of accumulator register to variable
11 ...
...
Furthermore, these variables can provide a powerful way of communication between a TMCL program
running on a module and a host. The host can change a variable by issuing a direct mode SGP command
(remember that while a TMCL program is running direct mode commands can still be executed, without
interfering with the running program). If the TMCL program polls this variable regularly it can react on
such changes of its contents.
The host can also poll a variable using GGP in direct mode and see if it has been changed by the TMCL
program.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 105 / 111
This mechanism can also be nested. From a subroutine called by a CSUB command other subroutines
can be called. In the current version of TMCL eight levels of nested subroutine calls are allowed.
Communication between a program running in standalone mode and a host can be done using the TMCL
user variables. The host can then change the value of a user variable (using a direct mode SGP command)
which is regularly polled by the TMCL program (e.g. in its main loop) and so the TMCL program can react
on such changes. Vice versa, a TMCL program can change a user variable that is polled by the host (using
a direct mode GGP command).
A TMCL program can be started by the host using the run command in direct mode. This way, also a
set of TMCL routines can be defined that are called by a host. In this case it is recommended to place JA
commands at the beginning of the TMCL program that jump to the specific routines. This assures that
the entry addresses of the routines will not change even when the TMCL routines are changed (so when
changing the TMCL routines the host program does not have to be changed).
Example:
// Jump commands to the TMCL routines
2 Func1 : JA Func1Start
Func2 : JA Func2Start
4 Func3 : JA Func3Start
6 Func1Start :
MVP ABS , 0 , 1000
8 WAIT POS , 0 , 0
MVP ABS , 0 , 0
10 WAIT POS , 0 , 0
STOP
12
Func2Start :
14 ROL 0 , 500
WAIT TICKS , 0 , 100
16 MST 0
STOP
18
Func3Start :
20 ROR 0 , 1000
WAIT TICKS , 0 , 700
22 MST 0
STOP
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 106 / 111
This example provides three very simple TMCL routines. They can be called from a host by issuing a run
command with address 0 to call the first function, or a run command with address 1 to call the second
function, or a run command with address 2 to call the third function. You can see the addresses of the
TMCL labels (that are needed for the run commands) by using the ”Generate symbol file function” of the
TMCL-IDE.
• Execute the command SGP 77, 0, 1 in direct mode (using the Direct Mode tool in the TMCL-IDE).
• Use the Global Parameters tool in the TMCL-IDE to set global parameter #77 to 1.
• Use the Autostart entry in the TMCL menu of the TMCL Creator in the TMCL-IDE. Go to the Autostart
entry in the TMCL menu and select "’On"’.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 107 / 111
8 Figures Index
1 Cascaded Regulation . . . . . . . . . . 97 4 Positioning Regulation . . . . . . . . . 101
2 Current Regulation . . . . . . . . . . . 98 5 Positioning Algorithm . . . . . . . . . 102
3 Velocity Regulation . . . . . . . . . . . 99
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 108 / 111
9 Tables Index
1 TMCL Command Format . . . . . . . . 9 14 All TMCM-1638 Axis 0 Parameters . . 91
2 TMCL Reply Format . . . . . . . . . . . 10 15 Meaning of the Letters in the Access
3 TMCL Status Codes . . . . . . . . . . . 10 Column . . . . . . . . . . . . . . . . . . 92
4 Overview of all TMCL Commands . . . 13 16 All Global Parameters of the TMCM-
5 Motion Commands . . . . . . . . . . . 14 1638 Module in Bank 0 . . . . . . . . . 95
6 Parameter Commands . . . . . . . . . 14 17 User Variables in Bank 2 . . . . . . . . 95
7 Branch Commands . . . . . . . . . . . 15
18 Interrupt Parameters in Bank 3 . . . . 96
8 I/O Port Commands . . . . . . . . . . 15
19 Current Regulation Parameters . . . . 98
9 Calculation Commands . . . . . . . . 15
10 Interrupt Processing Commands . . . 16 20 Velocity Regulation Parameters . . . . 99
11 Interrupt Vectors . . . . . . . . . . . . 17 21 Position Regulation Parameters . . . 101
12 New TMCL Commands . . . . . . . . . 18 22 Firmware Revision . . . . . . . . . . . 111
13 TMCL Control Commands . . . . . . . 84 23 Document Revision . . . . . . . . . . . 111
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 109 / 111
10 Supplemental Directives
10.1 Producer Information
10.2 Copyright
TRINAMIC owns the content of this user manual in its entirety, including but not limited to pictures, logos,
trademarks, and resources. © Copyright 2021 TRINAMIC. All rights reserved. Electronically published by
TRINAMIC, Germany.
Redistributions of source or derived format (for example, Portable Document Format or Hypertext Markup
Language) must retain the above copyright notice, and the complete Datasheet User Manual documen-
tation of this product including associated Application Notes; and a reference to other available product-
related documentation.
This TMCL™ Firmware Manual is a non-commercial publication that seeks to provide concise scientific
and technical user information to the target user. Thus, trademark designations and symbols are only
entered in the Short Spec of this document that introduces the product at a quick glance. The trademark
designation /symbol is also entered when the product or feature name occurs for the first time in the
document. All trademarks and brand names used are property of their respective owners.
The Target User knows how to responsibly make use of this product without causing harm to himself or
others, and without causing damage to systems or devices, in which the user incorporates the product.
Life support systems are equipment intended to support or sustain life, and whose failure to perform,
when properly used in accordance with instructions provided, can be reasonably expected to result in
personal injury or death.
Information given in this document is believed to be accurate and reliable. However, no responsibility
is assumed for the consequences of its use nor for any infringement of patents or other rights of third
parties which may result from its use. Specifications are subject to change without notice.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 110 / 111
or of any other nature are made hereunder with respect to information/specification or the products to
which information refers and no guarantee with respect to compliance to the intended use is given.
In particular, this also applies to the stated possible applications or areas of applications of the product.
TRINAMIC products are not designed for and must not be used in connection with any applications where
the failure of such products would reasonably be expected to result in significant personal injury or death
(safety-Critical Applications) without TRINAMIC’s specific written consent.
TRINAMIC products are not designed nor intended for use in military or aerospace applications or environ-
ments or in automotive applications unless specifically designated for such use by TRINAMIC. TRINAMIC
conveys no patent, copyright, mask work right or other trade mark right to this product. TRINAMIC as-
sumes no liability for any patent and/or other trade mark rights of a third party resulting from processing
or handling of the product and/or any other use of the product.
©2021 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-1638 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.01 • 2021-FEB-05 111 / 111
11 Revision History
11.1 Firmware Revision
©2021 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at www.trinamic.com