User Manual

TMCM-3230 TMCL
Firmware Manual Firmware Version V1.07 | Document Revision V1.05 2017-OCT-10
96 / 103
WAIT POS , Motor0 , 0
17
JA MainLoop
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).
Please see the following example:
1
MyVariable = 42
//Use a symbolic name for the user variable
3
//(This makes the program better readable and understandable .)
5
SGP MyVariable , 2, 1234 // Initialize the variable with the value 1234
...
7
...
GGP MyVariable , 2 //Copy contents of variable to accumulator register
9
CALC MUL , 2 // Multiply accumulator register with two
AAP MyVariable , 2 //Store contents of accumulator register to variable
11
...
...
Furthermore, these variables can provide a powerful way of communication between a TMCL program
running on a module and a host. The host can change a variable by issuing a direct mode SGP command
(remember that while a TMCL program is running direct mode commands can still be executed, without
interfering with the running program). If the TMCL program polls this variable regularly it can react on
such changes of its contents.
The host can also poll a variable using GGP in direct mode and see if it has been changed by the TMCL
program.
©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