User Manual

TMCM-3230 TMCL
Firmware Manual Firmware Version V1.07 | Document Revision V1.05 2017-OCT-10
97 / 103
7.5 Using Subroutines
The CSUB and RSUB commands provide a mechanism for using subroutines. The CSUB command branches
to the given label. When an RSUB command is executed the control goes back to the command that
follows the CSUB command that called the subroutine.
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.
7.6 Combining Direct Mode and Standalone Mode
Direct mode and standalone mode can also be combined. When a TMCL program is being executed in
standalone mode, direct mode commands are also processed (and they do not disturb the ow 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 dened 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 specic 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
©2017 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at www.trinamic.com