User Manual

TMCM-3230 TMCL
Firmware Manual Firmware Version V1.07 | Document Revision V1.05 2017-OCT-10
95 / 103
7 TMCL Programming Techniques and Structure
7.1 Initialization
The rst task in a TMCL program (like in other programs also) is to initialize all parameters where dierent
values than the default values are necessary. For this purpose, SAP and SGP commands are used.
7.2 Main Loop
Embedded systems normally use a main loop that runs innitely. 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 rst does all necessary initializations and then enters
the main loop, which does all necessary tasks end never ends (only when the module is powered o 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
7.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 le 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
©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