1 Features ........................................................................................................................................................................... 4
3 Putting the TMCM-1640 into Operation .................................................................................................................. 6
3.1 Starting up ............................................................................................................................................................. 6
3.2 Operating the Module in Direct Mode ........................................................................................................... 9
4.1 Binary Command Format ................................................................................................................................ 10
4.2 Reply Format ....................................................................................................................................................... 11
4.2.1 Status Codes ................................................................................................................................................. 11
4.5.3 Control Commands ..................................................................................................................................... 13
4.5.4 I/O Port Commands .................................................................................................................................... 13
4.6.17 JA (jump always).......................................................................................................................................... 31
4.6.18 CSUB (call subroutine) and RSUB (return from subroutine) ........................................................... 32
4.6.19 WAIT (wait for an event to occur) ......................................................................................................... 33
4.6.20 STOP (stop TMCL program execution) ................................................................................................... 34
4.6.21 CALCX (calculate using the X register) .................................................................................................. 35
4.6.22 AAP (accumulator to axis parameter) .................................................................................................... 36
4.6.23 AGP (accumulator to global parameter) ............................................................................................... 37
5.1 Axis Parameter Sorted by Functionality ...................................................................................................... 43
6 Global Parameter Overview (SGP, GGP, STGP, RSGP) ....................................................................................... 47
6.1 Bank 0 ................................................................................................................................................................... 47
6.2 Bank 2 ................................................................................................................................................................... 48
7 Motor Regulation ........................................................................................................................................................ 49
7.1 Structure of the Cascaded Motor Regulation Modes............................................................................... 49
7.2 Current Regulation ............................................................................................................................................ 50
7.5 Position Regulation ........................................................................................................................................... 52
8 Temperature Calculation........................................................................................................................................... 54
10 Life Support Policy ..................................................................................................................................................... 55
11 Revision History .......................................................................................................................................................... 56
The TMCM-1640 is a highly compact controller/driver module for brushless DC (BLDC) motors with up to 5A
coil current, optional encoder and/or hall sensor feedback. For communication the module offers RS485 and
(mini-)USB interface.
Applications
- Compact single-axis brushless DC motor solutions
Electrical data
- Supply voltage: +24V DC nom. (+12V… +28.5V DC)
- Motor current: up to 5A RMS (programmable)
Integrated motion controller
- High performance microcontroller for system control and communication protocol handling
Integrated driver
- High performance integrated pre-driver (TMC603)
- High-efficient operation, low power dissipation (MOSFETs with low R
- Dynamic current control
- Integrated protection
Interfaces
- USB (mini-USB, full speed (12Mbit/s)) serial communication interface
- RS485 serial communication interface
- Hall sensor interface (+5V TTL or open-collector signals)
- Encoder interface (+5V TTL or open-collector signals)
- General purpose inputs (2x digital (+5V / +24V compatible), 1x analogue (+0… +10V)
- 1 general purpose output (open-drain)
Software
- Available with TMCL
- Standalone operation or remote controlled operation
- Program memory (non volatile) for up to 2048 TMCL commands
- PC-based application development software TMCL-IDE
- PC-based control software TMCM-BLDC for initial adjustments
The software running on the microprocessor of the TMCM-1640 consists of two parts, a boot loader and the
firmware itself. Whereas the boot loader is installed during production and testing at TRINAMIC and remains
– normally – untouched throughout the whole lifetime, the firmware can be updated by the user. New
versions can be downloaded free of charge from the TRINAMIC website (http://www.trinamic.com).
The firmware is related to the standard TMCL firmware with regard to protocol and commands. The module
is based on the ARM Cortex-M3 microcontroller and the high performance pre-driver TMC603 and supports
the standard TMCL with a special range of values.
The new FOC firmware V2.0 is field oriented control software for brushless DC applications. It is developed
for high-performance motor applications which can operate smoothly over the full velocity range, can
generate full torque at zero speed and is capable of fast acceleration and deceleration. This saves energy
and quiets rotating machinery.
Here you can find basic information for putting your module into operation. The text contains a simple
example for a TMCL program and a short description of operating the module in direct mode.
THINGS YOU NEED:
- TMCM-1640
- USB interface and appropriate cable or RS485 interface / adapter and appropriate cable
- Nominal supply voltage +24V DC (+12… +28.5V DC) for your module with sufficient output filtering
(to be sure add e.g. 2200µF capacitor close to power supply input of module)
- BLDC motor, e.g. one of TRINAMICs QBL4208 motors
- Encoder optional
- TMCL-IDE program and PC
PRECAUTIONS
- Do not mix up connections or short-circuit pins.
- Avoid bounding I/O wires with motor power wires as this may cause noise picked up from the motor supply.
- The power supply has to be buffered by a capacitor. Otherwise the module will be damaged!
- Do not exceed the maximum power supply of 28.5V DC.
- Do not connect or disconnect the motor while powered!
- Start with power supply OFF!
3.1 Starting up
The following figure shows how the connectors have to be used.
a) keep power supply cables as short as possible
b) use cables with large diameters for power supply cables
c) add 2200µF or larger filter capacitors near the motor driver unit especially if the distance to
the power supply is large (i.e. more than 2-3m)
6. Connect the power supply as follows:
Please note, that there is no protection against reverse polarity and only limited protection
against voltages above the upper maximum limit. The power supply typically should be within
a range of +12 to +28.5V.
When using supply voltages near the upper limit, a regulated power supply is mandatory. Please
ensure that enough power filtering capacitors are available in the system (2200µF or more
recommended) in order to absorb energy fed back by the motor while the motor is decelerating and
in order to prevent any voltage surge e.g. during power-on (especially with longer power supply
cables as there are only ceramic filter capacitors on-board). In larger systems an additional external
zener/suppressor diode with adequate voltage rating might be necessary in order to limit the
maximum voltage.
To ensure reliable operation of the unit, the power supply has to have a sufficient output capacitor
and the supply cables should have a low resistance, so that the chopper operation does not lead to
an increased power supply ripple directly at the unit. Power supply ripple due to the chopper
operation should be kept at a maximum of a few 100mV
7. Switch ON the power supply
The power LED glows now. If this does not occur, switch power OFF and check your connections as
well as the power supply.
8. Start the TMCL-IDE software development environment
The TMCL-IDE is available on www.trinamic.com.
Installing the TMCL-IDE
Make sure the COM port you intend to use is not blocked by another program.
Open TMCL-IDE by clicking TMCL.exe.
PROCEED AS FOLLOWS:
Choose Setup and Options as shown in Figure 3.1.
Choose the Connection tab.
Choose Type.
The TMCL-IDE shows you which Port the module uses.
Click OK.
Figure 3.1: Setup menu Figure 3.2: Connection tab of TMCL-IDE
3.2 Operating the Module in Direct Mode
Start TMCL Direct Mode.
If the communication is established the TMCM-1640 is automatically detected. If the module is not detected,
please check all points above (cables, interface, power supply, COM port, baud rate).
Issue a command by choosing Instruction, Type (if necessary), Motor, and Value and click Execute to send
it to the module.
Examples:
ROR rotate right, motor 0, value 500 -> Click Execute. The first motor is rotating now.
MST motor stop, motor 0 -> Click Execute. The first motor stops now.
The TMCM-1640 module supports TMCL direct mode and standalone TMCL program execution. You can store
up to 2048 TMCL instructions on it.
In direct mode the TMCL communication over USB/RS485 follows a strict master/slave relationship. That is, a
host computer (e.g. PC/PLC) acting as the interface bus master will send a command to the module. The
TMCL interpreter on it will then interpret this command, do the initialization of the motion controller, read
inputs and write outputs or whatever is necessary according to the specified command. As soon as this step
has been done, the module will send a reply back over USB/RS485 to the bus master. The master should not
transfer the next command till then. Normally, the module will just switch to transmission and occupy the
bus for a reply, otherwise it will stay in receive mode. It will not send any data over the interface without
receiving a command first. This way, any collision on the bus will be avoided when there are more than
two nodes connected to a single bus.
The Trinamic Motion Control Language (TMCL) provides a set of structured motion control commands. Every
motion control command can be given by a host computer or can be stored on the TMCM-1640 to form
programs that run standalone on the module.
Every command has a binary representation and a mnemonic:
- The binary format is used to send commands from the host to a module in direct mode.
- The mnemonic format is used for easy usage of the commands when developing standalone TMCL
applications with the TMCL-IDE (IDE means Integrated Development Environment).
There is also a set of configuration variables for the axis and for global parameters which allow individual
configuration of nearly every function of a module. This manual gives a detailed description of all TMCL
commands and their usage.
4.1 Binary Command Format
When commands are sent from a host to a module, the binary format has to be used. Every command
consists of a one-byte command field, a one-byte type field, a one-byte motor/bank field and a four-byte
value field. So the binary representation of a command always has seven bytes.
When a command is to be sent via USB interface, it has to be enclosed by an address byte at the beginning
and a checksum byte at the end. In this case it consists of nine bytes.
The binary command format for USB and RS485 is structured as follows:
As mentioned above, the checksum is calculated by adding up all bytes (including the module address byte)
using 8-bit addition. Here is an example for the calculation:
in C:
unsigned char i, Checksum;
unsigned char Command[9];
//Set the “Command” array to the desired command
Checksum = Command[0];
for(i=1; i<8; i++)
Checksum+=Command[i];
Command[8]=Checksum; //insert checksum as last byte of the command
//Now, send the command back to the module
4.2 Reply Format
Every time a command has been sent to a module, the module sends a reply.
The reply format for USB and RS485 is structured as follows:
- The checksum is also calculated by adding up all the other bytes using an 8-bit addition.
- Do not send the next command before you have received the reply!
4.2.1 Status Codes
The reply contains a status code.
The status code can have one of the following values:
Loop:
ROL 0, 4000 //rotate left with 4000 rpm
WAIT TICKS, 0, 2000
ROR 0, 4000 //rotate right with 4000 rpm
WAIT TICKS, 0, 2000
JA Loop
4.3 Standalone Applications
The module is equipped with an EEPROM for storing TMCL applications. You can use the TMCL-IDE for
developing standalone TMCL applications. You can load your program down into the EEPROM and then it
will run on the module. The TMCL-IDE contains an editor and a TMCL assembler where the commands can
be entered using their mnemonic format. They will be assembled automatically into their binary
representations. Afterwards this code can be downloaded into the module to be executed there.
4.4 Testing with a Simple TMCL Program
Open the file test2.tmc of the TMCL-IDE. The following source code appears on the screen:
Figure 4.1: Assemble, download, stop, and run icons of TMCL-IDE
Click on icon Assemble to convert the TMCL example into binary code.
Then download the program to the TMCM-1640 module via the icon Download.
Press icon Run. The desired program will be executed.
Click Stop button to stop the program.
For further information about the TMCL-IDE and TMCL programming techniques please refer to the TMCL-IDE
User Manual on TRINAMICs website.
TRINAMIC offers two software tools for BLDC applications: the TMCM-BLDC and the BLDC tool of the
TMCL-IDE. Whereas the TMCM-BLDC is used for testing different configurations in all modes of
operation the TMCL-IDE is mainly designed for conceiving programs and firmware updates. New
versions of the TMCM-BLDC and the TMCL-IDE can be downloaded free of charge from the TRINAMIC
website (http://www.trinamic.com).
The following section provides a short overview of the TMCL commands supported by the TMCM-1640.
4.5.1 Motion Commands
These commands control the motion of the motor. They are the most important commands and can be used
in direct or in standalone mode.
4.5.2 Parameter Commands
These commands are used to set, read and store axis parameters or global parameters. Axis parameters can
be set independently for the axis, whereas global parameters control the behavior of the module itself.
These commands can also be used in direct mode and in standalone mode.
4.5.3 Control Commands
These commands are used to control the program flow (loops, conditions, jumps etc.) in standalone mode,
only.
4.5.4 I/O Port Commands
These commands control the external I/O ports and can be used in direct mode and in standalone mode.
Calculate using the accumulator and a constant value
CALCX
33
Calculate using the accumulator and the X register
AAP
34
Copy accumulator to an axis parameter
AGP
35
Copy accumulator to a global parameter
4.5.5 Calculation Commands
These commands are intended to be used for calculations within TMCL applications in standalone mode,
only. For calculating purposes there are an accumulator (or accu or A register) and an X register. When
executed in a TMCL program (in standalone mode), all TMCL commands that read a value store the result in
the accumulator. The X register can be used as an additional memory when doing calculations. It can be
loaded from the accumulator.
MIXING STANDALONE PROGRAM EXECUTION AND DIRECT MODE
It is possible to use some commands in direct mode while a standalone program is active. When a
command which reads out a value is executed (direct mode) the accumulator will not be affected. While a
TMCL program is running standalone on the module, a host can still send commands like GAP and GGP to it
(e.g. to query the actual position of the motor) without affecting the flow of the TMCL program running
standalone on the module.
The motor will be instructed to move to a specified relative or absolute position. It uses the
acceleration/deceleration ramp and the positioning speed programmed into the unit. This command is nonblocking (like all commands). A reply will be sent immediately after command interpretation. Further
commands may follow without waiting for the motor reaching its end position. The maximum velocity and
acceleration are defined by axis parameters #4 and #11.
TWO OPERATION TYPES ARE AVAILABLE:
- Moving to an absolute position in the range from -2147483648… +2147483647.
- Starting a relative movement by means of an offset to the actual position. In this case, the new
resulting position value must not exceed the above mentioned limits, too.
Internal function: A new position value is transferred to the axis parameter #0 target position.
Most of the motion control parameters of the module can be specified by using the SAP command. The
settings will be stored in SRAM and therefore are volatile. Thus, information will be lost after power off.
Please use command STAP (store axis parameter) in order to store any setting permanently.
Related commands: GAP, STAP, and RSAP
Mnemonic: SAP <parameter number>, 0, <value>
Binary representation:
Reply in direct mode:
A list of all parameters which can be used for the SAP command is shown in section 5.
The STAP command stores an axis parameter previously set with a Set Axis Parameter command (SAP)
permanently. Most parameters are automatically restored after power up.
Internal function: An axis parameter value stored in SRAM will be transferred to EEPROM and loaded from
EEPORM after next power up.
Related commands: SAP, RSAP, and GAP
Mnemonic: STAP <parameter number>, 0
Binary representation:
* The value operand of this function has no effect. Instead, the currently used value (e.g. selected by SAP) is saved.
Reply in direct mode:
A list of all parameters which can be used for the STAP command is shown in section 5.
Example:
Store the maximum speed
Mnemonic: STAP 4, 0
Binary:
Note: The STAP command will not have any effect when the configuration EEPROM is locked. The error
code 5 (configuration EEPROM locked) will be returned in this case.
For all configuration related axis parameters non-volatile memory locations are provided. By default, most
parameters are automatically restored after power up. A single parameter that has been changed before can
be reset by this instruction also.
Internal function: The specified parameter is copied from the configuration EEPROM memory to its RAM
location.
Related commands: SAP, STAP, and GAP
Mnemonic: RSAP <parameter number>, 0
Binary representation:
Reply in direct mode:
A list of all parameters which can be used for the RSAP command is shown in section 5.
Global parameters are related to the host interface, peripherals or other application specific variables. The
different groups of these parameters are organized in banks to allow a larger total number for future
products. Currently, only bank 0 and 1 are used for global parameters, and only bank 2 is intended to use
for user variables.
All global parameters can be read with this function.
Related commands: SGP, STGP, RSGP
Mnemonic: GGP <parameter number>, <bank number>
Binary representation:
Reply in direct mode:
A list of all parameters which can be used for the GGP command is shown in section 6.
Example:
Get variable 0 from bank 2
Mnemonic: GGP, 0, 2
Binary:
4.6.11 STGP (store global parameter)
Some global parameters are located in RAM memory, so modifications are lost at power down. This
instruction copies a value from its RAM location to the configuration EEPROM and enables permanent
storing. Most parameters are automatically restored after power up.
Related commands: SGP, GGP, RSGP
Mnemonic: STGP <parameter number>, <bank number>
Binary representation:
Reply in direct mode:
A list of all parameters which can be used for the STGP command is shown in section 6.
Example:
Copy variable 0 at bank 2 to the configuration EEPROM
Mnemonic: STGP, 0, 2
This instruction copies a value from the configuration EEPROM to its RAM location and so recovers the
permanently stored value of a RAM-located parameter. Most parameters are automatically restored after
power up.
Related commands: SGP, GGP, STGP
Mnemonic: RSGP <parameter number>, <bank number>
Binary representation:
Reply in direct mode:
A list of all parameters which can be used for the RSGP command is shown in section 6.
Example:
Copy variable 0 at bank 2 from the configuration EEPROM to the RAM location
Mnemonic: RSGP, 0, 2
GIO can be used in direct mode or in standalone mode.
GIO IN STANDALONE MODE
In standalone mode the requested value is copied to the accumulator (accu) for further processing purposes
such as conditioned jumps.
GIO IN DIRECT MODE
In direct mode the value is output in the value field of the reply without affecting the accumulator. The
actual status of a digital output line can also be read.
0 ADD – add to accu
1 SUB – subtract from accu
2 MUL – multiply accu by
3 DIV – divide accu by
4 MOD – modulo divide by
5 AND – logical and accu with
6 OR – logical or accu with
7 XOR – logical exor accu with
8 NOT – logical invert accu
9 LOAD – load operand to accu
don’t care
<operand>
Byte Index
0 1 2 3 4 5 6
7
Function
Target-
address
Instruction
Number
Type
Motor/
Bank
Operand
Byte3
Operand
Byte2
Operand
Byte1
Operand
Byte0
Value (hex)
$01
$13
$02
$00
$FF
$FF
$EC
$78
4.6.14 CALC (calculate)
A value in the accumulator variable, previously read by a function such as GAP (get axis parameter), can be
modified with this instruction. Nine different arithmetic functions can be chosen and one constant operand
value must be specified. The result is written back to the accumulator, for further processing like
comparisons or data transfer.
Related commands: CALCX, COMP, JC, AAP, AGP, GAP, GGP, GIO
The specified number is compared to the value in the accumulator register. The result of the comparison can
be used for example by the conditional jump (JC) instruction. This command is intended for use in
standalone operation, only. The host address and the reply are required to take the instruction to the TMCL
program memory while the TMCL program downloads. It does not make sense to use this command in
direct mode.
Internal function: The specified value is compared to the internal accumulator, which holds the value of a
preceding get or calculate instruction (see GAP/GGP/CALC/CALCX). The internal arithmetic status flags are set
according to the comparison result.
Related commands: JC (jump conditional), GAP, GGP, CALC, CALCX
Mnemonic: COMP <value>
Binary representation:
Example:
Jump to the address given by the label when the position of the motor #0 is greater or equal to
1000.
GAP 1, 0, 0 //get axis parameter, type: no. 1 (actual position), motor: 0, value: 0 don’t care
COMP 1000 //compare actual value to 1000
JC GE, Label //jump, type: 5 greater/equal, the label must be defined somewhere else in the
0 ZE - zero
1 NZ - not zero
2 EQ - equal
3 NE - not equal
4 GT - greater
5 GE - greater/equal
6 LT - lower
7 LE - lower/equal
8 ETO - time out error
9 EAL - external alarm
don’t care
<jump address>
Byte Index
0 1 2 3 4 5 6
7
Function
Target-
address
Instruction
Number
Type
Motor/
Bank
Operand
Byte3
Operand
Byte2
Operand
Byte1
Operand
Byte0
Value (hex)
$01
$15
$05
$00
$00
$00
$00
$0a
4.6.16 JC (jump conditional)
The JC instruction enables a conditional jump to a fixed address in the TMCL program memory, if the
specified condition is met. The conditions refer to the result of a preceding comparison. This function is for
standalone operation only. The host address and the reply are required to take the instruction to the TMCL
program memory while the TMCL program downloads. It is not possible to use this command in direct
mode.
Internal function: The TMCL program counter is set to the passed value if the arithmetic status flags are in
the appropriate state(s).
Related commands: JA, COMP, WAIT
Mnemonic: JC <condition>, <label>
where <condition>=ZE|NZ|EQ|NE|GT|GE|LT|LE|ETO|EAL
Binary representation:
Example:
Jump to address given by the label when the position of the motor is greater than or equal to 1000.
GAP 1, 0, 0 //get axis parameter, type: no. 1 (actual position), motor: 0, value: 0 don’t care
COMP 1000 //compare actual value to 1000
JC GE, Label //jump, type: 5 greater/equal
...
...
Label: ROL 0, 1000
Binary format of JC GE, Label when Label is at address 10:
Jump to a fixed address in the TMCL program memory. This command is intended for standalone operation,
only. The host address and the reply are required to take the instruction to the TMCL program memory
while the TMCL program downloads. This command cannot be used in direct mode.
Internal function: The TMCL program counter is set to the passed value.
Related commands: JC, WAIT, CSUB
Mnemonic: JA <Label>
Binary representation:
Example:An infinite loop in TMCL
Loop: MVP ABS, 0, 10000
WAIT POS, 0, 0
MVP ABS, 0, 0
WAIT POS, 0, 0
JA Loop //Jump to the label Loop
Binary format of JA Loop assuming that the label Loop is at address 20:
CSUBSubW//Save program counter and jump to label SubW (see below)
MVP ABS, 0, 0
JA Loop
SubW: WAIT POS, 0, 0
WAIT TICKS, 0, 50
RSUB//Continue with the command following the CSUB command (in this
example: MVP ABS).
4.6.18 CSUB (call subroutine) and RSUB (return from subroutine)
For implementing subroutines there are two commands:
- CSUB calls a subroutine in the TMCL program memory. It is intended for standalone operation, only.
The host address and the reply are required to take the instruction to the TMCL program memory
while the TMCL program downloads. This command cannot be used in direct mode.
- RSUB is used for returning from a subroutine to the next command behind the CSUB command.
4.6.18.1 CSUB (call subroutine)
Internal function: The actual TMCL program counter value is saved to an internal stack, afterwards
overwritten with the passed value. The number of entries in the internal stack is limited to 8. This also
limits nesting of subroutine calls to 8. The command will be ignored if there is no more stack space left.
Related commands: RSUB, JA
Mnemonic: CSUB <Label>
Binary representation:
Binary format of the CSUB SubW command assuming that the label SubW is at address 100:
4.6.18.2 RSUB (return from subroutine)
Internal function: The TMCL program counter is set to the last value of the stack. The command will be
This instruction interrupts the execution of the TMCL program until the specified condition is met. The WAIT
command is intended for standalone operation only. The host address and the reply are used for
communication with the TMCL memory. This command is not to be used in direct mode.
THERE ARE DIFFERENT WAIT CONDITIONS THAT CAN BE USED:
- TICKS: Wait until the number of timer ticks specified by the <ticks> parameter has been reached.
- POS: Wait until the target position of the motor specified by the <motor> parameter has been
reached. An optional timeout value (0 for no timeout) must be specified by the <ticks>
parameter.
- REFSW: Wait until the reference switch of the motor specified by the <motor> parameter has
been triggered. An optional timeout value (0 for no timeout) must be specified by the <ticks>
parameter.
- LIMSW: Wait until a limit switch of the motor specified by the <motor> parameter has been
triggered. An optional timeout value (0 for no timeout) must be specified by the <ticks>
parameter.
- RFS: Wait until the reference search of the motor specified by the <motor> field has been
reached. An optional timeout value (0 for no timeout) must be specified by the <ticks>
parameter.
The timeout flag (ETO) will be set after a timeout limit has been reached. You can then use a JC ETO
command to check for such errors or clear the error using the CLE command.
Internal function: The TMCL program counter is held until the specified condition is met.
Related commands: JC, CLE
Mnemonic: WAIT <condition>, 0, <ticks>
where <condition> is TICKS|POS|REFSW|LIMSW|RFS
Binary representation:
* One tick is 10msec (in standard firmware).
Example:
Wait for motor to reach its target position, without timeout
Mnemonic: WAIT POS, 0, 0
0 ADD – add X register to accu
1 SUB – subtract X register from accu
2 MUL – multiply accu by X register
3 DIV – divide accu by X-register
4 MOD – modulo divide accu by x-register
5 AND – logical and accu with X-register
6 OR – logical or accu with X-register
7 XOR – logical exor accu with X-register
8 NOT – logical invert X-register
9 LOAD – load accu to X-register
10 SWAP – swap accu with X-register
don’t care
don’t care
Byte Index
0 1 2 3 4 5 6
7
Function
Target-
address
Instruction
Number
Type
Motor/
Bank
Operand
Byte3
Operand
Byte2
Operand
Byte1
Operand
Byte0
Value (hex)
$01
$21
$02
$00
$00
$00
$00
$00
4.6.21 CALCX (calculate using the X register)
This instruction is very similar to CALC, but the second operand comes from the X register. The X register
can be loaded with the LOAD or the SWAP type of this instruction. The result is written back to the
accumulator for further processing like comparisons or data transfer.
The content of the accumulator register is transferred to the specified axis parameter. For practical use, the
accumulator has to be loaded e.g. by a preceding GAP instruction. The accumulator may have been modified
by the CALC or CALCX (calculate) instruction.
Related commands: AGP, SAP, GAP, SGP, GGP, CALC, CALCX
Mnemonic: AAP <parameter number>, 0
Binary representation:
Reply in direct mode:
See chapter 5 for a complete list of axis parameters.
Example:
Positioning a motor by a potentiometer connected to analogue input #0:
Start: GIO 0, 1 // get value of analogue input line 0
CALC MUL, 4 // multiply by 4
AAP 0, 0 // transfer result to target position of motor 0
JA Start // jump back to start
The content of the accumulator register is transferred to the specified global parameter. For practical use,
the accumulator has to be loaded e.g. by a preceding GAP instruction. The accumulator may have been
modified by the CALC or CALCX (calculate) instruction.
- Note that the global parameters in bank 0 are mostly EEPROM-only and thus should not be modified
automatically by a standalone application.
- See chapter 6 for a complete list of global parameters.
Related commands: AAP, SGP, GGP, SAP, GAP
Mnemonic: AGP <parameter number>, <bank number>
Binary representation:
Reply in direct mode:
Example:
Copy accumulator to TMCL user variable #3
Mnemonic: AGP 3, 2
Binary:
4.6.24 Customer Specific TMCL Command Extension (user functions 0… 7)
The user definable functions UF0… UF7 are predefined functions without topic for user specific purposes. A
user function UF command uses three parameters. Please contact TRINAMIC for a customer specific
programming.
Internal function: Call user specific functions implemented in C by TRINAMIC.
Parameter automatically restored from EEPROM after reset or power-on. These
parameters can be stored permanently in EEPROM using STAP command and
also explicitly restored (copied back from EEPROM into RAM) using RSAP.
Number
Axis Parameter
Description
Range [Unit]
Access
0
Target position
The target position of a currently executed ramp.
-2147483648…
+2147483647
RW 1 Actual position
Set/get the position counter without moving the
motor.
-2147483648…
+2147483647
RW
2
Target speed
Set/get the desired target velocity.
-2147483648…
+2147483647
[rpm]
RW
3
Actual speed
The actual velocity of the motor.
-2147483648…
+2147483647
[rpm]
R
4
Max. ramp
velocity
The maximum velocity used for velocity ramp in
velocity mode and positioning mode. Set this
value to a realistic velocity which the motor can
reach!
-2147483648…
+2147483647
[rpm]
RWE
6
Max current
Set/get the max allowed motor current.
*This value can be temporarily exceeded marginal due to the
operation of the current regulator.
0… +4294967295
[mA]
RWE
7
MVP Target
reached velocity
Maximum velocity at which end position flag can
be set. Prevents issuing of end position when
the target is passed at high velocity.
-2147483648…
+2147483647
[rpm]
RWE
9
Motor halted
velocity
If the actual speed is below this value the motor
halted flag will be set.
-2147483648…
+2147483647
[rpm]
RWE
10
MVP target
reached
distance
Maximum distance at which the position end
flag is set.
-2147483648…
+2147483647
RWE
11
Acceleration
Acceleration parameter for ROL, ROR, and the
velocity ramp of MVP.
-2147483648…
+2147483647
[RPM/s]
RWE
13
Ramp generator
speed
The actual speed of the velocity ramp used for
positioning and velocity mode.
-2147483648…
+2147483647
[rpm]
R
25
Thermal
winding time
constant
Thermal winding time constant for the used
motor. Used for I²t monitoring.
0… +4294967295
[ms]
RWE
26
I²t limit
An actual I²t sum that exceeds this limit leads to
increasing the I²t exceed counter.
0… +4294967295
RWE
27
I²t sum
Actual sum of the I²t monitor.
0… +4294967295
R
28
I²t exceed
counter
Counts how often an I²t sum was higher than
the I²t limit.
0… +4294967295
RWE
29
Clear I²t
exceeded flag
Clear the flag that indicates that the I²t sum has
exceeded the I²t limit.
1: Activate velocity ramp generator for position
and velocity mode. (Allows usage of acceleration
and positioning velocity for MVP command.)
0/1
RWE
150
Actual motor
current
Get actual motor current.
-2147483648…
+2147483647 [mA]
R
151
Actual voltage
Actual supply voltage.
0… +4294967295
R
152
Actual driver
temperature
Actual temperature of the motor driver.
0… +4294967295
R
155
Target current
Get desired target current or set target current to
activate current regulation mode. (+= turn motor
in right direction; -= turn motor in left direction)
-2147483648…
+2147483647
[mA]
RW
156
Error/Status
flags
Bit 0: Overcurrent flag. This flag is set if the max.
current limit is exceeded.
Bit 1: Undervoltage flag. This flag is set if supply
voltage is too low for motor operation.
Bit 2: Overvoltage flag. This flag is set if the
motor becomes switched off due to overvoltage.
Bit 3: Overtemperature flag. This flag is set if
overtemperature limit is exceeded.
Bit 4: Motor halted flag. This flag is set if motor
has been switched off.
Bit 5: Hall error flag. This flag is set upon a hall
error.
Bit 6: TMC603 error flag
Bit 7: unused
Bit 8: unused
Bit 9: Velocity mode active flag
Bit 10: Position mode active flag.
Bit 11: Torque mode active flag.
Bit 12: unused
Bit 13: unused
Bit 14: Position end flag. This flag is set if the
motor has been stopped at the target position.
Bit 15: unused
Bit 16: unused
Bit 17: I²t exceeded flag. This flag is set if the I²t
sum exceeded the I²t limit of the motor.
(reset by SAP 29 after the time specified by the
I²t thermal winding time constant)
Flag 0 to 15 are automatically reset. Only flag 17
must be cleared manually.
0…+4294967295
R
159
Commutation
mode
6: FOC based on hall sensor
7: FOC based on encoder
6, 7
RWE
161
Encoder set
NULL
1: set position counter to zero at next N channel
event.
0/1
RWE
162
Switch set NULL
1: set position counter to zero at next switch
event.
0/1
RWE
163
Encoder clear
set NULL
1: set position counter to zero only once
0: always at an N channel event
Mass inertia constant. Compensates the rotor
inertia of the motor.
-2147483648…
+2147483647
RWE
239
BEMF constant
BEMF constant of the motor. Used for current,
position, and velocity regulation.
-2147483648…
+2147483647
[rpm/(10V)]
RWE
240
Motor coil
resistance
Resistance of motor coil. Used for current,
position, and velocity regulation.
-2147483648… +2147483647 [mΩ]
RWE
244
Init sine delay
Duration for sine initialization sequence. This
parameter should be set in a way, that the
motor has stopped mechanical oscillations after
the specified time.
-32768… +32767
[ms]
RWE
245
Overvoltage
protection
1: Enable overvoltage protection.
0/1
RWE
249
Init sine mode
0: Initialization in controlled sine commutation
(determines the encoder offset)
1: Initialization in block commutation using hall
sensors
2: Initialization in controlled sine commutation
(use the previous set encoder offset)
-128… +127
RWE
250
Encoder steps
Encoder steps per rotation.
0… +4294967295
RWE
251
Encoder
direction
Set the encoder direction in a way, that ROR
increases position counter.
0/1
RWE
253
Number of
motor poles
Number of motor poles.
+2… +254
RWE
254
Hall sensor
invert
1: Hall sensor invert. Invert the hall scheme, e.g.
used by some Maxon motors.
Parameter automatically restored from EEPROM after reset or power-on. These
parameters can be stored permanently in EEPROM using STAP command and
also explicitly restored (copied back from EEPROM into RAM) using RSAP.
Number
Axis Parameter
Description
Range [Unit]
Access
253
Number of
motor poles
Number of motor poles.
+2… +254
RWE
239
BEMF constant
BEMF constant of the motor. Used for current,
position, and velocity regulation.
-2147483648…
+2147483647
[rpm/(10V)]
RWE
240
Motor coil
resistance
Resistance of motor coil. Used for current,
position, and velocity regulation.
-2147483648…
+2147483647
[mΩ]
RWE
238
Mass inertia
constant
Mass inertia constant. Compensates the rotor
inertia of the motor.
-2147483648…
+2147483647
RWE
25
Thermal
winding time
constant
Thermal winding time constant for the used
motor. Used for I²t monitoring.
0… +4294967295
[ms]
RWE
26
I²t limit
An actual I²t sum that exceeds this limit leads to
increasing the I²t exceed counter.
0… +4294967295
RWE
27
I²t sum
Actual sum of the I²t monitor.
0… +4294967295
R
28
I²t exceed
counter
Counts how often an I²t sum was higher than
the I²t limit.
0… +4294967295
RWE
29
Clear I²t
exceeded flag
Clear the flag that indicates that the I²t sum has
exceeded the I²t limit.
(ignored)
W
30
Minute counter
Counts the module operational time in minutes.
0… +4294967295
[min]
RWE
245
Overvoltage
protection
1: Enable overvoltage protection.
0/1
RWE
Number
Axis Parameter
Description
Range [Unit]
Access
254
Hall sensor
invert
1: Hall sensor invert. Invert the hall scheme, e.g.
used by some Maxon motors.
0/1
RWE
250
Encoder steps
Encoder steps per rotation.
0… +4294967295
RWE
209
Actual encoder
position
Actual encoder position / counter value
-2147483648…
+2147483647
R
210
Actual hall
angle
Actual hall angle value
-32767… +32767
R
211
Actual encoder
angle
Actual encoder angle value
-32767… +32767
R
251
Encoder
direction
Set the encoder direction in a way, that ROR
increases position counter.
0/1
RWE
165
Actual encoder
commutation
offset
This value represents the internal commutation
offset.
(0 … max. encoder steps per rotation)
-2147483648…
+2147483647
RWE
5.1 Axis Parameter Sorted by Functionality
The following section describes all axis parameters that can be used with the SAP, GAP, STAP, RSAP and AAP
commands.
Motor current for controlled commutation. This
parameter is used in commutation mode.
0… +4294967295
[mA]
RWE
249
Init sine mode
0: Initialization in controlled sine commutation
(determines the encoder offset)
1: Initialization in block commutation using hall
sensors
2: Initialization in controlled sine commutation
(use the previous set encoder offset)
0… 2
RWE
244
Init sine delay
Duration for sine initialization sequence. This
parameter should be set in a way, that the motor
has stopped mechanical oscillations after the
specified time.
-32768… +32767
[ms]
RWE
159
Commutation
mode
6: FOC based on hall sensor
7: FOC based on encoder
6, 7
RWE
Number
Axis Parameter
Description
Range [Unit]
Access
6
Max current
Set/get the max allowed motor current.
This value can be temporarily exceeded marginal due to the
operation of the current regulator.
0… +4294967295
[mA]
RWE
150
Actual motor
current
Get actual motor current.
-2147483648…
+2147483647
[mA]
R
155
Target current
Get desired target current or set target current to
activate current regulation mode. (+= turn motor
in right direction; -= turn motor in left direction)
-2147483648…
+2147483647
[mA]
RW
134
Current
regulation loop
delay
Delay of the PID current regulator.
0… +4294967295
[50µs]
RWE
172
P parameter for
current PID
P parameter of current PID regulator.
-2147483648…
+2147483647
RWE
173
I parameter for
current PID
I parameter of current PID regulator.
-2147483648…
+2147483647
RWE
200
Current PID
error
Actual error of current PID regulator
-2147483648…
+2147483647
R
201
Current PID
error sum
Sum of errors of current PID regulator
-2147483648…
+2147483647
R
Number
Axis Parameter
Description
Range [Unit]
Access
3
Actual speed
The actual velocity of the motor.
-2147483648…
+2147483647
[rpm]
R
2
Target speed
Set/get the desired target velocity.
-2147483648…
+2147483647
[rpm]
RW
9
Motor halted
velocity
If the actual speed is below this value the motor
halted flag will be set.
Bit set: Left stop
switch input is high
active
Bit clear: Left stop
switch input is low
active
Bit 1
Right stop switch
polarity
Bit set: Right stop
switch input is high
active
Bit clear: Right stop
switch input is low
active
0… 3
RWE
230
P parameter for
position PID
P parameter of position PID regulator. (
-2147483648…
+2147483647
RWE
226
Position PID
error
Actual error of PID position regulator
-2147483648…
+2147483647
R
Number
Axis Parameter
Description
Range [Unit]
Access
151
Actual voltage
Actual supply voltage.
0… +4294967295
R
152
Actual driver
temperature
Actual temperature of the motor driver.
0… +4294967295
R
156
Error/Status
flags
Bit 0: Overcurrent flag. This flag is set if max.
current limit is exceeded.
Bit 1: Undervoltage flag. This flag is set if supply
voltage is too low for motor operation.
Bit 2: Overvoltage flag. This flag is set if the
motor becomes switched off due to overvoltage.
Bit 3: Overtemperature flag. This flag is set if
overtemperature limit is exceeded.
Bit 4: Motor halted flag. This flag is set if motor
has been switched off.
Bit 5: Hall error flag. This flag is set upon a hall
error.
Bit 6: TMC603 error flag
Bit 7: unused
Bit 8: unused
Bit 9: Velocity mode active flag
Bit 10: Position mode active flag.
Bit 11: Torque mode active flag.
Bit 12: unused
Bit 13: unused
Bit 14: Position end flag. This flag is set if the
motor has been stopped at the target position.
Bit 15: unused
Bit 16: unused for TMCM-1640
Bit 17: I²t exceeded flag. This flag is set if the I²t
sum exceeded the I²t limit of the motor.
(reset by SAP 29 or after the time specified by
the I²t thermal winding time constant)
Flag 0 to 15 are automatically reset. Only flag 17
must be cleared manually.
Parameter automatically restored from EEPROM after reset or power-on.
Number
Global
parameter
Description
Range
Access
64
EEPROM magic
Setting this parameter to a different value as $E4 will
cause re-initialization of the axis and global parameters
(to factory defaults) after the next power up. This is
useful in case of miss-configuration.
0… 255
RWE
65
RS485 baud rate
0
9600 baud
Default
1
14400 baud
2
19200 baud
3 28800 baud
4 38400 baud
5 57600 baud
6
76800 baud
Not supported by Windows!
7
115200 baud
0… 7
RWE
66
serial address
The module (target) address for RS485 and virtual COM
port
0… 255
RWE
73
configuration
EEPROM lock
flag
Write: 1234 to lock the EEPROM, 4321 to unlock it.
Read: 1=EEPROM locked, 0=EEPROM unlocked.
0/1
RWE
75
telegram pause
time
Pause time before the reply via RS485 is sent.
0… 255
RWE
76
serial host
address
Host address used in the reply telegrams sent back via
RS485.
0… 255
RWE
77
auto start mode
0: Do not start TMCL application after power up (default).
1: Start TMCL application automatically after power up.
0/1
RWE
6 Global Parameter Overview (SGP, GGP, STGP, RSGP,
AGP)
The following section describes all global parameters that can be used with the SGP, GGP, STGP and RSGP
commands.
TWO BANKS ARE USED FOR GLOBAL PARAMETERS:
- Bank 0 (global configuration of the module)
- Bank 2 (user TMCL variables)
6.1 Bank 0
Parameters 64… 255
Parameters below 63 configure stuff like the serial address of the module RS485 baud rate or the telegram
pause time. Change these parameters to meet your needs. The best and easiest way to do this is to use the
appropriate functions of the TMCL-IDE. The parameters between 64 and 85 are stored in EEPROM only. A SGP
command on such a parameter will always store it permanently and no extra STGP command is needed.
Take care when changing these parameters and use the appropriate functions of the TMCL-IDE to do it in an
interactive way!
Protect a TMCL program against disassembling or
overwriting.
0 – no protection
1 – protection against disassembling
2 – protection against overwriting
3 – protection against disassembling and overwriting
If you switch off the protection against disassembling,
the program will be erased first!
Changing this value from 1 or 3 to 0 or 2, the TMCL
program will be wiped off.
0, 1, 2, 3
RWE
85
do not restore
user variables
0 – user variables are restored (default)
1 – user variables are not restored
0/1
RWE
128
TMCL
application
status
0 –stop
1 – run
2 – step
3 – reset
0… 3
R
129
download
mode
0 – normal mode
1 – download mode
0/1 R 130
TMCL program
counter
The index of the currently executed TMCL instruction.
o… 2047
R
132
tick timer
A 32 bit counter that gets incremented by one every
millisecond. It can also be reset to any start value.
0…
+4294967295
RW
255
suppress reply
0 – reply (default)
1 – no reply
0/1
RW
Access
type
Related
command(s)
Description
R
GGP
Parameter readable
W
SGP, AGP
Parameter writable
E
STGP, RSGP
Parameter automatically restored from EEPROM after reset or power-on.
Number
Global parameter
Description
Range
Access
0… 55
general purpose variable #0… 55
for use in TMCL applications
-231…+2
31
(int32)
RWE
56… 255
general purpose variables #56… #255
for use in TMCL applications
-231…+2
31
(int32)
RW
6.2 Bank 2
Bank 2 contains general purpose 32 bit variables for the use in TMCL applications. They are located in RAM
and can be stored to EEPROM. After booting, their values are automatically restored to the RAM.
7.1 Structure of the Cascaded Motor Regulation Modes
The TMCM-1640 supports a current, velocity, and position PID regulation mode for motor control in different
application areas. These regulation modes are cascaded as shown in figure 12.1. The individual modes are
explained in the following sections.
The current regulation mode uses a PID regulator to adjust a desired motor current. This target current can
be set by axis parameter 155. The maximal target current is limited by axis parameter 6.
The PID regulation uses three basic parameters: The P and I value as well as the timing control value.
TIMING CONTROL VALUE
The timing control value (current regulation loop multiplier, axis parameter 134) determines how often the
current regulation is invoked. It is given in multiple of 50µs:
= resulting delay between two current regulation loops
= current regulation loop multiplier parameter
For most applications it is recommended to leave this parameter unchanged at its default of 2*50µs. Higher
values may be necessary for very slow and less dynamic drives.
STRUCTURE OF THE CURRENT REGULATOR
Figure 7.2: Current regulation
PARAMETERIZING THE CURRENT REGULATOR SET
1. Set the P parameter and the I parameter to zero.
2. Start the motor by using a low target current (e.g. 1000 mA).
3. Modify the current P parameter. Start from a low value and go to a higher value, until the actual
current nearly reaches 50% of the desired target current.
4. Do the same with the current I parameter.
For all tests set the motor current limitation to a realistic value, so that your power supply does not become
overloaded during acceleration phases. If your power supply reaches current limitation, the unit may reset or
undetermined regulation results may occur.
Target current for current PID regulator (GAP 155)
7.3 Velocity Regulation
Based on the current regulation the motor velocity can be controlled by the velocity PID regulator.
TIMING CONTROL VALUE
Also, the velocity PID regulator uses a timing control value (PID regulation loop delay, axis parameter 133)
which determines how often the PID regulator is invoked. It is given in multiple of 1ms:
= resulting delay between two PID calculations
= PID regulation loop delay parameter
For most applications it is recommended to leave this parameter unchanged at its default value of 1ms.
Higher values may be necessary for very slow and less dynamic drives.
STRUCTURE OF THE VELOCITY REGULATOR
Figure 7.3: Velocity regulation
PARAMETERIZING THE VELOCITY REGULATOR SET
1. Set the velocity I parameter to zero.
2. Start the motor by using a medium target velocity (e.g. 2000 rpm).
3. Modify the velocity P parameter. Start from a low value and go to a higher value, until the actual
motor speed reaches 80 or 90% of the target velocity.
4. The lasting 10 or 20% speed difference can be reduced by slowly increasing the velocity I
For a controlled start up of the motor's velocity a velocity ramp generator can be activated/deactivated by
axis parameter 146. The ramp generator uses the maximal allowed motor velocity (axis parameter 4), the
acceleration (axis parameter 11) und the desired target velocity (axis parameter 2) to calculate a ramp
generator velocity for the following velocity PID regulator.
7.5 Position Regulation
Based on current and velocity regulators the TMCM-1640 supports a positioning mode based on encoder or
hall sensor position. During positioning the velocity ramp generator can be activated to enable motor
positioning with controlled acceleration or it can be disabled to support motor positioning with max
allowed speed.
The PID regulation uses two basic parameters: the P regulation and a timing control value.
TIMING CONTROL VALUE
The timing control value (PID regulation loop parameter - axis parameter 133) determines how often the PID
regulator is invoked. It is given in multiple of 1ms:
= the resulting delay between two position regulation loops
= PID regulation loop multiplier parameter
For most applications it is recommended to leave the timing control value unchanged at its default of 1ms.
Higher values may be necessary for very slow and less dynamic drives.
STRUCTURE OF THE POSITION REGULATOR
Figure 7.4: Positioning regulation
PARAMETERIZING THE POSITION REGULATION
Based on the velocity regulator only the position regulator P has to be parameterized.
1. Disable the velocity ramp generator and set position P parameter to zero.
2. Choose a target position and increase the position P parameter until the motor reaches the target
position approximately.
3. Switch on the velocity ramp generator. Based on the max. positioning velocity (axis parameter 4)
and the acceleration value (axis parameter 11) the ramp generator automatically calculates the slow down point, i.e. the point at which the velocity has to be reduced in order to stop at the desired
target position.
4. Reaching the target position is signaled by setting the position end flag.
Motor regulated by
combination of
Velocity and Position
PID
Acceleration
MVP target
reached velocity
Target reached flag
only set when velocity
and position are in
this area.
NOTE:
- In order to minimize the time until this flag becomes set, the positioning tolerance MVP target reached
distance can be chosen with axis parameter 10.
- Since the motor typically is assumed not to signal target reached when the target was just passed in a
short moment at a high velocity, additionally the maximum target reached velocity (MVP target reached velocity) can be defined by axis parameter 7.
- A value of zero for axis parameter 7 is the most universal, since it implies that the motor stands still at the
target. But when a fast rising of the position end flag is desired, a higher value for the MVP target reached velocity parameter will save a lot of time. The best value should be tried out in the actual application.
CORRELATION OF AXIS PARAMETERS 10 AND 7, THE TARGET POSITION, AND THE POSITION END FLAG
Figure 7.5: Positioning algorithm
Depending on motor and mechanics a low oscillation is normal. This can be reduced to at least +/-1 encoder
steps. Without oscillation the regulation cannot keep the position!
Axis parameter 152 delivers the actual ADC value of the motor driver. This ADC value can be converted to a
temperature in °C as follows:
≈ 5.31
Example 1: Example 2:
ADC = 1000 ADC = 1200
R
≈ 6.81 R
NTC
NTC
T ≈ 35 T ≈ 42
9 I²t Monitoring
The I²t monitor determines the sum of the square of the motor current over a given time. The integrating
time is motor specific. In the datasheet of the motor this time is described as thermal winding time constant and can be set for each module using axis parameter 25. The number of measurement values
within this time depends on how often the current regulation and thus the I²t monitoring is invoked. The
value of the actual I²t sum can be read by axis parameter 27. With axis parameter 26 the default value for
the I²t limit can be changed (default: 211200). If the actual I²t sum exceeds the I²t limit of the motor, flag 17
(in axis parameter 156) is set and the motor pwm is set to zero as long as the I²t exceed flag is set. The
actual regulation mode will not be changed. Furthermore, the I²t exceed counter is increased once every
second as long as the actual I²t sum exceeds the I²t limit. The I²t exceed flag can be cleared manually using
parameter 29 but only after the cool down time given by the thermal winding time constant has passed.
The I²t exceed flag will not be reset automatically. The I²t limit can be determined as follows:
is the desired average current
is the thermal winding time constant given by the motor datasheet
Example:
I²t limits for an average current of a) 1A, b) 2A, c) 3A and d) 4A over a thermal winding time of 13,2s.
TRINAMIC Motion Control GmbH & Co. KG does not authorize or
warrant any of its products for use in life support systems,
without the specific written consent of TRINAMIC Motion Control
GmbH & Co. KG.
Life support systems are equipment intended to support or
sustain life, and whose failure to perform, when properly used in
accordance with instructions provided, can be reasonably
expected to result in personal injury or death.
Information given in this data sheet is believed to be accurate
and reliable. However neither responsibility is assumed for the
consequences of its use nor for any infringement of patents or
other rights of third parties, which may result from its use.
Specifications are subject to change without notice.