MODULE Module for Stepper Motors TMCM-3314 TMCL™ Firmware Manual Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 The TMCM-3314 is a three axes controller/driver module for 2-phase bipolar stepper motors with separate differential encoder and separate home and stop switch inputs for each axis. Dynamic current control, and quiet, smooth and efficient operation are combined with stealthChop™, dcStep™, stallGuard™ and coolStep™ features.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 2 / 109 Contents 1 Features 1.1 stallGuard2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 coolStep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 6 2 First Steps with TMCL 2.1 Basic Setup . . . . . . . . . . . . . . . . 2.2 Using the TMCL Direct Mode . . . . . 2.3 Changing Axis Parameters . . . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.27 3.6.28 3.6.29 3.6.30 3.6.31 3.6.32 3.6.33 3.6.34 3.6.35 3.6.36 3 / 109 AAP (Accu to Axis Parameter) . . . . . . . . . . . . . . . . . . . . . . . . . AGP (Accu to Global Parameter) . . . . . . . . . . . . . . . . . . . . . . . CLE (Clear Error Flags) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . EI (Enable Interrupt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 10 Supplemental Directives 10.1 Producer Information . . . . . . . . . 10.2 Copyright . . . . . . . . . . . . . . . . . 10.3 Trademark Designations and Symbols 10.4 Target User . . . . . . . . . . . . . . . . 10.5 Disclaimer: Life Support Systems . . . 10.6 Disclaimer: Intended Use . . . . . . . 10.7 Collateral Documents & Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 1 5 / 109 Features The TMCM-3314 is a triple axis controller/driver module for 2-phase bipolar stepper motors with state of the art feature set. It is highly integrated, offers a convenient handling and can be used in many decentralized applications. The module has been designed for coil currents up to 3A RMS and 48 V DC supply voltage.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 1.1 6 / 109 stallGuard2 stallGuard2 is a high-precision sensorless load measurement using the back EMF of the coils. It can be used for stall detection as well as other uses at loads below those which stall the motor. The stallGuard2 measurement value changes linearly over a wide range of load, velocity, and current settings. At maximum motor load, the value reaches zero or is near zero.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 2 7 / 109 First Steps with TMCL In this chapter you can find some hints for your first steps with the TMCM-3314 and TMCL. You may skip this chapter if you are already familiar with TMCL and the TMCL-IDE. Things that you will need • Your TMCM-3314 module. • A USB cable with micro USB plug or an RS485 interface with suitable cable or a CAN interface with suitable cable.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 8 / 109 The following table points out the most important axis parameters. Please see chapter 4 for a complete list of all axis parameters. Most important axis parameters Number Axis Parameter Description Range [Units] Access 4 Maximum positioning speed The maximum speed used for positioning ramps. 0. . . 7999774 [pps] RW 5 Maximum acceleration Maximum acceleration in positioning ramps.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 9 / 109 1. Click the Assemble icon (or choose Assemble from the TMCL menu) in the TMCL creator to assemble the program. 2. Click the Download icon (or choose Download from the TMCL menu) in the TMCL creator to donwload the program to the module. 3. Click the Run icon (or choose Run from the TMCL menu) in the TMCL creator to run the program on the module.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3 10 / 109 TMCL and the TMCL-IDE — An Introduction As with most TRINAMIC modules the software running on the microprocessor of the TMCM-3314 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 untouched throughout the whole lifetime, the firmware can be updated by the user.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 11 / 109 TMCL Command Format Bytes Meaning 1 Module address 1 Command number 1 Type number 1 Motor or Bank number 4 Value (MSB first!) 1 Checksum Table 2: TMCL Command Format Info Note 3.1.1 The checksum is calculated by accumulating all the other bytes using an 8-bit addition. When using the CAN interface, leave out the address byte and the checksum byte.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.2 12 / 109 Reply Format Every time a command has been sent to a module, the module sends a reply. The reply format with RS-232, RS-485, RS-422 and USB is as follows: TMCL Reply Format Bytes Meaning 1 Reply address 1 Module address 1 Status (e.g.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.3 13 / 109 Standalone Applications The module is equipped with a TMCL memory for storing TMCL applications. You can use the TMCL-IDE for developing standalone TMCL applications. You can download a program into the EEPROM and afterwards it will run on the module. The TMCL-IDE contains an editor and the TMCL assembler where the commands can be entered using their mnemonic format.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.4 14 / 109 TMCL Command Overview This sections gives a short overview of all TMCL commands. 3.4.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.5.2 16 / 109 Parameter Commands These commands are used to set, read and store axis parameters or global parameters. Axis parameters can be set independently for each axis, whereas global parameters control the behavior of the module itself. These commands can also be used in direct mode and in standalone mode.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 17 / 109 I/O Port Commands Mnemonic Command number Meaning SIO 14 Set output GIO 15 Get input Table 9: I/O Port Commands 3.5.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.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 18 / 109 Interrupt Processing Commands Mnemonic Command number Meaning EI 25 Enable interrupt DI 26 Disable interrupt VECT 37 Set interrupt vector RETI 38 Return from interrupt Table 11: Interrupt Processing Commands 3.5.6.1 Interrupt Types There are many different interrupts in TMCL, like timer interrupts, stop switch interrupts, position reached interrupts, and input pin change interrupts.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Interrupt number Interrupt type 41 Input change 2 42 Input change 3 255 Global interrupts 19 / 109 Table 12: Interrupt Vectors 3.5.6.2 Interrupt Processing When an interrupt occurs and this interrupt is enabled and a valid interrupt vector has been defined for that interrupt, the normal TMCL program flow will be interrupted and the interrupt handling routine will be called.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 15 17 19 21 Timer0Irq : GIO 0 , JC NZ , SIO 0 , RETI Out0Off : SIO 0 , RETI 2 Out0Off 2, 1 // check if OUT0 is high // jump if not // switch OUT0 high // end of interrupt 2, 0 // switch OUT0 low // end of interrupt 20 / 109 In the example above, the interrupt numbers are being used directly. To make the program better readable use the provided include file Interrupts.inc.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6 21 / 109 Detailed TMCL Command Descriptions The module specific commands are explained in more detail on the following pages. They are listed according to their command number. 3.6.1 ROR (Rotate Right) The motor is instructed to rotate with a specified velocity in right direction (increasing the position counter). The velocity is given in microsteps per second (pulse per second [pps]).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.2 22 / 109 ROL (Rotate Left) The motor is instructed to rotate with a specified velocity in left direction (decreasing the position counter). The velocity is given in microsteps per second (pulse per second [pps]). 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.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.3 23 / 109 MST (Motor Stop) The motor is instructed to stop with a soft stop. Internal function: The velocity mode is selected. Then, the target speed (axis parameter #0) is set to zero. Related commands: ROR, ROL, SAP, GAP. Mnemonic: MST Binary Representation Instruction Type Motor/Bank Value 3 0 0. . . 2 0 Reply in Direct Mode Status Value 100 - OK don’t care Example Stop motor 0.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.4 24 / 109 MVP (Move to Position) With this command the motor will be instructed to move to a specified relative or absolute position. It will use the acceleration/deceleration ramp and the positioning speed programmed into the unit. This command is non-blocking - that is, a reply will be sent immediately after command interpretation and initialization of the motion controller.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Binary Form of MVP ABS, 0, 90000 Field Value Target address 01h Instruction number 04h Type 00h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 01h Value (Byte 1) 5Fh Value (Byte 0) 90h Checksum F5h Example Move motor 0 from current position 10000 microsteps backward.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 26 / 109 Binary Form of MVP COORD, 0, 8 Field Value Target address 01h Instruction number 04h Type 02h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 08h Checksum 0Fh Note Before moving to a stored coordinate, the coordinate has to be set using an SCO, CCO or ACO command. ©2018 TRINAMIC Motion Control GmbH & Co.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.5 27 / 109 SAP (Set Axis Parameter) With this command most of the motion control parameters of the module can be specified. The settings will be stored in SRAM and therefore are volatile. That is, information will be lost after power off. For a table with parameters and values which can be used together with this command please refer to section 4.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.6 28 / 109 GAP (Get Axis Parameter) Most motion / driver related parameters of the TMCM-3314 can be adjusted using e.g. the SAP command. With the GAP parameter they can be read out. In standalone mode the requested value is also transferred to the accumulator register for further processing purposes (such as conditional jumps).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.7 29 / 109 SGP (Set Global Parameter) With this command most of the module specific parameters not directly related to motion control can be specified and the TMCL user variables can be changed. Global parameters are related to the host interface, peripherals or application specific variables. The different groups of these parameters are organized in banks to allow a larger total number for future products.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.8 30 / 109 GGP (Get Global Parameter) All global parameters can be read with this function. Global parameters are related to the host interface, peripherals or application specific variables. The different groups of these parameters are organized in banks to allow a larger total number for future products. Currently, bank 0 is used for global parameters, and bank 2 is used for user variables.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.9 31 / 109 STGP (Store Global Parameter) This command is used to store TMCL global parameters permanently in the EEPROM of the module. This command is mainly needed to store the TMCL user variables (located in bank 2) in the EEPROM of the module, as most other global parameters (located in bank 0) are stored automatically when being modified.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.10 32 / 109 RSGP (Restore Global Parameter) With this command the contents of a TMCL user variable can be restored from the EEPROM. By default, all user variables are automatically restored after power up. A user variable that has been changed before can be reset to the stored value by this instruction.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.11 33 / 109 RFS (Reference Search) The TMCM-3314 has a built-in reference search algorithm. The reference search algorithm provides different refrence search modes. This command starts or stops the built-in reference search algorithm. The status of the reference search can also be queried to see if it already has finished.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Binary Form of RFS START Field Value Target address 01h Instruction number 0Dh Type 00h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 00h Checksum 0Eh ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.12 35 / 109 SIO (Set Output) This command sets the states of the general purpose digital outputs. Internal function: The state of the output line specified by the type parameter is set according to the value passed to this command. Related commands: GIO.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 36 / 109 Digital Outputs in Bank 2 Port Command Range OUT0 SIO 0, 2, 0/1 OUT1 SIO 1, 2, 0/1 OUT2 SIO 2, 2, 0/1 OUT3 SIO 3, 2, 0/1 Special case: SIO 255, 2, can be used to change all general purpose digital output lines simulaneously. The value will then be interpreted as a bit vector where each bit represents one of the digital outputs.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.13 37 / 109 GIO (Get Input) With this command the status of the available general purpose outputs of the module can be read. The function reads a digital or an analog input port. Digital lines will read as 0 or 1, while the ADC channels deliver their 16 bit result in the range of 0. . . 65535.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 38 / 109 Reply (Status=no error, Value=302) Field Value Host address 02h Target address 01h Status 64h Instruction 0Fh Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 01h Value (Byte 0) 2Eh Checksum A5h Bank 0 – Digital Inputs The analog input lines can be read as digital or analog inputs at the same time. The digital input states can be accessed in bank 0.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 39 / 109 Bank 2 – States of the Digital Outputs The states of the output lines (that have been set by SIO commands) can be read back using bank 2. Digital Outputs in Bank 2 Port Command Range OUT0 GIO 0, 2 0/1 OUT1 GIO 1, 2 0/1 OUT2 GIO 2, 2 0/1 OUT3 GIO 3, 2 0/1 State of the ENABLE Input To query the state of the ENABLE input use GIO 10, 0.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.14 40 / 109 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.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.15 42 / 109 COMP (Compare) The specified number is compared to the value in the accumulator register. The result of the comparison can for example be used by the conditional jump (JC) instruction. This command is intended for use in standalone operation only. Internal function: The accumulator register is compared with the sepcified value.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.16 43 / 109 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. Please refer to COMP instruction for examples. This command is intended for standalone operation only.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Binary form of JC GE, Label assuming Label at address 10 Field Value Target address 01h Instruction number 15h Type 05h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 0Ah Checksum 25h ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.17 45 / 109 JA (Jump always) Jump to a fixed address in the TMCL program memory. This command is intended for standalone operation only. Internal function: The TMCL program counter is set to the value passed to this command. Related commands: JC, WAIT, CSUB.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.18 46 / 109 CSUB (Call Subroutine) This function calls a subroutine in the TMCL program memory. It is intended for standalone operation only. 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.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.19 47 / 109 RSUB (Return from Subroutine) Return from a subroutine to the command after the CSUB command. This command is intended for use in standalone mode only. Internal function: the TMCL program counter is set to the last value saved on the stack. The command will be ignored if the stack is empty. Related commands: CSUB.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.20 48 / 109 WAIT (Wait for an Event to occur) This instruction interrupts the execution of the TMCL program until the specified condition is met. This command is intended for standalone operation only. There are five different wait conditions that can be used: • TICKS: Wait until the number of timer ticks specified by the parameter has been reached.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Wait for motor 0 to reach its target position, without timeout. Mnemonic: WAIT POS, 0, 0 Binary Form of WAIT POS, 0, 0 Field Value Target address 01h Instruction number 1Bh Type 01h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 00h Checksum 1Dh ©2018 TRINAMIC Motion Control GmbH & Co.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.21 50 / 109 STOP (Stop TMCL Program Execution – End of TMCL Program) This command stops the execution of a TMCL program. It is intended for use in standalone operation only. Internal function: Execution of a TMCL program in standalone mode will be stopped. Related commands: none.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.22 51 / 109 SCO (Set Coordinate) Up to 20 position values (coordinates) can be stored for every axis for use with the MVP COORD command. This command sets a coordinate to a specified value. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.23 52 / 109 GCO (Get Coordinate) Using this command previously stored coordinate can be read back. In standalone mode the requested value is copied to the accumulator register for further processing purposes such as conditional jumps. In direct mode, the value is only output in the value field of the reply, without affecting the accumulator.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 53 / 109 Two special functions of this command have been introduced that make it possible to copy all coordinates or one selected coordinate from the EEPROM to the RAM. These functions can be accessed using the following special forms of the GCO command: • GCO 0, 255, 0 copies all coordinates (except coordinate number 0) from the EEPROM to the RAM.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.24 54 / 109 CCO (Capture Coordinate) This command copies the actual position of the axis to the selected coordinate variable. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.25 55 / 109 ACO (Accu to Coordinate) With the ACO command the actual value of the accumulator is copied to a selected coordinate of the motor. Depending on the global parameter 84, the coordinates are only stored in RAM or also stored in the EEPROM and copied back on startup (with the default setting the coordinates are stored in RAM only). Note Coordinate #0 is always stored in RAM only.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.26 56 / 109 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. This command is mainly intended for use in standalone mode.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Binary Form of CALCX MUL Field Value Target address 01h Instruction number 21h Type 02h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 00h Checksum 24h ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.27 58 / 109 AAP (Accu to Axis Parameter) The content of the accumulator register is transferred to the specified axis parameter. For practical usage, 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. This command is mainly intended for use in standalone mode.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.28 59 / 109 AGP (Accu to Global Parameter) The content of the accumulator register is transferred to the specified global parameter. For practical usage, 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. This command is mainly intended for use in standalone mode.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.29 CLE (Clear Error Flags) This command clears the internal error flags. It is mainly intended for use in standalone mode. The following error flags can be cleared by this command (determined by the <flag> parameter): • ALL: clear all error flags. • ETO: clear the timeout flag. • EAL: clear the external alarm flag. • EDV: clear the deviation flag. • EPO: clear the position error flag. Related commands: JC, WAIT.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Binary Form of CLE ETO Field Value Target address 01h Instruction number 24h Type 01h Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 00h Checksum 26h ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.30 62 / 109 EI (Enable Interrupt) The EI command enables an interrupt. It needs the interrupt number as parameter. Interrupt number 255 globally enables interrupt processing. This command is mainly intended for use in standalone mode. Please see table 12 for a list of interrupts that can be used on the TMCM-3314 module. Info Related commands: DI, VECT, RETI.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.31 63 / 109 DI (Disable Interrupt) The DI command disables an interrupt. It needs the interrupt number as parameter. Interrupt number 255 globally disables interrupt processing. This command is mainly intended for use in standalone mode. Please see table 12 for a list of interrupts that can be used on the TMCM-3314 module. Info Related commands: EI, VECT, RETI.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.32 64 / 109 VECT (Define Interrupt Vector) The VECT command defines an interrupt vector. It takes an interrupt number and a label (just like with JA, JC and CSUB commands) as parameters. The label must be the entry point of the interrupt handling routine for this interrupts. Interrupt vectors can also be re-defined. This command is intended for use in standalone mode only.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Binary form of VECT (assuming label is at 50) Field Value Target address 01h Instruction number 25h Type FFh Motor/Bank 00h Value (Byte 3) 00h Value (Byte 2) 00h Value (Byte 1) 00h Value (Byte 0) 32h Checksum 58h ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.33 66 / 109 RETI (Return from Interrupt) This command terminates an interrupt handling routine. Normal program flow will be continued then. This command is intended for use in standalone mode only. An interrupt routine must always end with a RETI command. Do not allow the normal program flow to run into an interrupt routine.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.34 67 / 109 Customer specific Command Extensions (UF0. . . UF7 – User Functions) These commands are used for customer specific extensions of TMCL. They will be implemented in C by Trinamic. Please contact the sales department of Trinamic Motion Control GmbH & Co KG if you need a customized TMCL firmware. Related commands: none. Mnemonic: UF0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.35 68 / 109 Request Target Position reached Event This command is the only exception to the TMCL protocol, as it sends two replies: One immediately after the command has been executed (like all other commands also), and one additional reply that will be sent when the motor has reached its target position.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 3.6.36 70 / 109 TMCL Control Commands There is a set of TMCL commands which are called TMCL control commands. These commands can only be used in direct mode and not in a standalone program. For this reason they only have opcodes, but no mnemonics. Most of these commands are only used by the TMCL-IDE (in order to implement e.g. the debugging functions in the TMCL creator).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 Instruction Description Type Value 135 – get application status Return information about the current status, depending on the type field. 0 - return mode, wait flag, memory pointer 1 - return mode, wait flag, program counter 2 - return accumulator 3 - return X register 0 (don’t care) 136 – get firmware version Return firmware version in string format (special reply) or binary format).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 4 72 / 109 Axis Parameters Most motor controller features of the TMCM-3314 module are controlled by axis parameters. Axis parameters can be modified or read using SAP, GAP and AAP commands. This chapter describes all axis parameters that can be used on the TMCM-3314 module.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 74 / 109 Number Axis Parameter Description Range [Units] 27 Virtual stop right Virtual stop position when motor is moving in positive direction. -2147483648 RW . . . 2147483647 [µsteps] 28 Virtual stop enable 0 - both virtual stop disabled 1 - Virtual stop left enable 2 - Virtual stop right enable 3 - both virtual stop enabled 0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 75 / 109 Number Axis Parameter Description Range [Units] Access 116 CL correction velocity I Parameter I of PI regulator which controls the maximum velocity during closed loop regulation. 0. . . 16777215 RW 117 CL correction velocity I clipping Clipping of the error sum of the integral part of the PI regulator which controls the maximum velocity during closed loop regulation. 0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 76 / 109 Number Axis Parameter Description Range [Units] Access 134 Positioning window Maximum deviation for target reached flag to be set. 0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 77 / 109 Number Axis Parameter Description Range [Units] Access 167 Chopper off time (TOff) The off time setting controls the minimum chopper frequency. An off time within the range of 5µs to 20µs will fit. 0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 78 / 109 Number Axis Parameter Description Range [Units] Access 174 stallGuard2 threshold This signed value controls stallGuard2 threshold level for stall output and sets the optimum measurement range for readout. A lower value gives a higher sensitivity. Zero is the starting value. A higher value makes stallGuard2 less sensitive and requires more torque to indicate a stall. -64. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 79 / 109 Number Axis Parameter Description Range [Units] Access 191 PWM frequency PWM frequency selection for stealthChop. 0 - fPWM = 15.625kHz 1 - fPWM = 23.426kHz 2 - fPWM = 31.250kHz 3 - fPWM = 39.024kHz 0. . . 3 RW 192 PWM autoscale PWM automatic amplitude scaling for stealthChop. 0 - User defined PWM amplitude. The current settings do not have any influence. 1 - Enable automatic current control.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 80 / 109 Number Axis Parameter Description Range [Units] 196 End switch distance This parameter provides the distance between the end switches after executing the RFS command (with reference search mode 2 or 3). -2147483648 R . . . 2147483647 [µsteps] 197 Last reference position This parameter contains the last position value before the position counter is set to zero during reference search.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 5 82 / 109 Global Parameters The following sections describe all global parameters that can be used with the SGP, GGP, AGP, STGP and RSGP commands. Global parameters are grouped into banks: • Bank 0: Global configuration of the module. • Bank 1: Not used. • Bank 2: TMCL user variables. • Bank 3: TMCL interrupt configuration. 5.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 83 / 109 All Global Parameters of the TMCM-3314 Module in Bank 0 Number 65 Global Parameter Description 0 9600 1 14400 2 19200 3 28800 4 38400 5 57600 6 76800 7 115200 8 230400 Not supported by PCs 9 250000 Not supported by PCs 10 500000 Not supported by PCs 11 1000000 Not supported by PCs Range [Units] Access 0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 84 / 109 Number Global Parameter Description Range [Units] Access 76 Serial host address Host address used in the reply telegrams sent back via RS485. 0. . . 255 RWA 77 Auto start mode 0 - Do not start TMCL application after power up (default). 1 - Start TMCL application automatically after power up. 0/1 RWA 81 TMCL code protection Protect a TMCL program against disassembling or overwriting.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 85 / 109 Number Global Parameter Description Range [Units] Access 132 TMCL tick timer A 32 bit counter that gets incremented by one every millisecond. It can also be reset to any start value. 0. . . 2147483647 RW 133 Random number Returns a random number. The seed value can be set by writing to this parameter. 0. . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 86 / 109 Interrupt Parameters in Bank 3 Number Global Parameter Description Range [Units] 0 Timer 0 period (ms) Time between two interrupts 0. . . 4294967295 RW [ms] 1 Timer 1 period (ms) Time between two interrupts 0. . . 4294967295 RW [ms] 2 Timer 2 period (ms) Time between two interrupts 0. . . 4294967295 RW [ms] 27 Stop left 0 trigger transition 0=off, 1=low-high, 2=high-low, 3=both 0. .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 6 87 / 109 Hints and Tips This chapter gives some hints and tips on using the functionality of TMCL, for example how to use and parameterize the built-in reference search algorithm. You will also find basic information about stallGuard2™ and coolStep™ in this chapter. 6.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 6.1.1 88 / 109 Mode 1 Reference search mode 1 only searches the left end switch. Select this mode by setting axis parameter #193 to 1. Figure 3 illustrates this. Add 64 to the mode number (i.e. set axis parameter #193 to 65) to search the right end switch instead of the left end switch.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 L 89 / 109 R start stop left limit / end / stop switch right limit / end / stop switch : reference search speed (axis parameter 194) : reference switch speed (axis parameter 195) Figure 5: Reference search Mode 3 6.1.4 Mode 4 Reference search mode 4 searches the left end switch only, but from both sides so that the middle of the switch will be found and used as the zero point. This is shown in figure 6.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 90 / 109 Home L R start stop left limit / end / stop switch home switch : reference search speed (axis parameter 194) : reference switch speed (axis parameter 195) Figure 7: Reference search Mode 5 6.1.6 Mode 6 Reference search mode 6 searches the home switch in positive direction. The search direction will be reversed if the right limit switch is reached. This is shown in figure 8.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 L 91 / 109 R start stop home switch : reference search speed (axis parameter 194) : reference switch speed (axis parameter 195) Figure 9: Reference search Mode 7 6.1.8 Mode 8 Reference search mode 8 searches the home switch in positive direction, ignoring the limit switch inputs. It is recommende mainly for use with a circular axis. The exact middle of the switch will be found and used as the zero point.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 6.2 92 / 109 Using Encoders With the TMCM-3314 it is also possible to use encoders. The TMCM-3314 can work as an open-loop system as well as a true servo-like closed-loop system. In open-loop mode encoders can be used just to check if the motor really reaches its target positions and thus can follow the magnetic field and the position counter.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 25 27 29 31 SAP SAP SAP SAP SAP 116 , 117 , 118 , 119 , 124 , 0, 0, 0, 0, 0, 20 2000 0 100000 65536 // set // set // set // set // set 93 / 109 CL correction velocity I CL correction velocity I clipping CL correction velocity DV clock CL correction velocity DV clipping correction position P ( default 65536) SAP 212 , 0 , 1000 SAP 213 , 0 , 30000 // Max . position deviation . // Pos_ERROR output .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 6.3.2 94 / 109 Load Angle Control As typical for stepper motor drivers, phase currents will be assigned directly to he motor drivers. This results in a current vector which should be followed by the rotor.The rotor position will be directly sampled by encoder feedback. The closed-loop motor control monitors the resulting load angle (deviation between driver stage current vector and encoder angle).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 95 / 109 Current Value [0..
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 96 / 109 Normal Closed Loop Load Angle [µSteps] Field Weakening max. 180° SAP 110 SAP 111max. 90° Motor Velocity [pps] SAP 108 SAP 109 Figure 14: Field Weakening • SAP 111: Closed Loop Beta • SAP 110: Closed Loop Gamma • SAP 108: Gamma Vmin • SAP 109: Gamma Vmax 6.3.5 Position Catch up The TMCM-3314 includes a special feature for closed-loop positioning.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 97 / 109 as a stall detection signal. The measured value changes linear with the load on the motor in a wide range of load, velocity and current settings. At maximum motor load the stallGuard value goes to zero. This corresponds to a load angle of 90° between the magnetic field of the stator and magnets in the rotor. This also is the most energy efficient point of operation for the motor.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 6.5 98 / 109 coolStep This section gives an overview of the coolStep related parameters. Please bear in mind that the figure only shows one example for a drive. There are parameters which concern the configuration of the current. Other parameters are there for velocity regulation and for time adjustment. Figure 16 shows all the adjustment points for coolStep.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 coolStep Adjustment Points and Thresholds Number Axis Parameter Description I6 Absolute maximum current The maximum value is 255. This value means 100% of the maximum current of the module. The current adjustment is within the range 0. . . 255 and can be adjusted in 32 steps (0. . . 255 divided by eight; e.g. step 0 = 0. . . 7, step 1 = 8. . . 15 and so on).
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 6.6 100 / 109 Velocity and Acceleration Calculation When the unit mode (axis parameter #255) is set to 1 (which is also the default value), all velocity parameters on the TMCM-3314 are given in microsteps per second (also called pulse per second or pps). Acceleration and deceleration units are given in pps2 . When axis parameter #255 is set to 0 the internal units of the ramp generators are directly used.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 7 101 / 109 TMCL Programming Techniques and Structure 7.1 Initialization The first task in a TMCL program (like in other programs also) is to initialize all parameters where different values than the default values are necessary. For this purpose, SAP and SGP commands are used. 7.2 Main Loop Embedded systems normally use a main loop that runs infinitely.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 17 102 / 109 WAIT POS , Motor0 , 0 JA MainLoop Have a look at the file TMCLParam.tmc provided with the TMCL-IDE. It contains symbolic constants that define all important parameter numbers. Using constants for other values makes it easier to change them when they are used more than once in a program. You can change the definition of the constant and do not have to change all occurrences of it in your program. 7.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 7.5 103 / 109 Using Subroutines The CSUB and RSUB commands provide a mechanism for using subroutines. The CSUB command branches to the given label. When an RSUB command is executed the control goes back to the command that follows the CSUB command that called the subroutine. This mechanism can also be nested. From a subroutine called by a CSUB command other subroutines can be called.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 104 / 109 This example provides three very simple TMCL routines. They can be called from a host by issuing a run command with address 0 to call the first function, or a run command with address 1 to call the second function, or a run command with address 2 to call the third function.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 8 105 / 109 Figures Index 1 2 3 4 5 6 7 8 stallGuard2 Load Measurement as a Function of Load . . . . . . . . . . . . Energy Efficiency Example with coolStep Reference search Mode 1 . . . . . . . Reference search Mode 2 . . . . . . . Reference search Mode 3 . . . . . . . Reference search Mode 4 . . . . . . . Reference search Mode 5 . . . . . . . Reference search Mode 6 . . . . . . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 9 106 / 109 Tables Index 1 2 3 4 5 6 7 8 9 10 11 12 13 Most important Axis Parameters . TMCL Command Format . . . . . . TMCL Reply Format . . . . . . . . . TMCL Status Codes . . . . . . . . . Overview of all TMCL Commands . Motion Commands . . . . . . . . . Parameter Commands . . . . . . . Branch Commands . . . . . . . . . I/O Port Commands . . . . . . . . Calculation Commands . . . . . .
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 10 107 / 109 Supplemental Directives 10.1 Producer Information 10.2 Copyright TRINAMIC owns the content of this user manual in its entirety, including but not limited to pictures, logos, trademarks, and resources. © Copyright 2018 TRINAMIC. All rights reserved. Electronically published by TRINAMIC, Germany.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 108 / 109 or of any other nature are made hereunder with respect to information/specification or the products to which information refers and no guarantee with respect to compliance to the intended use is given. In particular, this also applies to the stated possible applications or areas of applications of the product.
TMCM-3314 TMCL™ Firmware Manual • Firmware Version V1.09 | Document Revision V1.07 • 2017-DEC-01 11 11.1 109 / 109 Revision History Firmware Revision Version Date Author Description 1.04 2016-JUL-13 OK First release. 1.05 2016-NOV-02 OK Bugfix: TMCL program could be overwritten by user variables. 1.07 2017-JUN-08 OK Enhanced performance. USB OTG power disabled. 1.08 2017-SEP-09 OK Not deployed. 1.09 2017-DEC-01 OK Added axis parameters #50, #249 and #251. Added deviation checking.