Tmcl-Ide Usermanual v201
Tmcl-Ide Usermanual v201
V 2.01
Integrated Development
Environment for TMCL™
(Trinamic Motion
Control Language)
+ +
www.trinamic.com
TMCL-IDE User Manual (V2.01/2011-SEP-14) 2
Table of contents
1 TMCL-IDE: Overview....................................................................................................................................5
2 Installation / getting started ...................................................................................................................6
2.1 Getting started ...................................................................................................................................................... 8
2.2 Writing a simple TMCLTM program .................................................................................................................. 9
3 The File menu ........................................................................................................................................... 10
3.1 New ........................................................................................................................................................................ 10
3.2 Open ...................................................................................................................................................................... 10
3.3 Save, Save as ...................................................................................................................................................... 10
3.4 Save all ................................................................................................................................................................. 10
3.5 Close ...................................................................................................................................................................... 10
3.6 Exit.......................................................................................................................................................................... 10
4 The integrated text editor ..................................................................................................................... 11
5 The TMCL™ menu .................................................................................................................................... 12
5.1 Basics..................................................................................................................................................................... 12
5.2 Direct Mode ......................................................................................................................................................... 13
5.2.1 Assemble a TMCL™ program ................................................................................................................ 14
5.3 Download a TMCL™ program ........................................................................................................................ 15
5.4 Select a main file ............................................................................................................................................... 16
5.5 Run a TMCL™ program .................................................................................................................................... 16
5.6 Stop a TMCL™ program ................................................................................................................................... 16
5.7 Continue a TMCL™ program .......................................................................................................................... 16
5.8 Disassemble a TMCL™ program .................................................................................................................... 17
6 The Setup menu ....................................................................................................................................... 18
6.1 Options dialogue ............................................................................................................................................... 18
6.1.1 Assembler options .................................................................................................................................... 18
6.1.2 Connection options .................................................................................................................................. 19
6.1.3 TMCL™ debugger options ...................................................................................................................... 22
6.1.3.1 Starting the debugger .................................................................................................................................. 23
6.1.3.2 Breakpoints ...................................................................................................................................................... 23
6.1.3.3 The Run/Continue function ......................................................................................................................... 24
6.1.3.4 The Pause function ....................................................................................................................................... 24
6.1.3.5 The Step function .......................................................................................................................................... 24
6.1.3.6 The Animate function................................................................................................................................... 24
6.1.3.7 The Stop/Reset function .............................................................................................................................. 24
6.1.3.8 The Direct Mode function in the debugger ........................................................................................... 25
6.2 Configure .............................................................................................................................................................. 25
6.2.1 RS232/RS485................................................................................................................................................ 25
6.2.2 CAN ................................................................................................................................................................ 26
6.2.3 Drivers .......................................................................................................................................................... 27
6.2.4 Micro stepping (graphical view) ........................................................................................................... 28
6.2.5 Microstepping (table view)..................................................................................................................... 29
6.2.6 Other ............................................................................................................................................................. 30
1 TMCL-IDE: Overview
The TMCL-IDE is an integrated development environment mainly for developing stand-alone TMCL™
applications, but it also includes a function for using the TMCL™ commands in direct mode. The TMCL-IDE
is a PC application running under Windows 95/98/NT/2000/XP/Vista/Windows 7 (Windows 3.x is not
supported) that includes
Please be sure to always use the latest version of the TMCL-IDE as its functionality is being extended
and improved constantly.
1. To install the TMCL-IDE to your computer, just copy the file TMCL.EXE to your hard disk.
Make sure the COM port you intend to use is not blocked by another program. After this double
click the file to start the program.
3. Choose type and COM port with the parameters shown below (baud rate usually 9600).
Click OK. Make sure the COM port is not blocked by another application.
If it is not detected, please check cables, interface, power supply, COM port, and baud rate.
3. Issue a command by choosing Instruction, Type (if necessary), Motor, and Value and click Execute
to send it to the module. The motor will follow the instruction now.
MOTOR NUMBERS:
Motors Motor numbers
one axis 0
two axes 0, 1
three axes 0, 1, 2
six axes 0, 1, 2, 3, 4, 5
Examples:
ROR rotate right, motor 0, value 500 -> Click Execute. The motor is rotating now.
MST motor stop, motor 0 -> Click Execute. The motor stops now.
Assemble
3. Thereafter click the Download icon to download the code to the module.
4. Click the Run icon. The downloaded program will now be executed.
Note: The TMCL-IDE offers other examples, which can be assembled and downloaded for testing
purposes. Open the files with the Open icon.
3.1 New
This function opens a new editor page, so a new file can be created.
3.2 Open
After selecting the Open function a file selection dialog will be shown. Here you can select a file to be
opened. Then, a new editor page opens and the selected file will be loaded into that editor page.
3.5 Close
The Close function closes the actual editor page. This function can also be selected from the context menu
of the editor (click the right mouse button in the editor window to open the context menu).
3.6 Exit
Use this function to close the TMCL-IDE. The same function can be achieved by closing the main window.
- If the type of the module cannot be detected (e.g. because there is no module connected), a
little dialogue pops up where you are prompted to select your module type. Do this by
choosing the appropriate module type and click OK.
- If a module is not detected automatically the communication is not established. Please check
cables, interface, COM port, and power supply again.
By using the direct mode you can send commands to a module that are executed immediately. In the
TMCL™ Instruction Selector area you can select a command and its parameters. Click the Execute button in
this area to send the command to the module. The response will be displayed in the Answer section. By
clicking the Copy to editor button the command mnemonic will be copied to the TMCL™ editor.
You can also enter the instruction numbers directly in the Manual Instruction Input area and execute them
by clicking the appropriate Execute button (but this option is needed only very seldom). The Copy button
in the TMCL™ Instruction Selector area copies the instruction bytes to the Manual Instruction Input area.
If an error occurs, the line containing the error will be highlighted and the assembly will be aborted. The
error message will be displayed in the assembler progress dialog.
You can click on the Clear button in the Select Main TMCL™ File dialog to switch off the function and to
assemble always the currently selected editor file.
Assemble
The progress of downloading the program from the module and the disassembly is shown in special
windows. It can be aborted by clicking the Abort button.
The Setup Menu provides tools for the basic configuration of your module:
The Assembler tab in the Options dialogue provides the following assembler options:
After you have selected RS232/RS485 the COM port that is to be used, the baud rate and the module
address can be set.
If you do not know the address of the connected module, just click the Search button. The Search function
provides the address search dialogue. Here, just click the Start button. Now, every address (1… 255) will be
tried out. You can abort the progress by clicking the Stop button.
Please note that RS485 adapters where the data direction is controlled by the RTS line of the COM port do
not work with Windows 95, Windows 98 or Windows ME (due to a bug in these operating systems). They
can only be used with Windows NT4, Windows 2000 or Windows XP or Vista and also with these
operating systems there may be the problem that switching back to receive takes place too late. It is
recommended to use the TRINAMIC USB-2-485 instead.
Debugger
Stop
on/off
After these two preconditions have been verified you can start the debugger either by selecting the
function Debugger active in the Debug menu or by clicking the Debugger icon on the tool bar. After the
debugger has been successfully started, the debugger functions will be enabled and most other functions
of the TMCL-IDE will be disabled (now it is not possible to change the program in the editor).
You can exit the debugger by clicking Debugger active in the Debug menu or the Debugger icon on the
tool bar once again. Then, all debugger functions will be disabled and all other functions of the TMCL-IDE
will be enabled again.
6.1.3.2 Breakpoints
Breakpoints can be set or removed by clicking the appropriate line on the left breakpoint bar of the editor.
A blue bullet is displayed in every line where a breakpoint can be set. When a breakpoint is set a red
bullet with a green tick is displayed in that line.
When a program is run either by the Run or by the Animate function of the debugger it will be stopped
when a breakpoint is reached. It can be continued by clicking Run, Animate or Step again. It can also be
reset by clicking Stop/Reset, so that it can be restarted form the beginning again.
If you wish to restart the program from the very beginning, select the Stop/Reset function before clicking
Run/Continue.
The program will be paused when running into a breakpoint or when the Pause function is selected.
Program execution can be continued either by the Run/Continue, the Animate or the Step function.
This function can also be used when the program execution is paused (by a breakpoint or by the Pause
function) to reset it and ensure that the program can be started again from the beginning.
Please refer to paragraph 5.2 for further information about TMCL™ direct mode.
6.2 Configure
This function provides a dialogue for changing the configuration (global parameters) of a module.
6.2.1 RS232/RS485
Here, you can change the send address, the receive addresses and the baud rate of the serial interface of a
module. Just set the desired value and then click on the appropriate Apply button to send the new setting
to the module. Be careful, as most changes take effect immediately.
6.2.2 CAN
This page provides the settings of the CAN interface of a module. The usage is the same as with the
RS232/RS485 page.
6.2.3 Drivers
This page allows changing the settings for the SPI driver chain. See the TMC428 / TMC429 datasheets for
details. Normally these settings must not be changed!
It is only necessary to change the settings for the SPI driver chain on TMCM-301 and TMCM-341 modules if
you prefer other motor drivers than TMC239, TMC249 or the TMCM-035 module.
When programming user specific driver configuration chain tables please disable the automatic mixed
decay handling for TMC236 drivers, the automatic full step switching and the freewheeling function first
(axis parameters 203, 204 and 211). This is needed because these functions modify the driver configuration
table.
When clicking the Calculate button a waveform will be calculated in the same manner as in the graphical
view of the microstepping function. This can be used as a basis of a table that can then be fine tuned
manually.
6.2.6 Other
This page provides the Firmware Revision, the Configuration EEPROM, and the TMCL™ auto start.
1. Firmware revision:
Click the Get button in the Firmware Revision section to read the firmware revision of a module.
The result will be displayed beside the Get button.
2. Configuration EEPROM:
Here you can lock or unlock the configuration EEPROM. When the configuration EEPROM is locked,
STAP and STGP commands do not have any effect so that the settings stored in the configuration
EEPROM cannot be changed by accident. The buttons in the Configuration EEPROM section provide
the following functionality:
Get State: Click this button to see if the configuration EEPROM is locked. The state will then be
displayed beside the button.
Restore Factory Default: Clicking this button will restore all settings stored in the configuration
EEPROM to their factory defaults and then reset the module. Please use this function with extreme
care. If this function should not work, try to use the hardware reset option of the module.
6.3 Install OS
By using this function you can update the firmware of a module. First, load the new firmware file (which
must be in Intel-HEX format) by clicking the Load button. The file is then checked if it is a TMCL™ firmware
file, and its device type and version number will be displayed. Then, click the Start button to program the
new firmware into the module. Please make sure that there will be no power cut or cut of the serial
connection during the programming process. The program checks if the device type in the firmware file
and the device type of the module are identical. An error message will be displayed if this is not the case.
If everything is okay, the new firmware will be programmed into the module and verified afterwards. The
programming progress is shown by a status bar.
The stallGuard™ adjusting tool helps to find the necessary motor parameters when stallGuard™ is to be
used. This function can only be used when a module is connected that features stallGuard™. This will be
automatically checked when the stallGuard™ adjusting tool is selected in the Setup menu. If the test is
carried out successfully the stallGuard™ adjusting tool will be displayed.
The commands which are necessary for setting the chosen values (entered in this dialogue) are displayed
in the Commands area at the bottom of the window. They can be selected, copied and pasted into the
TMCL™ editor.
The stallGuard™ profiler is a utility that helps you to find the best parameters for using stall detection. It
scans through given velocities and shows which velocities are the best ones. Similar to the stallGuard™
adjusting tool it can only be used together with a module that supports stallGuard™. This is checked right
after the stallGuard™ profiler has been selected in the Setup menu. After this has been successfully
checked the stallGuard™ profiler window will be shown.
The standard deviation is very low or zero. This means that there is effectively no vibration at this
velocity.
The red color means that there is high vibration at that velocity.
Yellow: This color means that there might be some low vibration at this velocity.
Velocities shown in yellow can also be used, but with care as they might cause problems (maybe the
motor stops even if it is not stalled).
Velocities shown in red should not be chosen. Because of vibration the load value is often unpredictable
and so not usable to achieve good results when using stall detection.
As it is very seldom that exactly the same result is produced when recording a profile with the same
parameters a second time, always two or more profiles should be recorded and compared against each
other.
The stallGuard2™ & coolStep™ Adjusting Tool helps to find necessary motor parameter adjustments when
stallGuard2™ and coolStep™ are to be used. These functions are only provided when a module is
connected that features stallGuard2™ and coolStep™ (modules equipped e.g. with TMC260, TMC261,
TMC262, and TMC389). This will be automatically checked when the stallGuard2™ & coolStep™ Adjusting
Tool is selected in the Setup menu. If the test is carried out successfully the tool will be displayed.
There are four tabs which concern different aspects of the features:
- motor
- stallGuard2™
- coolStep™
- TMCL™ code
The stallGuard2™ & coolStep™ Adjusting Tool of the TMCL-IDE provides an interactive way for adjusting
the module. All settings which have been tried out with the help of the stallGuard2™ tab and the
coolStep™ tab are immediately represented as TMCL™ mnemonics on the TMCL™ code tab.
stallGuard2™ and coolStep™ parameters have to be adjusted with a special command of the TMCL-IDE, the
SAP (set axis parameter) command. 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. For storing any setting permanently, please use command STAP
(store axis parameter). If you want to read out your parameter calibrations, use the GAP command. Please
refer to the special TMCL™ Firmware Manual for your module for further information about writing TMCL™
commands.
ROR (rotate right): With this command the motor will be instructed to rotate with a specified velocity in
right direction (increasing the position counter). Please specify the velocity in the Velocity field.
ROL (rotate left): With this command the motor will be instructed to rotate with a specified velocity
(opposite direction compared to ROR, decreasing the position counter). Please specify the velocity in the
Velocity field.
MST (motor stop): With this command the motor will be instructed to stop. (Depending on the motor
speed a hard stop might lead to step losses.)
SAP (set axis parameter): With this command most of the motion control parameters of the module can be
specified. On the Motor tab, the acceleration (axis parameter 5) is set. Just fill in the Acceleration field.
All settings will be represented as mnemonics on the TMCL™ code tab immediately.
Realize that every change of parameters bases on the SAP (Set Axis Parameter) command of the TMCL-IDE.
Please refer to the TMCL™ Firmware Manual of your module and read more about this command. A short
information is given in the beginning of this chapter (6.6 stallGuard2™ & coolStep™ adjusting tool).
All chosen settings will be shown immediately as graphical view on the Current and Load Display and as
mnemonics on the TMCL™ code tab.
For changing parameter values write your chosen value in the specific value field und click the Apply
button afterwards. It is possible to change several parameter values before clicking the Apply button, but
we recommend trying out new adjustments step by step for a better screening of their effects.
0 Indifferent value
1… 63 less sensitivity
-1… -64 higher sensitivity
The Current & Load Display shows the applied changes of parameter values immediately. Certainly, every
change of parameters will be documented as written TMCL™ commands on the TMCL™ code tab.
Realize that every change of parameters bases on the SAP (Set Axis Parameter) command of the TMCL-IDE.
Please refer to the TMCL™ Firmware Manual of your module and read more about this command. A short
information is given in the beginning of this chapter (6.6 stallGuard2™ & coolStep™ adjusting tool).
All chosen settings will be shown immediately as graphical view on the Current and Load Display and as
mnemonics on the TMCL™ code tab.
For changing parameter values write your chosen value in the specific value field und click the Apply
button afterwards. It is possible to change several parameter values before clicking the Apply button, but
we recommend trying out new adjustments step by step for a better screening of their effects.
Hysteresis:
(smartEnergy hysteresis value + 1) * 32
Refer to the specific TMCL™ Firmware Manual for your TMCM module, too. Here you will find detailed
information about e.g. the Set Axis Parameter command, special parameters and their ranges for your
TMCM module. Here, only basic parameters for coolStep™ and stallGuard2™ are mentioned.
Use the commands in the text box for drawing up your TMCL™ program in the editor:
Mark the interesting lines, click the Copy button, close the window, and paste the chosen commands in
the editor. Add all commands you need.
One parameter calculation tool for all TMC428 / TMC429 based modules.
Another parameter calculation tool for the TMCM-100 module and the MONOpack 2, which are
TMC453 based.
You can choose the tool by selecting the appropriate tab page in the parameter calculation dialogue.
Always be sure to use the right one. In case of doubt please refer to your Hardware Manual.
To use the calculation tool, just fill in the values that are known and then click the Calculate button. After
changing any parameter always click it again. When a parameter in the TMCL™ section has been changed
the physical units will be recalculated with the next click on the Calculate button. When a parameter in the
physical units section has been changed the TMCL™ parameters will be recalculated with the next click on
the Calculate button also.
Example:
#include test.tmc
<Name>=<Value>
A Name must always start with a letter or the sign _ and may then contain any combination of letters,
numbers and the sign _.
A Value must always be a decimal, hexadecimal or binary number or a constant expression. Hexadecimal
numbers start with a $ sign, binary numbers start with a % sign.
Examples:
Speed=1000
Speed2=Speed/2
Mask=$FF
Binary Value=%1010101
Internally, the assembler uses floating point arithmetic to evaluate a constant expression, but as TMCL™
commands only take integer values, the result of a constant expression will always be rounded to an
integer value when used as an argument to a TMCL™ command.
Name Function
SIN Sinus
COS Cosinus
TAN Tangens
ASIN Arcus Sinus
ACOS Arcus Cosinus
ATAN Arcus Tangens
LOG Logarithm Base 10
LN Logarithm Base e
EXP Power to Base e
SQRT Square root
ABS Absolute value
INT Integer (truncate)
ROUND Integer (Round)
SIGN Returns
-1 if argument<1,
0 if argument=0
1 if argument>0
DEG Converts from radiant to degrees
RAD Converts from degrees to radiant
Symbol Meaning
() Parenthesis
^ Power
* Multiplication
/ Division
+ Addition
- Subtraction
Symbolic constants, floating point numbers, integer numbers, hexadecimal numbers and binary numbers
can also be used in constant expressions.
Here are some examples of constant expressions used wherever constant values can be placed:
ROL 0, 7+9*8
Speed2=Speed*SIN(0.5)
MVP ABS, 0, 3*1000
Sin90=Sin(Rad(90))
7.4 Labels
Labels have the form following form:
<Name>:
The same rules are valid for label names as for symbolic constants.
7.5 Comments
Comments always start with // (like in C++). The rest of the line is then ignored.
With:
<n1>, <n2>, <n3>: Any numerical value, constant expression or symbolic constant
<mvp_opt>: An option for MVP: ABS, REL or COORD.
<rfs_opt>: An option for RFS: START, STOP or STATUS.
<cc>: A condition code: ZE, NZ, EQ, NE, GT, GE, LT, LE, ETO, EAL, EDV, EPO.
<Event>: A wait event. This can be TICKS, POS, LIMSW, REFSW or RFS.
<op1>: An operator for the CALC command: ADD,SUB,MUL,DIV,MOD,AND,OR,NOT,LOAD
<op2>: An operator for the CALCX command: ADD,SUB,MUL,DIV,MOD,AND,OR,NOT,LOAD,SWAP
<Label>: A label defined somewhere else in the program.
<Flag>: An error flag code: ALL, ETO, EAL, EDV or EPO.
<Interrupt number>:
8.1 Initialization
The first task in a TMCL™ program (like in other programs also) is to initialize all parameters where
different values than the default values are necessary. For this purpose, SAP and SGP commands are used.
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
SAP 4, 0, 500 //define max. positioning speed
SAP 5, 0, 100 //define max. acceleration
MainLoop:
//do something, in this example just running between two positions
MVP ABS, 0, 5000
WAIT POS, 0, 0
MVP ABS, 0, 0
WAIT POS, 0, 0
JA MainLoop //end of the main loop => run infinitely
Example:
//Initialization
SAP APMaxPositioningSpeed, Motor0, MaxSpeed
SAP APMaxAcceleration, Motor0, MaxAcc
MainLoop:
MVP ABS, Motor0, Position1
WAIT POS, Motor0, 0
MVP ABS, Motor0, Position0
WAIT POS, Motor0, 0
JA MainLoop
Just have a look at the file TMCLParam.tmc provided with the TMCL-IDE. It contains symbolic constants
that define all important parameter numbers.
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.
Example:
MyVariable = 42
//Use a symbolic name for the user variable
//(This makes the program better readable and understandable.)
SGP MyVariable, 2, 1234 //Initialize the variable with the value 1234
...
...
GGP MyVariable, 2 //Copy the contents of the variable to the
accumulator register
CALC MUL, 2 //Multiply accumulator register with two
AAP MyVariable, 2 //Store contents of the accumulator register to the
variable
...
...
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.
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:
Func3Start:
ROR 0, 1000
WAIT TICKS, 0, 700
MST 0
STOP
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 (chapter 6.1.1) function of the TMCL-IDE.
9 Revision history
9.1 Document revision
Version Date Author Description
1.00 OK Initial Release as a chapter of the TMCL™ reference and programming
manual
2.00 2009-JUL-30 SD New version as self-contained TMCL™ User Manual
2.01 2011-SEP-14 SD Chapter 6.6 (stallGuard2™ and coolStep™) added, minor changes
Table 9.1: Document revision