User Manual

PD-x-1670 TMCL
Firmware Manual Firmware Version V2.0 | Document Revision V1.0 2018-Oct-29
75 / 82
11 JA MainLoo p // 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 constan t s
# include TMCLParam . tmc
3 MaxSpeed = 50000
MaxAcc = 10000
5 Position0 = 0
Po s i tion1 = 500000
7
// Initial i z a t ion
9 SAP AP M a x P o s i t i o n i n g S p e e d , Motor0 , MaxSpeed
SAP AP M axAccelerati on , Motor0 , MaxAcc
11
Ma inLoop :
13 MVP ABS , Motor0 , P o sition1
WAIT POS , Motor0 , 0
15 MVP ABS , Motor0 , P o sition0
WAIT POS , Motor0 , 0
17 JA MainLoo p
Have a look at the le TMCLParam.tmc provided with the TMCL-IDE. It contains symbolic constants that
dene 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 denition of the constant and do not have to change all occurrences of it in
your program.
7.4 Using Variables
The user variables can be used if variables are needed in your program. They can store temporary values.
The commands SGP, GGP and AGP as well as STGP and RSGP are used to work with user variables:
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.
The STGP command stores the contents of a user varaible in the EEPROM.
The RSGP command copies the value stored in the EEPROM back to the user variable.
Global parameter 85 controls if user variables will be restored from the EEPROM automatically on
startup (default setting) or not (user variables will then be initialized with 0 instead).
©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany
Terms of delivery and rights to technical change reserved.
Download newest version at www.trinamic.com