
TMCM-1311 TMCL Firmware V1.11 Manual (Rev. 1.17 / 2015-NOV-05)
106
www.trinamic.com
11.6
Mixing Direct Mode and Standalone Mode
Direct mode and stand alone mode can also be mixed. When a TMCL program is being executed in standalone
mode, direct mode commands are also processed (and they do not disturb the flow of the program running
in standalone mode). So, it is also possible to query e.g. the actual position of the motor in direct mode
while a TMCL program is running.
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).
E
XAMPLE
//Jump commands to the TMCL routines
Func1:
JA Func1Start
Func2:
JA Func2Start
Func3:
JA Func3Start
Func1Start: MVP ABS, 0, 1000
WAIT POS, 0, 0
MVP ABS, 0, 0
WAIT POS, 0, 0
STOP
Func2Start: ROL 0, 500
WAIT TICKS, 0, 100
MST 0
STOP
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
function of the TMCL-IDE.
Please refer to the TMCL-IDE User Manual for further information about the TMCL-IDE.