TMCM-1640 TMCL Firmware Manual

MODULE FOR BLDC MOTORS
MODULE
Firmware Version V2.06
TMCL™ FIRMWARE MANUAL
+
+
TMCM-1640
1-Axis BLDC
Controller / Driver Module
5A / 24 V
Hall Sensor Interface
Encoder Interface
RS485 and USB Interface
FOC Firmware
+
TRINAMIC Motion Control GmbH & Co. KG
Hamburg, Germany
www.trinamic.com
+
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Table of Contents
1
2
3
Features ........................................................................................................................................................................... 4
Overview ......................................................................................................................................................................... 5
Putting the TMCM-1640 into Operation .................................................................................................................. 6
3.1
Starting up ............................................................................................................................................................. 6
3.2
Operating the Module in Direct Mode ........................................................................................................... 9
4
TMCL ............................................................................................................................................................................... 10
4.1
Binary Command Format ................................................................................................................................ 10
4.2
Reply Format ....................................................................................................................................................... 11
4.2.1 Status Codes ................................................................................................................................................. 11
4.3
Standalone Applications .................................................................................................................................. 12
4.4
Testing with a Simple TMCL Program ......................................................................................................... 12
4.5
TMCL Command Overview .............................................................................................................................. 13
4.5.1 Motion Commands ...................................................................................................................................... 13
4.5.2 Parameter Commands ................................................................................................................................ 13
4.5.3 Control Commands ..................................................................................................................................... 13
4.5.4 I/O Port Commands .................................................................................................................................... 13
4.5.5 Calculation Commands .............................................................................................................................. 14
4.6
Commands ........................................................................................................................................................... 15
4.6.1 ROR (rotate right)......................................................................................................................................... 15
4.6.2 ROL (rotate left) ............................................................................................................................................ 16
4.6.3 MST (motor stop) ......................................................................................................................................... 17
4.6.4 MVP (move to position) ............................................................................................................................. 18
4.6.5 SAP (set axis parameter) ........................................................................................................................... 19
4.6.6 GAP (get axis parameter) ........................................................................................................................... 20
4.6.7 STAP (store axis parameter) ..................................................................................................................... 21
4.6.8 RSAP (restore axis parameter) ................................................................................................................. 22
4.6.9 SGP (set global parameter) ....................................................................................................................... 23
4.6.10 GGP (get global parameter) ...................................................................................................................... 24
4.6.11 STGP (store global parameter) ................................................................................................................. 24
4.6.12 RSGP (restore global parameter) ............................................................................................................. 25
4.6.13 SIO (set output) and GIO (get input / output) ................................................................................... 26
4.6.14 CALC (calculate) ............................................................................................................................................ 28
4.6.15 COMP (compare) ........................................................................................................................................... 29
4.6.16 JC (jump conditional).................................................................................................................................. 30
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
4.6.24 Customer Specific TMCL Command Extension (user functions 0… 7) ........................................... 37
4.6.25 Command 136 - Get Firmware Version ................................................................................................. 38
5
Axis Parameter Overview (SAP, GAP, STAP, RSAP, AAP) ................................................................................. 39
5.1
Axis Parameter Sorted by Functionality ...................................................................................................... 43
6
Global Parameter Overview (SGP, GGP, STGP, RSGP, AGP)............................................................................. 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.3
Velocity Regulation ........................................................................................................................................... 51
7.4
Velocity Ramp Generator ................................................................................................................................. 52
7.5
Position Regulation ........................................................................................................................................... 52
8
Temperature Calculation........................................................................................................................................... 54
9
I²t Monitoring .............................................................................................................................................................. 54
10 Life Support Policy ..................................................................................................................................................... 55
www.trinamic.com
2
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
11 Revision History .......................................................................................................................................................... 56
11.1 Firmware Revision ............................................................................................................................................. 56
11.2 Document Revision ........................................................................................................................................... 56
12 References..................................................................................................................................................................... 56
www.trinamic.com
3
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
1
4
Features
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 RDS(ON))
- 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
Refer to separate TMCM-1640 Hardware Manual, too.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
2
5
Overview
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.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
3
6
Putting the TMCM-1640 into Operation
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.
1
GPIO
USB
1
Hall
Power 1
1
Encoder
1
Motor
Figure 3.1 Connectors
USB
Hall
Connector type
Tyco electronics (formerly AMP) MTA-100
series (3-640456-2), 2 pol., male
Tyco electronics (formerly AMP) MTA-100
series (3-640456-3), 3 pol., male
5-pin standard mini-USB connector, female
2mm pitch 5 pin JST B5B-PH-K connector
Encoder
2mm pitch 5 pin JST B5B-PH-K connector
I/O, RS485
2mm pitch 8 pin JST B8B-PH-K connector
Domain
Power
Motor
www.trinamic.com
Mating connector type
MTA 100 series (3-640441-2), 2 pol., female
MTA 100 series (3-640441-3), 3 pol., female
5-pin standard mini-USB connector, male
Housing: JST PHR-5
Crimp contacts: BPH-002T-P0.5S (0.5-0.22mm)
Housing: JST PHR-5
Crimp contacts: BPH-002T-P0.5S (0.5-0.22mm)
Housing: JST PHR-8
Crimp contacts: BPH-002T-P0.5S (0.5-0.22mm)
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
1.
Connect the motor:
Pin
1
2
3
2.
5.
Label
GND
+5V
A
B
N
Description
Encoder supply and signal ground
+5V output for encoder supply (max. 100mA)
Encoder channel a
Encoder channel b
Encoder index / null channel
Connect the hall sensor:
Pin
1
2
3
4
5
4.
Description
Motor coil phase 1 / U
Motor coil phase 2 / V
Motor coil phase 3 / W
Connect the encoder (optional):
Pin
1
2
3
4
5
3.
Label
BM1
BM2
BM3
Label
GND
+5V
HALL_1
HALL_2
HALL_3
Description
Encoder supply and signal ground
+5V output for hall sensor supply
Hall sensor signal 1
Hall sensor signal 2
Hall sensor signal 3
Connect the I/Os and the RS485 interface, if needed:
Pin
1
Label
GND
2
+5V
3
AIN
4
IN_0
5
IN_1
6
OUT
7
RS485+
8
RS485-
Description
Signal and system ground
+5V output for supply of external circuit
(max. 100mA)
Analog input (0..10V), may be used as
velocity control input in standalone mode
(depending on initial script)
Digital input, may be used as stop (STOP_R)
/ limit switch input (if activated)
Digital input, may be used as stop (STOP_L) /
limit switch input (if activated)
Digital output (open-drain, max. 100mA)
RS485 2-wire serial interface (non-inverted
signal)
RS485 2-wire serial interface (inverted signal)
Connect the USB interface:
Pin
1
2
3
4
5
Label
VBUS
DD+
ID
GND
www.trinamic.com
Description
+5V power
Data –
Data +
Not connected
Ground
7
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
6.
8
Connect the power supply as follows:
Pin
1
Label
+U
2
GND
Description
Module and driver stage power supply input
Module ground (power supply and signal
ground)
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
GUIDELINES FOR POWER SUPPLY:
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)
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.2.
Choose the Connection tab.
Choose Type.
The TMCL-IDE shows you which Port the module uses.
Click OK.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Figure 3.2 Setup menu
9
Figure 3.3 Connection tab of TMCL-IDE
3.2 Operating the Module in Direct Mode
Start TMCL Direct Mode.
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.
Figure 3.4 Direct mode
EXAMPLES:
ROR rotate right, motor 0, value 500
MST motor stop, motor 0
www.trinamic.com
-> Click Execute. The first motor is rotating now.
-> Click Execute. The first motor stops now.
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4
10
TMCL
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:
Bytes
1
1
1
1
4
1
Meaning
Module address
Command number
Type number
Motor or Bank number
Value (MSB first!)
Checksum
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
11
Checksum calculation
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:
Bytes
1
1
1
1
4
1
-
4.2.1
Meaning
Reply address
Module address
Status (e.g. 100 means no error)
Command number
Value (MSB first!)
Checksum
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!
Status Codes
The reply contains a status code.
The status code can have one of the following values:
Code
100
101
1
2
3
4
5
6
Meaning
Successfully executed, no error
Command loaded into TMCL
program EEPROM
Wrong checksum
Invalid command
Wrong type
Invalid value
Configuration EEPROM locked
Command not available
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
12
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:
//A simple example for using TMCL and TMCL-IDE
Loop:
ROL 0, 4000
WAIT TICKS, 0, 2000
ROR 0, 4000
WAIT TICKS, 0, 2000
JA Loop
//rotate left with 4000 rpm
//rotate right with 4000 rpm
Assemble
Stop
Download
Run
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).
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
13
4.5 TMCL Command Overview
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.
Mnemonic
ROL
ROR
MVP
MST
4.5.2
Command number
2
1
4
3
Meaning
Rotate left
Rotate right
Move to position
Motor stop
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.
Mnemonic
SAP
GAP
STAP
RSAP
SGP
GGP
STGP
RSGP
4.5.3
Command number
5
6
7
8
9
10
11
12
Meaning
Set axis parameter
Get axis parameter
Store axis parameter into EEPROM
Restore axis parameter from EEPROM
Set global parameter
Get global parameter
Store global parameter into EEPROM
Restore global parameter from EEPROM
Control Commands
These commands are used to control the program flow (loops, conditions, jumps etc.) in standalone mode,
only.
Mnemonic
JA
JC
COMP
CSUB
RSUB
WAIT
STOP
4.5.4
Command number
22
21
20
23
24
27
28
Meaning
Jump always
Jump conditional
Compare accumulator with constant value
Call subroutine
Return from subroutine
Wait for a specified event
End of a TMCL program
I/O Port Commands
These commands control the external I/O ports and can be used in direct mode and in standalone mode.
Mnemonic
SIO
GIO
Command number
14
15
www.trinamic.com
Meaning
Set output
Get input
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.5.5
14
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.
Mnemonic
CALC
CALCX
AAP
AGP
Command number
19
33
34
35
Meaning
Calculate using the accumulator and a constant value
Calculate using the accumulator and the X register
Copy accumulator to an axis parameter
Copy accumulator to a global parameter
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.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
15
4.6 Commands
The module specific commands are explained in more detail on the following pages. They are listed
according to their command number.
4.6.1
ROR (rotate right)
The motor will be instructed to rotate with a specified velocity in right direction (increasing the position
counter).
Internal function: First, velocity mode is selected. Then, the velocity value is transferred to axis parameter
#2 (target velocity).
Related commands: ROL, MST, SAP, GAP
Mnemonic: ROR 0, <velocity>
Binary representation:
COMMAND
1
TYPE
don’t care
MOT/BANK
0
Reply in direct mode:
STATUS
100 – OK
COMMAND
1
VALUE
don’t care
VALUE <velocity>
-200000… +200000
Example:
Rotate right, velocity = 350
Mnemonic: ROR 0, 350
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$01
2
Type
$00
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$01
7
Operand
Byte0
$5e
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.2
16
ROL (rotate left)
The motor will be instructed to rotate with a specified velocity (opposite direction compared to ROR,
decreasing the position counter).
Internal function: First, velocity mode is selected. Then, the velocity value is transferred to axis parameter
#2 (target velocity).
Related commands: ROR, MST, SAP, GAP
Mnemonic: ROL 0, <velocity>
Binary representation:
COMMAND
2
TYPE
don’t care
MOT/BANK
0
Reply in direct mode:
STATUS
100 – OK
COMMAND
2
VALUE
don’t care
VALUE <velocity>
-200000… +200000
Example:
Rotate left, velocity = 1200
Mnemonic: ROL 0, 1200
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$02
2
Type
$00
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$04
7
Operand
Byte0
$b0
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.3
17
MST (motor stop)
The motor will be instructed to stop.
Internal function: The axis parameter target velocity is set to zero.
Related commands: ROL, ROR, SAP, GAP
Mnemonic: MST 0
Binary representation:
COMMAND
3
TYPE
don’t care
MOT/BANK
0
Reply in direct mode:
STATUS
100 – OK
COMMAND
3
VALUE
don’t care
VALUE
don’t care
Example:
Stop motor
Mnemonic: MST 0
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$03
2
Type
$00
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.4
18
MVP (move to position)
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.
Related commands: SAP, GAP, and MST
Mnemonic: MVP <ABS|REL>, 0, <position|offset value>
Binary representation:
COMMAND
4
TYPE
0 ABS – absolute
MOT/BANK
0
1 REL – relative
Reply in direct mode:
STATUS
100 – OK
VALUE
<position>
-2147483648…
+2147483647
<offset>
-2147483648…
+2147483647
0
COMMAND
4
VALUE
don’t care
Example MVP ABS:
Move motor to (absolute) position 9000
Mnemonic: MVP ABS, 0, 9000
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
1
Instruction
Number
$04
2
Type
$00
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$23
7
Operand
Byte0
$28
6
Operand
Byte1
$fc
7
Operand
Byte0
$18
Example MVP REL:
Move motor from current position 1000 steps backward (move relative -1000)
Mnemonic: MVP REL, 0, -1000
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$00
www.trinamic.com
1
Instruction
Number
$04
2
Type
$01
3
Motor/
Bank
$00
4
Operand
Byte3
$ff
5
Operand
Byte2
$ff
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.5
19
SAP (set axis parameter)
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:
COMMAND
5
TYPE
<parameter number>
MOT/BANK
0
Reply in direct mode:
STATUS
100 – OK
COMMAND
5
VALUE
don’t care
VALUE
<value>
A list of all parameters which can be used for the SAP command is shown in section 5.
Example:
Set the absolute maximum current to 2000mA
Mnemonic: SAP 6, 0, 2000
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$05
2
Type
$06
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$07
7
Operand
Byte0
$D0
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.6
20
GAP (get axis parameter)
Most parameters of the TMCM-1640 can be adjusted individually. They can be read out using the GAP
command.
Related commands: SAP, STAP, and RSAP
Mnemonic: GAP <parameter number>, 0
Binary representation:
COMMAND
6
TYPE
<parameter number>
MOT/BANK
0
Reply in direct mode:
STATUS
100 – OK
COMMAND
6
VALUE
don’t care
VALUE
don’t care
A list of all parameters which can be used for the GAP command is shown in section 5.
Example:
Get the actual motor position
Mnemonic: GAP 1, 0
Binary:
Byte Index
Function
Value (hex)
Reply:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
Instruction
Number
$06
$01
0
Hostaddress
$00
1
Targetaddress
$01
2
Status
www.trinamic.com
1
2
Type
$64
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
3
Instructio
n
$06
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$02
7
Operand
Byte0
$c7
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.7
21
STAP (store axis parameter)
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:
COMMAND
7
TYPE
<parameter number>
MOT/BANK
0
VALUE
don’t care*
* 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:
STATUS
100 – OK
COMMAND
7
VALUE
don’t care
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:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
1
Instruction
Number
$07
2
Type
$04
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
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.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.8
22
RSAP (restore axis parameter)
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:
COMMAND
8
TYPE
<parameter number>
MOT/BANK
0
Reply in direct mode:
STATUS
100 – OK
COMMAND
8
VALUE
don’t care
VALUE
don’t care
A list of all parameters which can be used for the RSAP command is shown in section 5.
Example:
Restore the maximum current
Mnemonic: RSAP 6, 0
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$08
2
Type
$06
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
4.6.9
23
SGP (set global parameter)
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.
Related commands: GGP, STGP, RSGP
Mnemonic: SGP <parameter number>, <bank number>, <value>
Binary representation:
COMMAND
9
TYPE
<parameter number>
Reply in direct mode:
STATUS
100 – OK
VALUE
don’t care
MOT/BANK
<bank number>
VALUE
<value>
A list of all parameters which can be used for the SGP command is shown in section 6.
Example:
Set variable 0 at bank 2 to 100
Mnemonic: SGP, 0, 2, 100
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
2
Instruction Type
Number
$09
$00
3
Motor/
Bank
$02
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$64
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
24
4.6.10 GGP (get global parameter)
All global parameters can be read with this function.
Related commands: SGP, STGP, RSGP
Mnemonic: GGP <parameter number>, <bank number>
Binary representation:
COMMAND
10
TYPE
<parameter number>
Reply in direct mode:
STATUS
100 – OK
VALUE
<value>
MOT/BANK
<bank number>
VALUE
don’t care
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:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
1
Instruction
Number
$0a
2
Type
$00
3
Motor/
Bank
$02
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
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:
COMMAND
11
TYPE
<parameter number>
Reply in direct mode:
STATUS
100 – OK
VALUE
don’t care
MOT/BANK
<bank number>
VALUE
don’t care
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
Binary:
Byte Index
0
1
2
3
4
Instruction
Function
TargetType
Motor/
Operand
Number
address
Bank
Byte3
Value (hex)
$01
$0b
$00
$02
$00
www.trinamic.com
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
25
4.6.12 RSGP (restore global parameter)
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:
COMMAND
12
TYPE
<parameter number>
Reply in direct mode:
STATUS
100 – OK
VALUE
don’t care
MOT/BANK
<bank number>
VALUE
don’t care
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
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$0c
2
Type
$00
3
Motor/
Bank
$02
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
26
4.6.13 SIO (set output) and GIO (get input / output)
The TMCM-1640 provides two commands for dealing with inputs and outputs:
-
SIO sets the status of the general digital output either to low (0) or to high (1).
With GIO the status of the two available general purpose inputs of the module can be read out. The
command reads out a digital or analogue input port. Digital lines will read 0 and 1, while the ADC
channel delivers 12 bit in the range of 0… 4095.
CORRELATION BETWEEN I/OS AND BANKS
Bank
Bank 0
Bank 1
Bank 2
Inputs/ Outputs
Digital inputs
Analogue inputs
Digital outputs
Description
Digital inputs are accessed in bank 0.
Analog inputs are accessed in bank 1.
The states of the OUT lines (that have been set by SIO commands)
can be read back using bank 2.
4.6.13.1 SIO (set output)
Bank 2 is used for setting the status of the general digital output either to low (0) or to high (1).
Internal function: the passed value is transferred to the specified output line.
Related commands: GIO, WAIT
Mnemonic: SIO <port number>, <bank number>, <value>
Binary representation:
INSTRUCTION NO.
TYPE
14
<port number>
Reply structure:
STATUS
100 – OK
Binary:
Byte Index
Function
Value (hex)
MOT/BANK
<bank number>
2
0
Targetaddress
$01
VALUE
<value>
0/1
VALUE
don’t care
1
Instruction
Number
$0e
2
Type
$07
3
Motor/
Bank
$02
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$01
4.6.13.2 GIO (get input/output)
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.
Internal function: the specified line is read.
Related commands: SIO, WAIT
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
27
Mnemonic: GIO <port number>, <bank number>
Binary representation:
INSTRUCTION NO.
15
Reply in direct mode:
STATUS
100 – OK
Binary:
Byte Index
Function
Value (hex)
Reply:
Byte Index
Function
Value (hex)
1
TYPE
<port number>
MOT/BANK
<bank number>
VALUE
don’t care
VALUE
<status of the port>
0
Targetaddress
$01
Instruction
Number
1
2
Type
$0f
$00
0
Hostaddress
$02
1
Targetaddress
$01
2
Status
$64
3
Motor/
Bank
$01
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
3
Instructio
n
$0f
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$01
7
Operand
Byte0
$2e
GPIO
Figure 4.2 GPIO connector of TMCM-1640
PROVIDED SIO AND GIO COMMANDS
Pin
3
4
5
6
Digital
x
x
x
Analog
x
-
www.trinamic.com
GIO <port>, <bank>
GIO 0, 1
GIO 0, 0
GIO 1, 0
GIO 0, 2
SIO <port>, <bank>, <value>
SIO 0, 2, <value>
Value range
0… 4095
0/1
0/1
0/1
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
28
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
Mnemonic: CALC <op>, <value>
Binary representation:
COMMAND
19
0
1
2
3
4
5
6
7
8
9
TYPE <op>
ADD – add to accu
SUB – subtract from accu
MUL – multiply accu by
DIV – divide accu by
MOD – modulo divide by
AND – logical and accu with
OR – logical or accu with
XOR – logical exor accu with
NOT – logical invert accu
LOAD – load operand to accu
MOT/BANK
don’t care
VALUE
<operand>
Example:
Multiply accu by -5000
Mnemonic: CALC MUL, -5000
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$13
2
Type
$02
3
Motor/
Bank
$00
4
Operand
Byte3
$FF
5
Operand
Byte2
$FF
6
Operand
Byte1
$EC
7
Operand
Byte0
$78
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
29
4.6.15 COMP (compare)
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:
COMMAND
20
TYPE
don’t care
MOT/BANK
don’t care
VALUE
<comparison value>
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
COMP 1000
JC GE, Label
//get axis parameter, type: no. 1 (actual position), motor: 0, value: 0 don’t care
//compare actual value to 1000
//jump, type: 5 greater/equal, the label must be defined somewhere else in the
program
Binary format of the COMP 1000 command:
Byte Index
0
1
2
Instruction
Function
TargetType
Number
address
Value (hex)
$01
$14
$00
www.trinamic.com
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$03
7
Operand
Byte0
$e8
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
30
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:
COMMAND
21
TYPE
0
1
2
3
4
5
6
7
8
9
ZE - zero
NZ - not zero
EQ - equal
NE - not equal
GT - greater
GE - greater/equal
LT - lower
LE - lower/equal
ETO - time out error
EAL - external alarm
MOT/BANK
don’t care
VALUE
<jump address>
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:
Byte Index
0
1
2
3
Instruction
Function
TargetType
Motor/
Number
address
Bank
Value (hex)
$01
$15
$05
$00
www.trinamic.com
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$0a
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
31
4.6.17 JA (jump always)
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:
COMMAND
22
TYPE
don’t care
MOT/BANK
don’t care
VALUE
<jump address>
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:
Byte Index
0
1
2
3
4
Instruction
Function
TargetType
Motor/
Operand
Number
address
Bank
Byte3
Value (hex)
$01
$16
$00
$00
$00
www.trinamic.com
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$14
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
32
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.
Example: Call a subroutine
Loop:
MVP ABS, 0, 10000
CSUB SubW
//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.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:
COMMAND
23
TYPE
don’t care
MOT/BANK
don’t care
VALUE
<subroutine address>
Binary format of the CSUB SubW command assuming that the label SubW is at address 100:
Byte Index
0
1
2
3
4
5
6
Instruction
Function
TargetType
Motor/
Operand
Operand
Operand
Number
address
Bank
Byte3
Byte2
Byte1
Value (hex)
$01
$17
$00
$00
$00
$00
$00
7
Operand
Byte0
$64
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
ignored if the stack is empty.
Related command: CSUB
Mnemonic: RSUB
Binary representation:
COMMAND
24
Binary format of RSUB:
Byte Index
0
Function
Targetaddress
Value (hex)
$01
www.trinamic.com
TYPE
don’t care
1
Instruction
Number
$18
2
Type
$00
MOT/BANK
don’t care
3
Motor/
Bank
$00
4
Operand
Byte3
$00
VALUE
don’t care
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
33
4.6.19 WAIT (wait for an event to occur)
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:
COMMAND
TYPE
0 TICKS - timer ticks*1
1 POS - target position reached
MOT/BANK
don't care
0
2 REFSW – reference switch
0
3 LIMSW – limit switch
0
27
4 RFS – reference search
completed
* One tick is 10msec (in standard firmware).
0
VALUE
<no. of ticks*>
<no. of ticks* for timeout>,
0 for no timeout
<no. of ticks* for timeout>,
0 for no timeout
<no. of ticks* for timeout>,
0 for no timeout
<no. of ticks* for timeout>,
0 for no timeout
Example:
Wait for motor to reach its target position, without timeout
Mnemonic: WAIT POS, 0, 0
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$1b
2
Type
$01
3
Motor/
Bank
$01
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
34
4.6.20 STOP (stop TMCL program execution)
This function stops executing a TMCL program. The host address and the reply are only used to transfer the
instruction to the TMCL program memory.
Every standalone TMCL program needs the STOP command at its end. It is not to be used in direct mode.
Internal function: TMCL instruction fetching is stopped.
Related commands: none
Mnemonic: STOP
Binary representation:
COMMAND
28
TYPE
don’t care
MOT/BANK
don’t care
VALUE
don’t care
Example:
Stop TMCL execution
Mnemonic: STOP
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$1c
2
Type
$00
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
35
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.
Related commands: CALC, COMP, JC, AAP, AGP
Mnemonic: CALCX <operation>
Binary representation:
COMMAND
TYPE <operation>
33
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
MOT/BANK
don’t care
VALUE
don’t care
Example:
Multiply accu by X-register
Mnemonic: CALCX MUL
Binary:
Byte Index
Function
Value (hex)
0
Targetaddress
$01
www.trinamic.com
1
Instruction
Number
$21
2
Type
$02
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
36
4.6.22 AAP (accumulator to axis parameter)
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:
COMMAND
34
TYPE
<parameter number>
Reply in direct mode:
STATUS
100 – OK
VALUE
don’t care
MOT/BANK
0
VALUE
<don't care>
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
CALC MUL, 4
AAP 0, 0
JA Start
//
//
//
//
get value of analogue input line 0
multiply by 4
transfer result to target position of motor 0
jump back to start
Binary format of the AAP 0, 0 command:
Byte Index
0
1
2
Instruction
Function
TargetType
Number
address
Value (hex)
$01
$22
$00
www.trinamic.com
3
Motor/
Bank
$00
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
37
4.6.23 AGP (accumulator to global parameter)
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:
COMMAND
35
TYPE
<parameter number>
Reply in direct mode:
STATUS
100 – OK
VALUE
don’t care
MOT/BANK
<bank number>
VALUE
don’t care
Example:
Copy accumulator to TMCL user variable #3
Mnemonic: AGP 3, 2
Binary:
Byte Index
Function
Value (hex)
0
1
Target- Instruction
address
Number
$01
$23
2
Type
$03
3
Motor/
Bank
$02
4
Operand
Byte3
$00
5
Operand
Byte2
$00
6
Operand
Byte1
$00
7
Operand
Byte0
$00
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.
Related commands: none
Mnemonic: UF0… UF7 <parameter number>
Binary representation:
COMMAND
64… 71
Reply in direct mode:
Byte Index
0
Function
Targetaddress
Value (hex)
$02
www.trinamic.com
TYPE
user defined
1
Targetaddress
$01
2
Status
user
defined
MOT/BANK
user defined
3
Instructio
n
64… 71
4
Operand
Byte3
user
defined
VALUE
user defined
5
Operand
Byte2
user
defined
6
Operand
Byte1
user
defined
7
Operand
Byte0
user
defined
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
38
4.6.25 Command 136 - Get Firmware Version
Command 136 is used for reading out the module type and firmware version as a string or in binary format.
(Motor/Bank and Value are ignored.)
Other control functions can be used with axis parameters.
Command
Type
136
0 – string
1 – binary
Parameter
Description
Firmware version Get the module type and firmware revision as a
string or in binary format. (Motor/Bank and Value
are ignored.)
TYPE SET TO 0 - REPLY AS A STRING:
Byte index
1
2… 9
Contents
Host Address
Version string (8 characters, e.g. 1640V200)
There is no checksum in this reply format!
TYPE SET TO 1 - VERSION NUMBER IN BINARY FORMAT:
The version number is output in the value field.
Byte index in value field
1
2
3
4
www.trinamic.com
Contents
Version number, low byte
Version number, high byte
Type number, low byte
Type number, high byte
Access
read
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
5
39
Axis Parameter Overview (SAP, GAP, STAP, RSAP, AAP)
The following section describes all axis parameters that can be used with the SAP, GAP, STAP, RSAP and AAP
commands.
MEANING OF THE LETTERS IN COLUMN ACCESS:
Access
type
R
W
E
Related
command(s)
GAP
SAP, AAP
STAP, RSAP
Number
0
Axis Parameter Description
Range [Unit]
Target position The target position of a currently executed ramp. -2147483648…
+2147483647
Actual position Set/get the position counter without moving the -2147483648…
motor.
+2147483647
Target speed
Set/get the desired target velocity.
-200000… +200000
[rpm]
Actual speed
The actual velocity of the motor.
-2147483648…
+2147483647
[rpm]
Max. absolute
The maximum velocity used for velocity ramp in 0 +200000
ramp velocity
velocity mode and positioning mode. Set this [rpm]
value to a realistic velocity which the motor can
reach!
Max current
Set/get the max allowed motor current.
0… +20000
*This value can be temporarily exceeded marginal due to the [mA]
Access
RW
MVP
Target Maximum velocity at which end position flag can
reached velocity be set. Prevents issuing of end position when
the target is passed at high velocity.
Motor
halted If the actual speed is below this value the motor
velocity
halted flag will be set.
MVP
target Maximum distance at which the position end
reached
flag is set.
distance
Acceleration
Acceleration parameter for ROL, ROR, and the
velocity ramp of MVP.
Ramp generator The actual speed of the velocity ramp used for
speed
positioning and velocity mode.
0 +200000 [rpm]
RWE
0 +200000 [rpm]
RWE
0… +100000
RWE
1
2
3
4
6
Description
Parameter readable
Parameter writable
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.
RW
RW
R
RWE
RWE
operation of the current regulator.
7
9
10
11
13
25
26
27
28
29
30
Thermal
winding time
constant
I²t limit
I²t sum
I²t exceed
counter
Clear I²t
exceeded flag
Minute counter
www.trinamic.com
0… +100000
[RPM/s]
-2147483648…
+2147483647
[rpm]
Thermal winding time constant for the used 0… +4294967295
motor. Used for I²t monitoring.
[ms]
RWE
An actual I²t sum that exceeds this limit leads to
increasing the I²t exceed counter.
Actual sum of the I²t monitor.
Counts how often an I²t sum was higher than
the I²t limit.
Clear the flag that indicates that the I²t sum has
exceeded the I²t limit.
Counts the module operational time in minutes.
0… +4294967295
RWE
0… +4294967295
0… +4294967295
R
RWE
(ignored)
W
0… +4294967295
[min]
RWE
R
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
31
133
134
146
150
151
152
155
156
159
161
162
Axis Parameter
BLDC
re-initialization
PID regulation
loop delay
Current
regulation loop
delay
Activate ramp
40
Description
Restart the timer and initialize encoder.
Range [Unit]
(ignored)
Access
W
Delay of the position and velocity
0… +10
[ms]
0… +10
[50µs]
RWE
Delay of the PID current regulator.
1: Activate velocity ramp generator for position 0/1
and velocity mode. (Allows usage of acceleration
and positioning velocity for MVP command.)
Actual
motor Get actual motor current.
-2147483648…
current
+2147483647 [mA]
Actual voltage
Actual supply voltage.
0… +4294967295
Actual
driver Actual temperature of the motor driver.
0… +4294967295
temperature
Target current
Get desired target current or set target current to -20000… +20000
activate current regulation mode. (+= turn motor [mA]
in right direction; -= turn motor in left direction)
Error/Status
Bit 0: Overcurrent flag. This flag is set if the max. 0…+4294967295
flags
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.
Commutation
6: FOC based on hall sensor
6, 7, 8
mode
7: FOC based on encoder
8: FOC controlled (velocity mode only)
Encoder
set 1: set position counter to zero at next N channel 0/1
NULL
event.
Switch set NULL 1: set position counter to zero at next switch 0/1
event.
www.trinamic.com
RWE
RWE
R
R
R
RW
R
RWE
RWE
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
163
164
Axis Parameter Description
Encoder
clear 1: set position counter to zero only once
set NULL
0: always at an N channel event
Left stop switch When this bit is set
Activate
stop Bit 0
enable
the motor will be
switch
Bit 1
165
166
173
177
200
201
210
211
212
226
228
229
230
Range [Unit]
0/1
Access
RWE
0… 3
RWE
stopped if it is
moving in negative
direction and the
left stop switch
input
becomes
active
When this bit is set
the motor will be
stopped if it is
moving in positive
direction and the
right stop switch
input
becomes
active
Please see parameter 166 for selecting the stop
switch input polarity.
Actual encoder This value represents the internal commutation 0… 65535
commutation
offset.
offset
(0 … max. encoder steps per rotation)
Bit 0
Left stop switch Bit set: Left stop
Stop
switch
0… 3
polarity
switch input is high
polarity
Bit 1
172
Right stop switch
enable
41
Right stop switch
polarity
RWE
active
Bit clear: Left stop
switch input is low
active
Bit set: Right stop
switch input is high
active
Bit clear: Right stop
switch input is low
active
P parameter for P parameter of current PID regulator.
0… 65535
current PID
I parameter for I parameter of current PID regulator.
0… 65535
current PID
Start current
Motor current for controlled commutation. This 0… +20000
parameter is used in commutation mode.
[mA]
Current
PID Actual error of current PID regulator
-2147483648…
error
+2147483647
Current
PID Sum of errors of current PID regulator
-2147483648…
error sum
+2147483647
Actual hall
Actual hall angle value
-32767… +32767
angle
Actual encoder Actual encoder angle value
-32767… +32767
angle
Actual
Actual controlled angle value
-32767… +32767
controlled
angle
Position
PID Actual error of position PID regulator
-2147483648…
error
+2147483647
Velocity
PID Actual error of velocity PID regulator
-2147483648…
error
+2147483647
Velocity
PID Sum of errors of velocity PID regulator
-2147483648…
error sum
+2147483647
P parameter for P parameter of position PID regulator.
0… 65535
position PID
www.trinamic.com
RWE
RWE
RWE
RWE
R
R
R
R
R
R
R
R
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
234
235
241
244
245
249
250
251
253
254
Axis Parameter
P parameter for
velocity PID
I parameter for
velocity PID
Sine
initialization
speed
Init sine delay
Overvoltage
protection
Init sine mode
Description
P parameter of velocity PID regulator.
Range [Unit]
0… 65535
Access
RWE
I parameter of velocity PID regulator.
0… 65535
RWE
Velocity during initialization in init sine mode 2. -200000… +200000 RWE
Refer to axis parameter 249, too.
[rpm]
Duration for sine initialization sequence. This 0… 10000
parameter should be set in a way, that the [ms]
motor has stopped mechanical oscillations after
the specified time.
1: Enable overvoltage protection.
0/1
RWE
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)
Encoder steps per rotation.
Set the encoder direction in a way, that ROR
increases position counter.
Number of motor poles.
0, 1, 2
RWE
0… +65535
0/1
RWE
RWE
+2… +254
RWE
0/1
RWE
Encoder steps
Encoder
direction
Number of
motor poles
Hall
sensor 1: Hall sensor invert. Invert the hall scheme, e.g.
invert
used by some Maxon motors.
www.trinamic.com
42
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
43
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.
MEANING OF THE LETTERS IN COLUMN ACCESS:
Access
type
R
W
E
Related
command(s)
GAP
SAP, AAP
STAP, RSAP
Description
Parameter readable
Parameter writable
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.
MOTOR / MODULE SETTINGS
Number
253
25
26
27
28
29
30
245
Axis Parameter
Number of
motor poles
Thermal
winding time
constant
I²t limit
I²t sum
I²t exceed
counter
Clear I²t
exceeded flag
Minute counter
Overvoltage
protection
Description
Number of motor poles.
Range [Unit]
+2… +254
Access
RWE
Thermal winding time constant for the used 0… +4294967295
motor. Used for I²t monitoring.
[ms]
RWE
An actual I²t sum that exceeds this limit leads to
increasing the I²t exceed counter.
Actual sum of the I²t monitor.
Counts how often an I²t sum was higher than
the I²t limit.
Clear the flag that indicates that the I²t sum has
exceeded the I²t limit.
Counts the module operational time in minutes.
0… +4294967295
RWE
0… +4294967295
0… +4294967295
R
RWE
(ignored)
W
0… +4294967295
[min]
0/1
RWE
Description
1: restart the timer and initialize encoder.
Range [Unit]
(Ignored)
Access
W
6: FOC based on hall sensor
7: FOC based on encoder
8: FOC controlled (velocity mode only)
This value represents the internal commutation
offset.
(0 … max. encoder steps per rotation)
Motor current for controlled commutation. This
parameter is used in commutation mode.
Actual hall angle value
6, 7, 8
RWE
0… 65535
RWE
0… +20000
[mA]
-32767… +32767
RWE
Actual encoder angle value
-32767… +32767
R
Actual controlled angle value
-32767… +32767
R
1: Enable overvoltage protection.
RWE
ENCODER / INITIALIZATION SETTINGS
Number
31
159
165
177
210
211
212
241
Axis Parameter
BLDC
re-initialization
Commutation
mode
Actual encoder
commutation
offset
Start current
Actual hall
angle
Actual encoder
angle
Actual
controlled
angle
Sine
initialization
speed
www.trinamic.com
R
Velocity during initialization in init sine mode 2. -200000… +200000 RWE
Refer to axis parameter 249, too.
[rpm]
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
244
249
250
251
254
Axis Parameter Description
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.
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)
Encoder steps
Encoder steps per rotation.
Encoder
Set the encoder direction in a way, that ROR
direction
increases position counter.
Hall
sensor 1: Hall sensor invert. Invert the hall scheme, e.g.
invert
used by some Maxon motors.
44
Range [Unit]
0… 10000
[ms]
Access
RWE
0… 2
RWE
0… +65535
0/1
RWE
RWE
0/1
RWE
TORQUE REGULATION MODE
Number
6
Axis Parameter Description
Max current
Set/get the max allowed motor current.
Range [Unit]
0… +20000
This value can be temporarily exceeded marginal due to the [mA]
150
Actual
current
155
Target current
134
Current
regulation loop
delay
P parameter for
current PID
I parameter for
current PID
Current
PID
error
Current
PID
error sum
Access
RWE
operation of the current regulator.
172
173
200
201
motor Get actual motor current.
-2147483648…
+2147483647
[mA]
Get desired target current or set target current to -20000… +20000
activate current regulation mode. (+= turn motor [mA]
in right direction; -= turn motor in left direction)
Delay of the PID current regulator.
0… +10
[50µs]
R
P parameter of current PID regulator.
0… 65535
RWE
I parameter of current PID regulator.
0… 65535
RWE
Actual error of current PID regulator
-2147483648…
+2147483647
-2147483648…
+2147483647
R
Sum of errors of current PID regulator
RW
RWE
R
VELOCITY REGULATION MODE
Number
2
3
9
133
234
235
Axis Parameter Description
Target speed
Set/get the desired target velocity.
Range [Unit]
-2147483648…
+2147483647
[rpm]
Actual speed
The actual velocity of the motor.
-2147483648…
+2147483647
[rpm]
Motor
halted If the actual speed is below this value the motor 0 +200000 [rpm]
velocity
halted flag will be set.
PID regulation Delay of the position and velocity
0… +10
loop delay
[ms]
P parameter for P parameter of velocity PID regulator.
0… 65535
velocity PID
I parameter for I parameter of velocity PID regulator.
0… 65535
velocity PID
www.trinamic.com
Access
RW
R
RWE
RWE
RWE
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
228
229
Axis Parameter Description
Velocity
PID Actual error of PID velocity regulator
error
Velocity
PID Sum of errors of PID velocity regulator
error sum
45
Range [Unit]
-2147483648…
+2147483647
-2147483648…
+2147483647
Access
R
Range [Unit]
0 +200000
[rpm]
Access
RWE
R
VELOCITY RAMP PARAMETER
Number
4
11
13
146
Axis Parameter Description
Max. absolute
The maximum velocity used for velocity ramp in
ramp velocity
velocity mode and positioning mode. Set this
value to a realistic velocity which the motor can
reach!
Acceleration
Acceleration parameter for ROL, ROR, and the
velocity ramp of MVP.
Ramp generator The actual speed of the velocity ramp used for
speed
positioning and velocity mode.
Activate ramp
0… +100000
[RPM/s]
-2147483648…
+2147483647
[rpm]
1: Activate velocity ramp generator for position 0/1
PID control. (Allows usage of acceleration and
positioning velocity for MVP command.)
RWE
R
RWE
POSITION REGULATION MODE
Number
1
0
7
10
161
162
163
164
Axis Parameter Description
Actual position Set/get the position counter without moving the
motor.
Target position The target position of a currently executed ramp.
Range [Unit]
-2147483648…
+2147483647
-2147483648…
+2147483647
MVP Target
Maximum velocity at which end position flag can 0 +200000 [rpm]
reached velocity be set. Prevents issuing of end position when
the target is passed at high velocity.
MVP target
Maximum distance at which the position end flag 0… +100000
reached
is set.
distance
Encoder
set 1: set position counter to zero at next N channel 0/1
NULL
event.
Switch set NULL 1: set position counter to zero at next switch 0/1
event.
Encoder clear
1: set position counter to zero only once
0/1
set NULL
0: always at an N channel event
Bit 0
Left stop switch When this bit is set
Activate stop
0… 3
enable
the motor will be
switch
Bit 1
Right stop switch
enable
stopped if it is
moving in negative
direction and the
left stop switch
input
becomes
active
When this bit is set
the motor will be
stopped if it is
moving in positive
direction and the
right stop switch
input
becomes
active
Please see parameter 166 for selecting the stop
switch input polarity.
www.trinamic.com
Access
RW
RW
RWE
RWE
RWE
RWE
RWEP
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
166
Axis Parameter Description
Bit 0
Left stop switch
Stop switch
polarity
polarity
Range [Unit]
0… 3
Access
RWE
0… 65535
RWE
-2147483648…
+2147483647
R
Description
Actual supply voltage.
Actual temperature of the motor driver.
Range [Unit]
0… +4294967295
0… +4294967295
Access
R
R
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)
0…+4294967295
R
Bit 1
230
226
46
Right stop switch
polarity
Bit set: Left stop
switch input is high
active
Bit clear: Left stop
switch input is low
active
Bit set: Right stop
switch input is high
active
Bit clear: Right stop
switch input is low
active
P parameter for P parameter of position PID regulator. (
position PID
Position
PID Actual error of PID position regulator
error
STATUS INFORMATION
Number
151
152
156
Axis Parameter
Actual voltage
Actual driver
temperature
Error/Status
flags
Flag 0 to 15 are automatically reset. Only flag 17
must be cleared manually.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
6
47
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!
MEANING OF THE LETTERS IN COLUMN ACCESS:
Access
type
R
W
E
Related
command(s)
GGP
SGP, AGP
STGP, RSGP
Description
Parameter readable
Parameter writable
Parameter automatically restored from EEPROM after reset or power-on.
GLOBAL PARAMETERS OF BANK 0
Number
64
65
Global
parameter
EEPROM magic
Description
Setting this parameter to a different value as $E4 will 0… 255
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.
9600 baud
Default
RS485 baud rate 0
0… 7
1
2
3
4
5
6
7
66
Serial address
73
Configuration
EEPROM lock
flag
Telegram pause
time
Serial host
address
Auto start
mode
75
76
77
Range
www.trinamic.com
14400 baud
19200 baud
28800 baud
38400 baud
57600 baud
76800 baud
115200 baud
Access
RWE
RWE
Not supported by Windows!
The module (target) address for RS485 and virtual COM 0… 255
port
Write: 1234 to lock the EEPROM, 4321 to unlock it.
0/1
Read: 1=EEPROM locked, 0=EEPROM unlocked.
RWE
Pause time before the reply via RS485 is sent.
0… 255
RWE
Host address used in the reply telegrams sent back via 0… 255
RS485.
0: Do not start TMCL application after power up (default). 0/1
1: Start TMCL application automatically after power up.
Note: the current initialization has to be finished first.
RWE
RWE
RWE
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
Number
81
85
128
Global
parameter
TMCL code
protection
Do not restore
user variables
TMCL
application
status
129
Download
mode
130
132
TMCL program
counter
Tick timer
255
Suppress reply
48
Description
Range
Access
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 – user variables are restored (default)
1 – user variables are not restored
0 –stop
1 – run
2 – step
3 – reset
0 – normal mode
1 – download mode
Attention:
Download mode can only be used if the motor has been
stopped first. Otherwise the download mode setting will
be disallowed.
During download mode the motor driver will be
deactivated and the actuator will be turned off.
The index of the currently executed TMCL instruction.
0, 1, 2, 3
RWE
0/1
RWE
0… 3
R
0/1
R
o… 2047
R
A 32 bit counter that gets incremented by one every 0…
RW
+4294967295
millisecond. It can also be reset to any start value.
0 – reply (default)
0/1
RW
1 – no reply
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.
Up to 256 user variables are available.
MEANING OF THE LETTERS IN COLUMN ACCESS:
Access
type
R
W
E
Related
command(s)
GGP
SGP, AGP
STGP, RSGP
Description
Parameter readable
Parameter writable
Parameter automatically restored from EEPROM after reset or power-on.
GLOBAL PARAMETERS OF BANK 2
Number
Global parameter
Description
Range
Access
0… 55
General purpose variable #0… 55
for use in TMCL applications
RWE
56… 255
General purpose variables #56… #255
for use in TMCL applications
-231…+231
(int32)
-231…+231
(int32)
www.trinamic.com
RW
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
7
7.1
49
Motor Regulation
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.
enable/
disable
ramp
(SAP 146)
target
position
(SAP 0)
position
PID
values
target
velocity
(SAP 2)
position
PID
target
velocity
max
target
velocity
(SAP 4)
velocity
PID
values
accelerat.
(SAP 11)
ramp
generator
ramp generator
velocity
velocity
PID
max
target
current
(SAP 6)
target
current
(SAP 155)
target
current
current
PID
values
FOC based
current PID
motor
actual current
current
measurement
actual commutation angle
actual velocity
actual position
current regulation mode
velocity regulation mode
position regulation mode
7.1 Cascaded regulation
www.trinamic.com
hall sensor
or encoder
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
50
7.2 Current Regulation
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:
𝑡𝑃𝐼𝐷𝐷𝐸𝐿𝐴𝑌 = 𝑥𝑃𝐼𝐷𝑅𝐿𝐷 ⋅ 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
PPARAM/256
X
IPARAM/65536
ITARGET
Clip
˗
IMax
+
Clip
ICLIP
eSUM
X
+
Clip
-32768..
+32767
SVPWM
IACTUAL
Figure 7.2 Current regulation
Parameter Description
IACTUAL
Actual motor current (GAP 150)
ITARGET
Target motor current (SAP 155)
IMax
Max. motor current (SAP 6)
eSUM
Error sum for integral calculation (GAP 201)
PPARAM
Current P parameter (SAP 172)
IPARAM
Current I parameter (SAP 173)
PARAMETERIZING THE CURRENT REGULATOR SET
1.
2.
3.
4.
Set the P parameter and the I parameter to zero.
Start the motor by using a low target current (e.g. 1000 mA).
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.
Do the same with the current I parameter.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
51
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.
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:
𝑡𝑃𝐼𝐷𝐷𝐸𝐿𝐴𝑌 = 𝑥𝑃𝐼𝐷𝑅𝐿𝐷 ⋅ 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
PPARAM / 256
IPARAM / 65536
vRAMPGEN
Clip
Clip
Clip
eSUM
VMax
ICLIP
vACTUAL
Figure 7.3 Velocity regulation
Parameter
Description
vACTUAL
Actual motor velocity (GAP 3)
vRAMPGEN
Target velocity of ramp generator (SAP 2, GAP 13)
vMax
Max. target velocity (SAP 4)
eSUM
Error sum for integral calculation (GAP 229)
PPARAM
Velocity P parameter (SAP 234)
IPARAM
Velocity I parameter (SAP 235)
IMax
Max. target current (SAP 6)
ITarget
Target current for current PID regulator (GAP 155)
PARAMETERIZING THE VELOCITY REGULATOR SET
1.
2.
Set the velocity I parameter to zero.
Start the motor by using a medium target velocity (e.g. 2000 rpm).
www.trinamic.com
ITARGET
IMax
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
3.
4.
52
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.
The lasting 10 or 20% speed difference can be reduced by slowly increasing the velocity I
parameter.
7.4 Velocity Ramp Generator
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:
𝑡𝑃𝐼𝐷𝐷𝐸𝐿𝐴𝑌 = 𝑥𝑃𝐼𝐷𝑅𝐿𝐷 ⋅ 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
nTARGET
nACTUAL
PPARAM/256
Clip
Clip
±65535
VMAX
VTARGET
Figure 7.4 Positioning regulation
Parameter
Description
nACTUAL
Actual motor position (GAP 1)
nTARGET
Target motor position (SAP 0)
PPARAM
Position P parameter (SAP 130, SAP 230)
VMAX
Max. allowed velocity (SAP 4)
VTARGET
New target velocity for ramp generator (GAP 13)
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.
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
3.
4.
53
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.
Reaching the target position is signaled by setting the position end flag.
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
MVP target reached distance
Slow-down-distance
|Velocity|
Max. positioning
velocity
Motor regulated by
Velocity PID
Acceleration
MVP target
reached velocity
Motor regulated by
combination of
Velocity and Position
PID
Position
Target position
(set via MVP)
Target reached flag
only set when velocity
and position are in
this area.
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!
www.trinamic.com
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
8
54
Temperature Calculation
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:
=
𝑡
15
=
𝑡
=
(
Example 1:
ADC = 1000
RNTC ≈ 6.81
10
𝑡
011
1
=
)
1
1
Example 2:
ADC = 1200
RNTC ≈ 5.31
T ≈ 35
9
𝑡
T ≈ 42
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:
𝑡=
𝑡
1000
1000
𝑡
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.
a)
𝑡
𝑡=
𝐴
𝐴
1
00
= 1
00
b)
𝑡
𝑡=
𝐴
𝐴
1
00
= 5
00
c)
𝑡
𝑡=
𝐴
𝐴
1
00
= 11
d)
𝑡
𝑡=
𝐴
𝐴
1
00
=
www.trinamic.com
00
11 00
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
10 Life Support Policy
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.
© TRINAMIC Motion Control GmbH & Co. KG 2013.
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.
www.trinamic.com
55
TMCM-1640 TMCL Firmware V2.06 Manual (Rev. 2.03 / 2013-SEP-03)
56
11 Revision History
11.1 Firmware Revision
Version
2.00
2.02
Date
2012-JUN-10
2012-DEC-14
Author
ED
ED
2.05
2013-APR-03
ED
2.06
2013-AUG-30
ED
Description
New FOC firmware
- Axis parameter 209 deleted.
- Axis parameter 241 (sine initialization speed) added.
- Axis parameter 31 (BLDC re-initialization) added.
- Global parameter 77 (auto start mode) updated.
- Global parameter 129 (download mode) updated.
- Several axis parameter values updated.
- Axis parameter 159 updated: new FOC controlled
mode.
- Axis parameter 212 (actual controlled angle) new.
- Bug fixed: adc offset calibration on power on
- Bug fixed: encoder initialisation in encoder-init-mode
1 with inverted hall sensor signals
- AP 238 removed (mass inertia const)
- AP 239 removed (BEMF const)
- AP 240 removed (motor coil resistance)
11.2 Document Revision
Version
2.00
Date
2012-JUL-31
Author
SD
2.01
2013-JAN-03
SD
2.02
2013-APR-04
SD
2.03
2013-SEP-03
JP
Description
Manual for new Field Orientated Control (FOC) firmware
- Commands SIO and GIO added
- Axis parameters updated
- Motor regulation updated
- Axis parameter 209 deleted.
- Axis parameter 241 (sine initialization speed) added.
- Axis parameter 31 (BLDC re-initialization) added.
- Global parameter 77 (auto start mode) updated.
- Global parameter 129 (download mode) updated.
- Several axis parameter values updated.
- Axis parameter 159 updated: new FOC controlled
mode.
- Axis parameter 212 (actual controlled angle) new.
Removed Parameters 238,239,240, updated revision
history.
12 References
[TMCM-1640]
[TMCL-IDE]
[TMCM-BLDC]
[TMC603]
[QBL4208]
TMCM-1640 Hardware Manual
TMCL-IDE User Manual
TMCM-BLDC User Manual
TMC603 Datasheet
QBL4208 Manual
Please refer to our homepage http://www.trinamic.com.
www.trinamic.com