TMCM-1021 TMCL
™
Firmware Manual • Firmware Version V1.42 | Document Revision V1.10 • 2018-JAN-09
100 / 109
8
TMCL Programming Techniques and Structure
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.
8.2
Main Loop
Embedded systems normally use a main loop that runs infinitely. This is also the case in a TMCL application
that is running stand alone. Normally the auto start mode of the module should be turned on. After power
up, the module then starts the TMCL program, which first does all necessary initializations and then enters
the main loop, which does all necessary tasks end never ends (only when the module is powered off or
reset).
There are exceptions to this, e.g. when TMCL routines are called from a host in direct mode.
So most (but not all) stand alone TMCL programs look like this:
1
// Initialization
SAP 4, 0, 50000
// define maximum positioning speed
3
SAP 5, 0, 10000
// define maximum acceleration
5
MainLoop :
// do something , in this example just running between two positions
7
MVP ABS , 0, 5000
WAIT POS , 0, 0
9
MVP ABS , 0, 0
WAIT POS , 0, 0
11
JA MainLoop
// end of the main loop => run infinitely
8.3
Using Symbolic Constants
To make your program better readable and understandable, symbolic constants should be taken for all
important numerical values that are used in the program. The TMCL-IDE provides an include file with
symbolic names for all important axis parameters and global parameters. Please consider the following
example:
1
// Define some constants
# include
TMCLParam . tmc
3
MaxSpeed = 50000
MaxAcc = 10000
5
Position0 = 0
Position1 = 500000
7
// 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
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at