PANDRIVE™ PANdrive™ for Stepper Motors PD-1160 TMCL™ Firmware Manual Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 The PD-1160 is a full mechatronic solution, made up of a TMCM-1160 stepper control module and a NEMA 23 (57mm flange size) motor (PD57-1160) or a NEMA 24 (60mm flange size) motor (PD60-1160).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 2 / 113 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 . . . . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.22 3.7.23 3.7.24 3.7.25 3.7.26 3.7.27 3.7.28 3.7.29 3.7.30 3.7.31 3.7.32 3.7.33 3.7.34 3.7.35 3.7.36 3.7.37 3.7.38 3 / 113 WAIT (Wait for an Event to occur) . . . . . . . . . . . . . . . . . . . . . . . STOP (Stop TMCL Program Execution – End of TMCL Program) . . . . . SCO (Set Coordinate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . GCO (Get Coordinate) . . . . . . . . . . . . . . . . . . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 8 TMCL Programming Techniques and Structure 8.1 Initialization . . . . . . . . . . . . . . . . . . . . . 8.2 Main Loop . . . . . . . . . . . . . . . . . . . . . . 8.3 Using Symbolic Constants . . . . . . . . . . . . . 8.4 Using Variables . . . . . . . . . . . . . . . . . . . 8.5 Using Subroutines . . . . . . . . . . . . . . . . . 8.6 Combining Direct Mode and Standalone Mode 8.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 1 5 / 113 Features The PANdrive™ PD-1160 is a full mechatronic solution with state of the art feature set. It is highly integrated and offers a convenient handling. The PD-1160 includes a stepper motor, controller/driver electronics and Trinamic’s sensOstep™ encoder. It can be used in many decentralized applications and has been designed for 0.20. . . 0.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 1.1 6 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 2 7 / 113 First Steps with TMCL In this chapter you can find some hints for your first steps with the PD-1160 and TMCL. You may skip this chapter if you are already familiar with TMCL and the TMCL-IDE. Things that you will need • Your PD-1160 module. • A USB cable. • A power supply (24V DC) for your PD-1160 module. • The TMCL-IDE 3.x already installed on your PC. • A two-phase bipolar stepper motor. 2.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 8 / 113 Most important axis parameters Number Axis Parameter Description Range [Units] Access 4 Maximum positioning speed The maximum speed used for positioning ramps. 1. . . 2047 [int] RW 5 Maximum acceleration Maximum acceleration in positioning ramps. Acceleration and deceleration value in velocity mode. 1. . . 2047 [int] RW 6 Maximum current Motor current used when motor is running.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 9 / 113 3. Click the Run icon (or choose Run from the TMCL menu) in the TMCL creator to run the program on the module. Also try out the debugging functions in the TMCL creator: 1. Click on the Bug icon to start the debugger. 2. Click the Animate button to see the single steps of the program. 3. You can at any time pause the program, set or reset breakpoints and resume program execution. 4.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3 10 / 113 TMCL and the TMCL-IDE — An Introduction As with most TRINAMIC modules the software running on the microprocessor of the PD-1160 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 11 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.2 12 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.3 13 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.4 14 / 113 The ASCII Interface There is also an ASCII interface that can be used to communicate with the module and to send some direct mode commands as text strings. Only the following commands can be used in ASCII mode: ROL, ROR, MST, MVP, SAP, GAP, STAP, RSAP, SGP, GGP, STGP, RSGP, RFS, SIO, GIO, SCO, GCO, CCO, UF0, UF1, UF2, UF3, UF4, UF5, UF6, UF7.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.4.3 15 / 113 Format of a Reply After executing the command the module sends back a reply in ASCII format which consists of the following things: • 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 character.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.5 16 / 113 TMCL Command Overview This sections gives a short overview of all TMCL commands. 3.5.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 18 / 113 Motion Commands Mnemonic Command number Meaning ROL 2 Rotate left ROR 1 Rotate right MVP 4 Move to position MST 3 Motor stop SCO 30 Store coordinate CCO 32 Capture coordinate GCO 31 Get coordinate Table 6: Motion Commands 3.6.2 Parameter Commands These commands are used to set, read and store axis parameters or global parameters.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 19 / 113 Branch Commands Mnemonic Command number Meaning JA 22 Jump always JC 21 Jump conditional COMP 20 Compare accumulator with constant value CSUB 23 Call subroutine RSUB 24 Return from subroutine WAIT 27 Wait for a specified event STOP 28 End of a TMCL program Table 8: Branch Commands 3.6.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 20 / 113 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 (standalone mode), a host can still send commands like GAP and GGP to the module (e.g.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 21 / 113 3.6.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. Before an interrupt handling routine gets called, the context of the normal program (i.e. accumulator register, X register, flags) will be saved automatically.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 22 / 113 In the example above, the interrupt numbers are being used directly. To make the program better readable use the provided include file Interrupts.inc. This file defines symbolic constants for all interrupt numbers which can be used in all interrupt commands. The beginning of the program above then looks as follows: 2 4 # include Interrupts .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7 23 / 113 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.7.1 ROR (Rotate Right) The motor is instructed to rotate with a specified velocity in right direction (increasing the position counter).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.2 24 / 113 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 internal units ([int]) of the TMC429 motion controller used on the PD-1160 module. Please see also section 6.1. Internal function: • First, velocity mode is selected.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.3 25 / 113 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 0 Reply in Direct Mode Status Value 100 - OK don’t care Example Stop motor 0.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.4 26 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 28 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.5 29 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.6 30 / 113 GAP (Get Axis Parameter) Most motion / driver related parameters of the PD-1160 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).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.7 31 / 113 STAP (Store Axis Parameter) This command is used to store TMCL axis parameters permanently in the EEPROM of the module. This command is mainly needed to store the default configuration of the module. The contents of the user variables can either be automatically or manually restored at power on.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.8 32 / 113 RSAP (Restore Axis Parameter) With this command the contents of an axis parameter can be restored from the EEPROM. By default, all axis parameters are automatically restored after power up. An axis parameter that has been changed before can be reset to the stored value by this instruction.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.9 33 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.10 34 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.11 35 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.12 36 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.13 37 / 113 RFS (Reference Search) The PD-1160 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.14 39 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 40 / 113 Digital Outputs in Bank 2 Port Command Range OUT0 SIO 0, 2, 0/1 OUT1 SIO 1, 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 of the lower eight bits represents one of the digital outputs. So the range for is 0. . . 255.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.15 41 / 113 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 12 bit result in the range of 0. . . 4095.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 42 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 43 / 113 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 ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.16 44 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.17 46 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.18 47 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.19 49 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.20 50 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.21 51 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.22 52 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.23 54 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.24 55 / 113 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).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.25 56 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 57 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.26 58 / 113 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).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.27 59 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.28 60 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.29 62 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.30 63 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.31 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.32 66 / 113 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 PD-1160 module. Info Related commands: DI, VECT, RETI.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.33 67 / 113 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 PD-1160 module. Info Related commands: EI, VECT, RETI.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.34 68 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.35 70 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.36 71 / 113 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. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.37 72 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 3.7.38 74 / 113 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).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 75 / 113 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).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 4 76 / 113 Axis Parameters Most motor controller features of the PD-1160 module are controlled by axis parameters. Axis parameters can be modified or read using SAP, GAP and AAP commands. Some axis parameters can also be stored to or restored from the EEPROM using STAP and RSAP commands. This chapter describes all axis parameters that can be used on the PD-1160 module. Please see also section 6.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 77 / 113 Number Axis Parameter Description Range [Units] Access 6 Maximum current Motor current used when motor is running. The maximum value is 255 which means 100% of the maximum current of the module. The current can be adjusted in 32 steps: 0. . . 255 RW 0. . . 7 79. . . 87 160. . . 167 240. . . 247 8. . . 15 88. . . 95 168. . . 175 248. . . 255 16. . . 23 96. . . 103 176. . . 183 24. .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 78 / 113 Number Axis Parameter Description Range [Units] Access 138 Ramp mode Automatically set when using ROR, ROL, MST and MVP. 0: Position mode. Steps are generated, when the parameters actual position and target position differ. Trapezoidal speed ramps are provided. 2: Velocity mode.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 79 / 113 Number Axis Parameter Description Range [Units] Access 154 Pulse divisor The exponent of the scaling factor for the pulse (step) generator. Change this parameter carefully (in steps of one) and only while the motor is not moving. Lower values lead to higher speeds. This parameter specifies the relation between internal and real world velocity units. 0. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 80 / 113 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. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 81 / 113 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. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 82 / 113 Number Axis Parameter Description Range [Units] Access 183 smartEnergy slow run current Sets the motor current which is used below the threshold speed. A value of 255 means 100% of the maximum current of the module. 0. . . 255 RW 184 Random TOff mode 0 - Chopper off time is fixed 1 - Chopper off time is random 0/1 RW 1. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 83 / 113 Number Axis Parameter Description Range [Units] Access 200 Boost current Current used for acceleration and deceleration phases. If set to 0 the same current as set by axis parameter #6 will be used. Same scaling as with axis parameter #6. 0. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 84 / 113 Number Axis Parameter Description Range [Units] 212 Maximum encoder deviation When the actual position (parameter #1) and the encoder position (parameter #209) differ more than set here the motor will be stopped. This function is switched off when the maximum deviation is set to zero. 0 RW . . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 Number Axis Parameter Description Table 15: All Axis Parameters of the PD-1160 Module ©2018 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany Terms of delivery and rights to technical change reserved. Download newest version at www.trinamic.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 5 86 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 87 / 113 All Global Parameters of the PD-1160 Module in Bank 0 Number 65 Global Parameter RS485 baud rate Description 0 9600 1 14400 2 19200 3 28800 4 38400 5 57600 6 76800 7 115200 8 230400 Range [Units] Access 0. . . 8 RWA Default 66 Serial address Module (target) address for RS485. 1. . . 255 RWA 67 ASCII Mode Configure the TMCL ASCII interface: 0. . . 63 RWA 0. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 88 / 113 Number Global Parameter Description Range [Units] Access 75 Telegram pause time Pause time before the reply via RS485 is sent. For use with older RS485 interfaces it is often necessary to set this parameter to 15 or more (e.g. RS485 adapters controlled by the RTS pin). For CAN interface this parameter has no effect! 0. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 89 / 113 Number Global Parameter Description Range [Units] Access 90 Reverse shaft Reverse motor and encoder direction. 0 - normal direction (default) 1 - reverse direction Reversing the motor direction only works for normal mode, not for step/direction mode. 0/1 RWA 128 TMCL application status 0 - stop 1 - run 2 - step 3 - reset 0. . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 90 / 113 User Variables in Bank 2 Number Global Parameter Description Range [Units] Access 0. . . 55 user variables #0. . . #55 TMCL user variables -2147483648 . . . 2147483647 RWE 56. . . 255 user variables #56. . . #255 TMCL user variables -2147483648 . . . 2147483647 RWE Table 18: User Variables in Bank 2 5.4 Bank 3 Bank 3 contains interrupt parameters. Some interrupts need configuration (e.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 6 91 / 113 Module Specific Hints This section contains some hints that are specific to the PD-1160 module. 6.1 Velocity and Acceleration Calculation On the PD-1160 module, the internal units of the TMC429 motion controller IC are used to specify velocity and acceleration values. The formulae for converting between internal units of this module and real world units are given in this section. Note 6.1.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 6.1.3 92 / 113 How to choose Pulse Divisor and Ramp Divisor The pulse divisor should be choosen in such a way that the range of the velocity internal units (0. . . 2047) covers the entire velocity range which is needed by the application.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 93 / 113 • The motor can be stopped automatically if motor position and encoder position differ too much (deviation error). This can be set using axis parameter #212 (maximum deviation). Setting this parameter to 0 turns off this feature. • As the built-in encoder is a magnetic encoder, the absolute position value can also be read. Use GAP 215, 0 to read the absolute (single-turn) position value.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 94 / 113 • To read out or to change the position value of the encoder use axis parameter #216. To read out the position of the internal encoder use GAP 216, 0. The encoder position register can also be changed using command SAP 216, 0, , with n = -2147483648 . . . 2147483647. • Axis parameter #217 is used to change the encoder settings. This also includes the prescaler of the encoder.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 95 / 113 The special functions of bit 2, 3 and 4 are shown in table 22. Add these values to the value supplied to the SAP 217 command to activate these functions. Special Encoder Functions Bit Value (add to
) Function 2 4 If set the encoder will be zeroed with next null channel event. 3 8 If set in combination with bit 2: Encoder will be zeroed with each null channel event.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 7 96 / 113 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. 7.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 7.1.1 97 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 L 98 / 113 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 7.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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 99 / 113 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 7.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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 L 100 / 113 R start stop home switch : reference search speed (axis parameter 194) : reference switch speed (axis parameter 195) Figure 9: Reference search Mode 7 7.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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 7.2 101 / 113 stallGuard2 The module is equipped with motor driver chips that feature load measurement. This load measurement can be used for stall detection. stallGuard2 delivers a sensorless load measurement of the motor as well 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 7.3 102 / 113 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 11 shows all the adjustment points for coolStep.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 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).
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 8 104 / 113 TMCL Programming Techniques and Structure 8.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. 8.2 Main Loop Embedded systems normally use a main loop that runs infinitely.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 17 105 / 113 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. 8.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 8.5 106 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 107 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 9 108 / 113 Figures Index 1 2 3 4 5 6 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 . . . . . . . 6 6 97 97 98 98 ©2018 TRINAMIC Motion Control GmbH & Co.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 109 / 113 Tables Index 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 . . . . . . . . . .
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 11 110 / 113 Supplemental Directives 11.1 Producer Information 11.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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 111 / 113 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.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 12 112 / 113 Revision History 12.1 Firmware Revision Version Date Author Description V1.18 2012-MAY-06 OK Release V1.19 2012-JUL-25 OK Global parameter #79 added V1.20 2012-OKT-04 OK Global parameter #87 (secondary address for RS232/RS485) added. Reference search: the last position before setting the counter to zero can be read out with axis parameter 197. V1.
PD-1160 TMCL™ Firmware Manual • Firmware Version V1.42 | Document Revision V1.06 • 2018-JAN-09 Version Date Author Description V1.42 2017-FEB-14 OK New axis parameter #150. Table 25: Firmware Revision 12.2 Document Revision Version Date Author Description V1.04 2017-FEB-28 OK Document completely revised. V1.05 2017-AUG-10 OK Description of axis parameters #5 and #130 improved. V1.06 2018-JAN-09 OK Typo in description of axis parameter #204 corrected.