2 Life support policy .......................................................................................................................................................5
3.1.1 Power supply ............................................................................................................................................. 6
3.1.2 Motor ............................................................................................................................................................ 6
3.1.3 CAN and RS485 ..........................................................................................................................................6
3.1.6 I / O ..............................................................................................................................................................8
4.1 Power supply requirements...........................................................................................................................14
4.2 Bus Interface.......................................................................................................................................................14
4.2.1 Terminating the RS485 network.........................................................................................................14
5.6 General Functions (explore using the Windows based demo software).........................................17
5.7 Temperature, Current and Voltage monitoring functions.....................................................................17
5.8 Programmable motor current limit..............................................................................................................18
6 Revision History ..........................................................................................................................................................19
Table 1.1: Order codes .........................................................................................................................................................4
Table 3.1: Pinning of power supply connector ............................................................................................................ 6
Table 3.2: Pinning of motor connector........................................................................................................................... 6
Table 3.3: Pinning of CAN and RS485 connector ......................................................................................................... 6
Table 3.4: Pinning of step / dir connector.....................................................................................................................7
Table 3.5: Pinning of Encoder, Hall, Temperature connector ...................................................................................7
Table 3.6: Pinning of I / O connector.............................................................................................................................. 8
Table 3.7: Programming connector (to be used by Trinamic only)........................................................................8
The TMCM-171 is a controller / driver module for high performance servo drives based on brushless
DC motors. It gives a high resolution like a stepper motor coupled with the high dynamic, high
velocity and high reliability of a BLDC drive. The motors and switches can be connected easily with
screw terminals. A build-in ramp generator allows parameterized smooth positioning. The TMCM-171
supports BLDC motors with nearly any number of poles and incremental encoders with nearly any
resolution.
The TMCM-171 integrates a position regulator and a ramp generator, to allow for velocity modes.
The module can be remote controlled via a CAN or RS485 interface. Additionally the TMCM-171 is
equipped with a step direction interface. Stand alone operation is also possible.
Its integration into the TRINAMIC family of motor control modules makes it easy to choose either a
stepper motor or a BLDC motor or any combination for an application.
Applications
• Replacement of servo drive by high reliability / low cost BLDC drive
• Fast and precise positioning
• Smooth very low to very high constant / variable velocity drives
• Very high velocity stability drives
Motor / Encoder type
• Sine (or block) commutated BLDC motors with encoder and with / without additional hall sensors
• Hall sensor based motors can be operated without encoder
• Motor power from a few watts to 800W
• Motor velocity up to 100,000 RPM (electrical field)
• Incremental encoder (2 channel with option for N-channel) with resolution from 256 to 30000 /
motor rotation (opt. per electrical field rotation)
TRINAMIC Motion Control GmbH & Co. KG does not
authorize or warrant any of its products for use in life
support systems, without the specific written consent
of TRINAMIC Motion Control GmbH & Co. KG.
Life support systems are equipment intended to
support or sustain life, and whose failure to perform,
when properly used in accordance with instructions
provided, can be reasonably expected to result in
personal injury or death.
Information given in this data sheet is believed to be
accurate and reliable. However no responsibility is
assumed for the consequences of its use nor for any
infringement of patents or other rights of third
parties, which may result form its use.
Opto-decoupled non inverted
step input
Opto-decoupled inverted step
input
Opto-decoupled non inverted
direction input
Opto-decoupled inverted
direction input
Table 3.4: Pinning of step / dir connector
1 S + non inverted step input
2 S - inverted step input
3 GND GND
4 D + non inverted direction input
3.1.5 Encoder, Hall, Temperature1
Pin Name Function Pin Name Function
Connector 1 (screw) Connector 3 (JST 1x8)
1 +5V 5V supply for encoder 1 +5V 5V supply for encoder
2 GND GND 2 GND GND
3 E I Encoder indexer 3 E I Non inverted encoder indexer
4 E A Encoder channel A 4 E I - Inverted encoder indexer
5 E B Encoder channel B 5 E A Non inverted encoder channel A
6 +5V 5V supply for hall sensors 6 E A - Inverted encoder channel A
7 GND GND 7 E B Non inverted encoder channel B
8 H1 Hall sensor signal 1 8 E B - Inverted encoder channel B
9 H2 Hall sensor signal 2
10 H3 Hall sensor signal 3 1 +5V 5V supply for hall sensors
11 +5V 5V supply (reference) 2 GND GND
12 TEMP Temperature input 3 H1 Hall sensor signal 1
Connector 2 (JST 2x3 pin)2
1 5 H3 Hall sensor signal 3
Close to use differential encoder ( B ) of
connector 3. Leave open otherwise.
2
3 7 +5V +5V
Close to use differential encoder ( A ) of
connector 3. Leave open otherwise.
4
5 -- -- --
Close to use differential encoder ( I ) of
connector 3. Leave open otherwise.
6
4 H2 Hall sensor signal 2
6 GND GND
8 TEMP Temperature input
-- -- --
Connector 4 (JST 1x8)
Table 3.5: Pinning of Encoder, Hall, Temperature connector
1
Signals with identical names are electrically identical.
2
This connector serves as three jumpers to enable or disable the differential encoder of connector 3.
The inputs “E I”, “E A” and “E B” of connector 1 or 3 are for single ended encoders, if the jumpers of
connector 2 are open.
1 +5V Constant +5V output
2 GND GND
3 OUT1 Digital output 1
4 OUT2 Digital output 2
5 AIN3 Analog input 3, 0-5V (free usage in TMCL)
6 AIN2 Analog input 2, 0-5V (free usage in TMCL)
7 GND GND
8 DIRIN Analog input 0, 0-5V (free usage in TMCL), has 10k pull up resistor to +5V
9
10 /STOP Reference switch input
The analog inputs can also be used as digital inputs. Threshold is ½ of maximum input voltage.
AIN1
Analog input 1 0-10V (free usage in TMCL or special function for stand alone
operation)
Table 3.6: Pinning of I / O connector
3.1.7 Programming connector
Pin Name Function Pin Name Function
1,3,4 Not connected 6 GND GND
2 /MCLR To be used by Trinamic only 7 PGD To be used by Trinamic only
5 PGC To be used by Trinamic only 8 +5V Constant +5V output
Table 3.7: Programming connector (to be used by Trinamic only)
3.2 Jumper “Select Opto In”
An open jumper deactivates the opto-decoupled step / direction inputs at the screw terminal and
activates inputs at the JST connector. Closing the jumper the screw terminal gets active and JST
connector inactive.
The schematic shows a typical application circuit using CAN bus interface. Optionally the unit allows
connection of motor hall sensors and encoder I- (N-)channel as well as further digital / analog pins
and different interface options.
The operational ratings show the intended / the characteristic range for the values and should be
used as design values. An operation within the limiting values is possible, but shall not be used for
extended periods, because the unit life time may be shortened. In no case shall the limiting values be
exceeded.
Symbol Parameter Min Typ Max Unit
VS Power supply voltage for operation 12.5 14 - 48 52 V
V
Maximum power supply voltage (for surge) 60 V
SMAX
V
Under voltage switch off trip point 9.5 10 10.5 V
SLOOFF
V
Under voltage switch on trip point 10.5 12 12.5 V
SON
V
VSD
SOFF
Over voltage switch off trip point (Feature can be
switched off, then V
limit applies)
SMAX
Power supply voltage for module operation with motor
disabled
Power supply current
IS
* maximum rating due to connector limitations when
using screw terminal connectors
PID
I
I
I
I
f
CHOP
V5
MCB
MCS
MPB
MPS
Module idle power consumption without encoder / hall
sensor
5 Volt (+-4%) output external load (encoder plus hall
sensors plus other load)
Continuous Motor RMS current in block commutation
mode (module surface at maximum 85°C)
Continuous Motor RMS current in sine commutation
mode (module surface at maximum 85°C)
Short time Motor current in acceleration periods
It is not recommended to set motor current above I
!
MC
Short time Motor current in acceleration periods
It is not recommended to set motor current above I
!
MC
Chopper frequency 20 kHz
52 55 58 V
7 8 9.5 V
0.04 (P
Motor
+3..10W)
/ V
S
I
MOT
or
16A*
2.4 W
0 200 mA
16 A
20 A
20 A
24 A
A
T
VI
Motor output slope (U, V, W) 100 ns
SL
Logic input voltage on digital inputs, encoder and hall
-0.3 V
sensor inputs
CC
0.3
+
V
IIH Pull-up resistor current for hall inputs 50 250 400 µA
IIE Pull-up resistor current for encoder inputs (1kOhm) 5 mA
IO
Logic output current on digital outputs (open drain
output with integrated 1k pullup resistor to +5V)
2 A
VO Output voltage on digital outputs with external load 55 V
V
Analog input voltage on input 1 -24 0 – 10 24 V
IA1
V
Analog input voltage on input 0, 2, 3 -24 0 – 5 24 V
IA023
EV Exactness of voltage measurement -5 +5 %
EC
Exactness of current measurement (the measured coil
current value might not correspond to the RMS current,
The power supply should be designed in a way, that it supplies the nominal motor voltage at the
desired maximum motor power. In no case shall the supply value exceed the upper / lower voltage
limit. The BLDC motor unit uses a chopper principle, i.e. the power supply to the motor is pulsed at a
frequency of 20kHz. 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.
Therefore we recommend to
a) keep power supply cables as short as possible
b) use large diameter for power supply cables
c) if the distance to the power supply is large (i.e. more than 2-3m), use a robust 4700µF or
larger additional filtering capacitor located near to the motor driver unit.
An effect the power supply has to cope with, is, that the motor can feed back substantial current into
the power supply whenever it is actively braked! While this generally is a positive effect (because it
saves energy), precautions have to be taken, to limit the supply voltage to within the operational
limits. The TMCM-171 contains an overvoltage protection circuit, which disables braking whenever the
upper supply voltage limit is exceeded. This automatic function may lead to an unwanted behavior,
i.e. overshooting the target position, and thus can be disabled. Disabling the overvoltage protection
should only be done, provided that the user takes additional precautions to limit the voltage:
It is recommended to use
a) a large capacitor on the power supply lines able to store substantial part of feed back energy
b) a zener / suppressor diode circuitry, limiting the power supply voltage to a maximum of 52-
60V
4.2 Bus Interface
The TMCM-171 can be operated via CAN or RS485 in the same way. CAN bus and RS485 require a
termination resistor at both ends of the cable (but not at every unit).
4.2.1 Terminating the RS485 network
For RS485 in addition to the termination resistor a termination network is required, which forces an
“inactive” level to the line, when no driver is on. Typically, use a 1K resistor to + 5V for RS485+ line
and a 1K resistor to GND for the RS485- line at some point of the network.
5.1 Setting the basic values for operation (using the
demonstration application)
The TMCM-171 can use nearly any BLDC motor and encoder type. However, care has to be taken to
correctly set the motor pole count (default: 8) and encoder resolution (default: 4096) and direction
(default: Encoder gives same direction as motor) before trying to operate the motor! If a hall sensor is
used, please check if the hall sensor polarity is to be reversed (try operating the motor in block
commutation mode, first). Also choose a fitting initialization mode (2 is most universal) and set the
corresponding parameters (please see chapter on start up).
The motor behavior afterwards may still give unsatisfactory results: The next step is to tune the PID
parameters.
For these basic settings, the Windows based demonstration application can be used. It requires
connection to the CAN or the RS485 interface. As a first step use the TMCL-IDE to set the parameter
“Telegram pause time” to a value of about 20. Further basic settings are required for motor start up
(see next chapter).
To avoid motor operation or damage, before the unit is completely parameterized, use a
Hint:
supply voltage of only 8V! This disables the motor.
5.2 Start up for encoder based commutation
The TMCM-171 uses an incremental encoder for motor commutation. Incremental means, that the
encoder does not give an absolute position reference. Thus, the unit needs an internal start up
procedure, which determines the encoder position with respect to the actual pole motor orientation.
The TMCM-170 provides basically two modes for encoder initialization:
Mode 0 uses additional motor hall sensors for the start up phase. Therefore, the motor can not do a
precise positioning until it has done at least one electrical rotation. This can be perceived
by a somehow rough behavior on the first positioning run.
We recommend using this mode, when the motor has hall sensors and mode 1 does not
give reliable results.
However, the motor hall sensors typically are not as precise, as this would be desired for
sine commutation. To accomplish with the hall sensor error and hysteresis, you can set the
corresponding parameters “Init Sine Block Offset CW” and CCW.
Mode 1 drives the motor field into a known position and then evaluates the encoder position.
While this is a very precise scheme, it is susceptible to external force applied to the rotor:
The rotor is not to be blocked in any direction. Additionally external mechanical torque
applied to the axis should be kept low. To use this mode, it is important to set the “Sine
Initialization Current A” as high as possible (within the 20A limit). Default value is 10A. You
can set Sine Initialization Current B to a somewhat lower value (at least ½ of Current A) to
give optimum results. The best setting has do be determined for a given motor. To allow
for minimum motor movement upon initialization, this mode also checks the hall sensor
positions.
Mode 2 is the same as mode 1, but does not check if the motor has hall sensors.
Mode 3 is the most precise and reliable initialization mode: It uses the encoder N-channel for
initialization. To first find the N-channel reference position, the motor is turned by up to
one rotation, until the N-channel is found positive. The velocity and direction can be
specified using the parameter “Sine Init Velocity”. After finding the reference position, the
“Actual Commutation Offset” gives the angular relationship between motor and encoder.
Therefore this parameter has to be stored correctly in EEPROM before power on! Do not
enable this mode, before the parameter has been set correctly. Mode 4 helps for the very
first initialization of this mode.
Mode 4 helps to do a first initialization and tuning of mode 3. It searches for the N-channel
reference point first, and then does a mode 2 initialization to determine the correct setting
for the “Actual Commutation Offset”. The encoder N-channel polarity has to be high active
for this mode (the actual setting of the encoder null polarity has no influence in this mode),
and, additionally, you have to specify the polarity of the encoder A- and B-channel upon Nchannel activity using the setting “Encoder Null Polarity”, bits 1 and 2. The correct setting of
this depends on the encoder. If the N-channel referencing fails, the motor does two full
rotations and then stops. Try again with reversing the “Encoder Null Polarity”. After
successfully initializing the “Actual Commutation Offset”, you can try moving the motor and
tune the offset, if desired. Then store the offset and switch to mode 3. If any encoder errors
are flagged during operation of the motor, retry with a modified setting for A- and Bchannel polarity.
Attention:
The quality of the initialization phase result can be checked by rotating the motor left and right at the
maximum velocity (use a velocity setting slightly higher than the motor can follow). Maximum velocity
for left and right direction shall not differ by more than a few percent. Also make some checks if
results are reproducible.
Whenever changing one of these parameters, re-power the unit to restart initialization phase!
Initialization modes 1 to 4 apply a high current to the motor for a few seconds. Be sure
to parameterize the initialization current correctly (i.e. not more than 2* the maximum
rated motor current) before first powering on the unit.
5.3 Encoder setting
The N-channel (index channel) of the encoder is not required for motor operation, but it is very good
for motor initialization, because it gives an absolute and exact reference point. So, the motor
initialization modes 3 and 4 use the N-channel for motor initialization. Behavior of the N-channel
signal is very dependent on the encoder type and has to be taken into account for the setting of the
TMCM171 encoder interface. Please refer to the following figure for correct setting of the Encoder Null
Polarity flag.
A wrong setting may either hinder the module from initializing the sine mode, or might lead to the
Encoder Error flag being set, in spite of correct encoder function.
The module can be used without an encoder. In this case, set the encoder resolution parameter (SGP
250) to the hall sensor resolution, i.e. 3 times the number of motor poles. Example: For a 4 pole
motor set the encoder resolution to 12. To avoid oscillations in positioning mode, the algorithm in
this mode stops regulation, as soon as the target distance is below the setting as determined by
“MVP target reached distance”. Adapt this setting to your needs. Switch the module to hall sensor
based commutation permanently in order to skip encoder initialization procedure in this configuration.
Please be aware, that the hall sensor resolution is very low, when compared to an encoder, and thus,
the PID regulator parameterization values have to be set much higher than the default setting.
Without encoder, the velocity measurement is not available. You may want to set a lower value than
the default for the “PWM Hysteresis” setting to get a softer response upon target reaching.
5.5 Stop switch
For positioning applications, typically some kind of global initialization is required. This can either be
done via a central unit operating the motor via its bus interface, or a reference switch can be
connected to the stop input (pull down to 0V at reference point). The position counter can be
automatically cleared when this point is reached. Be careful not to apply a voltage different from GND
to this digital input!
5.6 General Functions (explore using the Windows based
demo software)
The TMCM-171 module can either be remote controlled via the PC demonstration software or a user
specific program. The function of the stand alone mode can be modified by the user by writing
initialization values to the on-board EEPROM, e.g. a maximum rotation velocity, motor current limit
and rotation direction. For more detailed software information refer to the TMCM-170 Module –
Reference and Programming Manual (see 7: References).
5.7 Temperature, Current and Voltage monitoring functions
Name LED / Output Action Meaning
PWR Power On At least +5V power supply
The current limit LED blinks upon under voltage switch
off
Motor PWM is reduced due to exceeding the set motor
current limit or overvoltage threshold is exceeded
The power stage on the module has exceeded a critical
temperature of 85°C. (Pre-warning)
The power stage on the module has exceeded a critical
temperature of 115°C. The motor becomes switched
off, until temperature falls below 105°C. The
measurement is correct to about +/-10°C
CL
TEMP
Current Limit Blink
Current Limit On / Flicker
Temperature
Warning
Temperature
Warning
Blink
On
Table 5.1: Temperature, Current and Voltage monitoring functions (LEDs)
The motor current limiting function is meant as a function for torque limiting, and for protection of
motor, power supply and mechanical load.
Whenever the pre-programmed motor current is exceeded in a chopper cycle, the TMCM-171 calculates
a reduced PWM value for the next chopper cycle. New values are calculated 1000 times a second. The
response time of the current regulation can be set using the parameter “current regulation loop
delay”:
A value of zero means, that in every 1kHz period, the current correction calculation is directly executed
and the resulting PWM value is taken. A higher current loop delay acts like a filter for the current. The
higher the delay value, the slower the current loop response time. A value of 10 (default) leads to a
current regulation response time of about 10 ms for an 1/e response. On the mechanical side, a
higher value simulates a higher dynamic mass of the motor.
The actual current regulation time may differ, depending on the PID settings.
Attention:
The unit has a short circuit protection circuit, which limits coil current to about 40A.
There is a number of aspects when using the current limiting function:
• The current measurement is done at a point of the chopper cycle, where just one coil is switched
• The current measurement can not detect currents below about 200-300mA. If the current limit is
• The current limiting function is not meant as a protection against a hard short circuit.
• The performance of the current limiting depends on the motor and on the commutation mode.
• Operation of the current limiter and the PID regulator may result in instable behavior, if the
• If the motor is blocked and the ramp generator is not stopped, the motor will speed up and try
Please refer to the programming manual for the required current settings.
Please be careful, when programming a high value into the current regulation loop delay
register: The motor current could reach a very high peak value upon mechanical blocking
of the motor. The same goes for the motor current limit value: do not set higher than
16A if you are not sure about this. Please remark, that the current measurement gives
different results in block and in sine commutation mode, due to the different driving
scheme.
However, this function should not be relied on in normal operating conditions.
on. When using sine commutation, the effective motor current is calculated from a measurement
of all three coils.
set to a too low value, the motor may operate spuriously or become continuously switched off.
The current limit should be programmed to a value high enough, in order to achieve good
positioning and acceleration performance.
motor gets into a resonance area. Try adapting the current regulation loop delay parameter.
to catch up with the ramp generator position after removal of the blocking. To control this effect,
you can set the parameter “Clear Target Distance” in order to stop the ramp generator, when the
deviation between the positions become to large. The effect of this may look somehow weird if
the user does not expect it.
2.2 The reply format .................................................................................................................................................. 7
2.2.1 Status codes ............................................................................................................................................... 7
2.4.3 I/O port commands .................................................................................................................................. 8
2.4.4 Control commands ................................................................................................................................... 8
2.5 The ASCII interface ............................................................................................................................................. 9
2.5.1 Format of the command line ................................................................................................................ 9
2.5.2 Format of a reply ...................................................................................................................................... 9
2.5.3 Commands that can be used in ASCII mode ................................................................................ 10
2.5.4 Configuring the ASCII interface ......................................................................................................... 10
3.1 ROR – Rotate Right ........................................................................................................................................... 12
3.2 ROL – Rotate Left ............................................................................................................................................... 13
3.3 MST – Motor Stop ............................................................................................................................................. 14
3.4 MVP – Move to Position .................................................................................................................................. 15
3.5 SAP – Set Axis Parameter ............................................................................................................................... 17
3.6 GAP – Get Axis Parameter .............................................................................................................................. 18
3.7 STAP – Store Axis Parameter ......................................................................................................................... 19
3.9 SGP – Set Global Parameter ........................................................................................................................... 21
3.10 GGP – Get Global Parameter .......................................................................................................................... 22
3.11 STGP – Store Global Parameter ..................................................................................................................... 23
3.12 RSGP – Restore Global Parameter ................................................................................................................ 24
3.21 RSUB – Return from Subroutine ................................................................................................................... 35
3.22 WAIT – Wait for an event to occur ............................................................................................................. 36
3.23 STOP – Stop TMCL program execution ....................................................................................................... 38
3.24 SAC – SPI Bus Access....................................................................................................................................... 39
3.25 SCO – Set Coordinate ....................................................................................................................................... 40
3.26 GCO – Get Coordinate ...................................................................................................................................... 41
3.32 User definable commands (UF0..UF7) .......................................................................................................... 47
3.33 Request target position reached event ...................................................................................................... 48
3.34 BIN – Return to Binary Mode ........................................................................................................................ 49
3.35 TMCL Control Functions ................................................................................................................................... 50
4.2 Advanced axis parameters (all TMCL stepper motor modules except the TMCM-100) .................. 53
4.3 Axis parameters on the TMCM-100 and on the Monopack 2................................................................ 56
5 Global Parameters ...................................................................................................................................................... 59
5.1 Bank 0 ................................................................................................................................................................... 59
5.2 Bank 1 ................................................................................................................................................................... 62
5.3 Bank 2 ................................................................................................................................................................... 63
6 Hints and Tips ............................................................................................................................................................. 64
6.3.3 Position correction ................................................................................................................................. 66
6.4 Stall Detection (TMCL Version 3.06 or higher) .......................................................................................... 66
6.5 Fixing microstep errors (TMCL V3.13 or higher) ....................................................................................... 67
6.6 Using the RS485 interface ............................................................................................................................... 67
7 The TMCL IDE ............................................................................................................................................................... 68
7.2 Getting started ................................................................................................................................................... 69
7.3 The integrated editor ....................................................................................................................................... 69
7.4 The “File” menu ................................................................................................................................................. 69
7.4.1 New ............................................................................................................................................................. 69
7.4.2 Open ........................................................................................................................................................... 69
7.4.3 Save, Save as ........................................................................................................................................... 69
7.4.4 Save all ...................................................................................................................................................... 69
7.4.5 Close ........................................................................................................................................................... 69
7.5 The “TMCL” menu .............................................................................................................................................. 69
7.5.2 Direct mode .............................................................................................................................................. 70
7.5.3 Assemble a TMCL program .................................................................................................................. 70
7.5.4 Downloading the program .................................................................................................................. 71
TMCL Reference Manual 4
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
7.5.5 The “Main file” function ........................................................................................................................ 71
7.5.6 The “Start” function ............................................................................................................................... 71
7.5.7 The “Stop” function ................................................................................................................................ 71
7.5.8 The “Continue” function ....................................................................................................................... 71
7.5.9 Disassembling a TMCL program ......................................................................................................... 71
7.6 The “Setup” menu ............................................................................................................................................. 72
7.6.4 Install OS .................................................................................................................................................. 76
7.7.3 The “Run / Continue” function............................................................................................................ 79
7.7.4 The “Pause” function ............................................................................................................................. 80
7.7.5 The “Step” function ................................................................................................................................ 80
7.7.6 The “Animate” function ........................................................................................................................ 80
7.7.7 The “Stop / Reset” function ................................................................................................................. 80
7.7.8 The “Direct Mode” function in the debugger ................................................................................. 80
7.8 The syntax of TMCL in the TMCL assembler .............................................................................................. 80
8.1.2 Main loop .................................................................................................................................................. 84
8.2 Using symbolic constants ............................................................................................................................... 84
8.3 Using variables................................................................................................................................................... 85
8.4 Using subroutines ............................................................................................................................................. 85
8.5 Mixing direct mode and stand alone mode .............................................................................................. 85
Copyright 2003 - 2008 by Trinamic Motion Control GmbH & Co KG, Germany
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any
means without the written permission of the publisher. Information given in this book is believed to be accurate
and reliable. However no responsibility is assumed for the consequences of its use or for any infringement of
patents or other rights of third parties which may result from its use. Specifications are subject to change without
notice.
TMCL Reference Manual 5
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
1 Introduction
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 in an EEPROM on the TMCM module to form
programs that run stand alone on a module. For this purpose there are not only motion control commands but
also commands to control the program structure (like conditional jumps, compare and calculating). So, TMCL forms
a powerful language that can either be used to control a module directly from a host (direct mode) or to program
applications that run on a stand-alone module (program mode or stand-alone mode).
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, whereas the mnemonic format is used for easy usage of the commands
when developing stand-alone TMCL applications using the TMCL IDE (IDE means “Integrated Development Environment”).
There is also a set of configuration variables for every 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. It also describes how to use the
TMCL IDE.
TMCL Reference Manual 6
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
Bytes
Meaning
1
Module address
1
Command number
1
Type number
1
Motor or Bank number
4
Value (MSB first!)
1
Checksum
2 Basic TMCL Concepts
2.1 Binary command format
Every command has a mnemonic and a binary representation. 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 RS232 or RS485 interface, it has to be enclosed by an address byte
at the beginning and a checksum byte at the end. So it then consists of nine bytes. This is not the case when
communicating via the CAN bus as address and checksum are included in the CAN standard in do not have to be
supplied by the user.
When using a module with IIC interface the first byte (address byte) is left out because IIC has its own addressing
scheme. So for IIC the telegram consists of eight bytes, starting with the command byte.
So the binary command format when using RS232 or RS485 is as follows:
The checksum is calculated by adding up all the other bytes using an 8-bit addition. When using CAN bus, just
leave out the first byte (module address) and the last byte (checksum). When using IIC, leave out the first byte.
2.1.1 Checksum calculation
As mentioned above, the checksum is calculated by adding up all bytes (including the module address byte) using
8-bit addition. Here are two examples to show how to do this:
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 it to the module
in Delphi:
var
i, Checksum: byte;
Command: array[0..8] of byte;
//Set the “Command” array to the desired command
//Calculate the Checksum:
Checksum:=Command[0];
for i:=1 to 7 do Checksum:=Checksum+Command[i];
Command[8]:=Checksum;
//Now, send the “Command” array (9 bytes) to the module
TMCL Reference Manual 7
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
Bytes
Meaning
1
Reply address
1
Module address
1
Status (e.g. 100 means “no error”)
1
Command number
4
Value (MSB first!)
1
Checksum
Code
Meaning
100
Successfully executed, no error
101
Command loaded into TMCL
program EEPROM
1
Wrong checksum
2
Invalid command
3
Wrong type
4
Invalid value
5
Configuration EEPROM locked
6
Command not available
2.2 The reply format
Every time a command has been sent to a module, the module sends a reply. When using RS232 or RS485 the
format of the reply is as follows:
The checksum is also calculated by adding up all the other bytes using an 8-bit addition. When using CAN bus, the
first byte (reply address) and the last byte (checksum) are left out. When using IIC bus the first byte (reply address)
is left out. Do not send the next command before you have received the reply!
2.2.1 Status codes
The reply contains a status code. This status code can have one of the following values:
2.3 Stand-alone applications
When the module which is used is equipped with an EEPROM to store TMCL applications, the TMCL-IDE can be
used to develop stand-alone TMCL applications that can be downloaded into the EEPROM of the module and then
run on the module. The TMCL IDE contains an editor and a “TMCL assembler” where the commands can be entered
using their mnemonic format and then assembled to their binary representations. This code can then be
downloaded into the module to be executed there. The TMCL IDE is described in detail in chapter 7 of this manual.
2.4 TMCL command overview
In this section an overview of the TMCL commands is given. All commands are described in detail in chapter 3.
Some TMCL programming techniques are given in chapter 8.
2.4.1 Motion commands
These commands control the motion of the motors. They are the most important commands and can be used in
direct mode or in stand-alone mode.
TMCL Reference Manual 8
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
Mnemonic
Command
number
Meaning
ROL
2
Rotate left
ROR
1
Rotate right
MVP
4
Move to position
MST
3
Motor stop
RFS
13
Reference search
SCO
30
Store coordinate
CCO
32
Capture coordinate
GCO
31
Get coordinate
Mnemonic
Command
number
Meaning
SAP
5
Set axis parameter
GAP
6
Get axis parameter
STAP
7
Store axis parameter into EEPROM
RSAP
8
Restore axis parameter from EEPROM
SGP
9
Set global parameter
GGP
10
Get global parameter
STGP
11
Store global parameter into EEPROM
RSGP
12
Restore global parameter from EEPROM
Mnemonic
Command
number
Meaning
SIO
14
Set output
GIO
15
Get input
SAC
29
Access to external SPI device
Mnemonic
Command
number
Meaning
JA
22
Jump always
JC
21
Jump conditional
COMP
20
Compare accumulator with constant
value
CLE
36
Clear error flags
CSUB
23
Call subroutine
RSUB
24
Return from subroutine
WAIT
27
Wait for a specified event
STOP
28
End of a TMCL program
2.4.2 Parameter commands
These commands are used to set, read and store axis parameters or global parameters. Axis parameters can be set
independently for every axis, whereas global parameters control the behaviour of the module itself. These
commands can also be used in direct mode and in stand-alone mode.
2.4.3 I/O port commands
These commands control the external I/O ports and can be used in direct mode and in stand-alone mode.
2.4.4 Control commands
These commands are used to control the program flow (loops, conditions, jumps etc.). It does not make sense to
use them in direct mode. They are intended for stand-alone mode only.
TMCL Reference Manual 9
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
Mnemonic
Command
number
Meaning
CALC
19
Calculate using the accumulator and a
constant value
CALCX
33
Calculate using the accumulator and the
X register
AAP
34
Copy accumulator to an axis parameter
AGP
35
Copy accumulator to a global parameter
2.4.5 Calculation commands
These commands are intended to be used for calculations within TMCL applications. Although they could also be
used in direct mode it does not make much sense to do so.
For calculating purposes there is an accumulator (or accu or A register) and an X register. When executed in a
TMCL program (in stand-alone 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.
When a command that reads a value is executed in direct mode the accumulator will not be affected. This means
that while a TMCL program is running on the module (stand-alone mode), a host can still send commands like
GAP, GGP or GIO to the module (e.g. to query the actual position of the motor) without affecting the flow of the
TMCL program running on the module.
2.5 The ASCII interface
Since TMCL V3.21 there is also an ASCII interface that can be used to communicate with the module and to send
some commands as text strings. The ASCII command line interface is entered by sending the binary command 139
(enter ASCII mode). The commands are then entered as in the TMCL IDE, but not all commands can be entered in
ASCII mode. Only those commands that can be used in direct mode can also be entered in ASCII mode.
To leave the ASCII mode and re-enter the binary mode enter the command “BIN”.
2.5.1 Format of the command line
As the first character, the address character has to be sent. The address character is “A” when the module address
is 1, “B” for modules with address 2 and so on. After the address character there may be spaces (but this is not
necessary). Then, send the command with its parameters. At the end of a command line a <CR> character has to be
sent. Here are some examples for valid command lines:
AMVP ABS, 1, 50000
A MVP ABS, 1, 50000
AROL 2, 500
A MST 1
ABIN
These command would all address the module with address 1. To address e.g. module 3, use address character “C”
instead of “A”. The last command line shown above will make the module return to binary mode.
2.5.2 Format of a reply
After executing the command the module sends back a reply in ASCII format. This reply consists of:
the address character of the host (host address that can be set in the module) the address character of the module the status code as a decimal number the return value of the command as a decimal number a <CR> character
TMCL Reference Manual 10
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
So, after sending AGAP 0, 1 the reply would be BA 100 –5000 if the actual position of axis 1 is –5000, the
host address is set to 2 and the module address is 1. The value “100” is the status code 100 that means “command successfully executed”.
2.5.3 Commands that can be used in ASCII mode
The following commands can be used in ASCII mode: ROL, ROR, MST, MVP, SAP, GAP, STAP, RSAP, SGP, GGP, STGP,
RSGP, RFS, SIO, GIO, SAC, SCO, GCO, CCO, UF0, UF1, UF2, UF3, UF4, UF5, UF6, UF7.
There are also special commands that are only available in ASCII mode:
BIN: This command quits ASCII mode and returns to binary TMCL mode. RUN: This command can be used to start a TMCL program in memory. STOP: Stops a running TMCL application.
2.5.4 Configuring the ASCII interface
The module can be configured so that it starts up either in binary mode or in ASCII mode. Global parameter 67 is
used for this purpose (please see also chapter 5.1). Bit 0 determines the startup mode: if this bit is set, the module
starts up in ASCII mode, else it will start up in binary mode (default). Bit 4 and Bit 5 determine how the characters
that are entered are echoed back. Normally, both bits are set to zero. In this case every character that is entered is
echoed back when the module is addressed. Character can also be erased using the backspace character (press the
backspace key in a terminal program). When bit 4 is set and bit 5 is clear the characters that are entered are not
echoed back immediately but the entire line will be echoed back after the <CR> character has been sent. When bit
5 is set and bit 4 is clear there will be no echo, only the reply will be sent. This may be useful in RS485 systems.
TMCL Reference Manual 11
Trinamic Motion Control GmbH & Co KG
Sternstraße 67
D – 20357 Hamburg, Germany
http://www.trinamic.com
3 TMCL Command Dictionary
This chapter describes all TMCL commands. The commands are sorted by their command numbers. For every
command the mnemonic with its syntax and the binary representation are given.
Ranges for the parameters are also given. They sometimes differ between the types of the modules. If this is the
case, value ranges are given for every module.
Last but not least some examples are given at the end of every command description. In the examples for the
binary representation always RS232/RS485 communication (9 byte) format is used with module address 1 and host
address 2. When using CAN bus communication just leave out the first and the last byte (as mentioned in chapter
2.1).
Loading...
+ 104 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.