background image

PD42-1270 TMCL

Firmware Manual • Firmware Version V1.00 | Document Revision V1.0 • 2017-Mar-02

6 / 91

2

First Steps with TMCL

In this chapter you can find some hints for your first steps with the PD42-1270 and TMCL. You may skip

this chapter if you are already familiar with TMCL and the TMCL-IDE.

Things that you will need

• Your PD42-1270 PANdrive™.

• A CAN adapter.

• A power supply (24V DC) for your PD42-1270 module.

• The TMCL-IDE 3.x already installed on your PC

2.1

Basic Setup

First of all, you will need a PC with Windows (at least Windows 7) and the TMCL-IDE 3.x installed on it. If

you do not have the TMCL-IDE installed on your PC then please download it from the TMCL-IDE product

page of Trinamic’s website (http://www.trinamic.com) and install it on your PC.

Please also ensure that your PD42-1270 is properly connected to your power supply and that the stepper

motor is properly connected to the module. Please see the PD42-1270 hardware manual for instructions

on how to do this.

Do not connect or disconnect a stepper motor to or from the module while the

module is powered!

Then, please start up the TMCL-IDE. After that you can connect your PD42-1270 via CAN and switch on the

power supply for the module (while the TMCL-IDE is running on your PC). The module will be recognized

by the TMCL-IDE, and necessary driver registrations in Windows will automatically done by the TMCL-IDE.

2.2

Using the TMCL Direct Mode

At first try to use some TMCL commands in direct mode. In the TMCL-IDE a tree view showing the PD42-

1270 and all tools available for it is displayed. Click on the Direct Mode entry of the tool tree. Now, the

Direct Mode tool will pop up.

In the Direct Mode tool you can choose a TMCL command, enter the necessary parameters and execute

the command.

2.3

Changing Axis Parameters

Next you can try changing some settings (also called axis parameters) using the SAP command in direct

mode. Choose the SAP command. Then choose the parameter type and the motor number. Last, enter

the desired value and click execute to execute the command which then changes the desired parameter.

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]

Default

Access

4

Maximum

speed

The maximum speed used for posi-

tioning ramps.

0

. . .

7999774

[pps]

150000

RWE

©2017 TRINAMIC Motion Control GmbH & Co. KG, Hamburg, Germany

Terms of delivery and rights to technical change reserved.
Download newest version at

www.trinamic.com

Read entire documentation.

Summary of Contents for PD42-1270 TMCL

Page 1: ...e the motor Features Single Axis Stepper motor control Supply voltage 24V DC TMCL Motion Contoller CAN dcStep Integrated sixPoint ramp motion controller stealthChop silent PWM mode spreadCycle smart m...

Page 2: ...SGP Set Global Parameter 23 3 6 6 GGP Get Global Parameter 24 3 6 7 STGP Store Global Parameter 25 3 6 8 RSGP Restore Global Parameter 26 3 6 9 RFS Reference Search 27 3 6 10 GIO Get Input 29 3 6 11...

Page 3: ...s and Structure 81 8 1 Initialization 81 8 2 Main Loop 81 8 3 Using Symbolic Constants 81 8 4 Using Variables 82 8 5 Using Subroutines 83 8 6 Combining Direct Mode and Standalone Mode 83 9 Figures Ind...

Page 4: ...eration High performance microcontroller for overall system control and communication protocol handling Up to 256 microsteps per full step High e cient operation low power dissipation Dynamic current...

Page 5: ...omatic current scaling based on the load measurement via stallGuard2 adapting the required current to the load Energy consumption can be reduced by as much as 75 coolStep allows substantial energy sav...

Page 6: ...r the module while the TMCL IDE is running on your PC The module will be recognized by the TMCL IDE and necessary driver registrations in Windows will automatically done by the TMCL IDE 2 2 Using the...

Page 7: ...6 microsteps 0 8 4 RWE 141 Microstep Interpolation Interpolation of the current microstep resolution to 256 microsteps 0 No interpolation 1 Interpolation to 256 microsteps 0 1 1 RWE 179 VSense Sense r...

Page 8: ...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 Also tr...

Page 9: ...han two nodes connected to a single bus The Trinamic Motion Control Language TMCL provides a set of structured motion control commands Every motion control command can be given by a host computer or c...

Page 10: ...es including the module address byte using 8 bit addition Here are two examples which show how to do this Checksum calculation in C 1 unsigned char i Checksum unsigned char Command 9 3 Set the Command...

Page 11: ...eply Note When using CAN interface the reply does not contain an address byte and a checksum byte With CAN the CAN ID is used as the reply address and the checksum is not needed because the CAN bus us...

Page 12: ...e 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 They will be assembled automatica...

Page 13: ...ut mod ule speci c settings e g communica tion settings or TMCL user variables STGP 11 parameter bank number Store global parameter TMCL user variables only RSGP 12 parameter bank number Restore globa...

Page 14: ...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 Parameter Commands Mnemonic C...

Page 15: ...hey could also be used in direct mode it does not make much sense to do so Calculation Commands Mnemonic Command number Meaning CALC 19 Calculate using the accumulator and a constant value CALCX 33 Ca...

Page 16: ...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 to query the actual position of the motor without affecting the ow of the TMCL...

Page 17: ...section 4 Internal function The speci ed value is written to the axis parameter speci ed by the parameter number Related commands GAP AAP Mnemonic SAP parameter number axis value Binary representatio...

Page 18: ...can be used together with this command please refer to section 4 Internal function The speci ed value gets copied to the accumulator Related commands SAP AAP Mnemonic GAP parameter number axis Binary...

Page 19: ...ction The axis parameter speci ed by the type and bank number will be stored in the EEPROM Related commands SAP AAP GAP RSAP Mnemonic STAP parameter number bank Binary Representation Instruction Type...

Page 20: ...The axis parameter speci ed by the type and bank number will be restored from the EEPROM Related commands SAP AAP GAP RSAP Mnemonic RSAP parameter number bank Binary Representation Instruction Type M...

Page 21: ...th parameters and values which can be used together with this command please refer to section 5 Internal function The speci ed value will be copied to the global parameter speci ed by the type and ban...

Page 22: ...mmand please refer to section 5 Internal function The global parameter speci ed by the type and bank number will be copied to the accumulator register Related commands SGP AGP Mnemonic GGP parameter n...

Page 23: ...ther with this command please refer to dection 5 2 Internal function The global parameter speci ed by the type and bank number will be stored in the EEPROM Related commands SGP AGP GGP RSGP Mnemonic S...

Page 24: ...he global parameter speci ed by the type and bank number will be restored from the EEPROM Related commands SGP AGP GGP STGP Mnemonic RSGP parameter number bank Binary Representation Instruction Type M...

Page 25: ...algorithm to meet your needs please see chapter 4 Internal function The internal reference search state machine is started or stoped or its state is queried Related commands SAP GAP WAIT Mnemonic RFS...

Page 26: ...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 2017 TRINAMIC Motion Control GmbH Co KG Hamburg Germ...

Page 27: ...r The actual status of a digital output line can also be read Internal function The state of the i o line speci ed by the type parameter and the bank parameter is read Related commands SIO Mnemonic GI...

Page 28: ...1 REFL_ENCA Reference Left Switch Encoder A Input GIO 1 0 0 1 2 REFR_ENCB Reference Right Switch Encoder B Input GIO 2 0 0 1 3 Enable TMC5130 Enable Pin GIO 3 0 0 1 4 DIAG0 TMC5130 Diag 0 Output GIO...

Page 29: ...monic CALC operation operand Binary representation Binary Representation Instruction Type Motor Bank Value 19 0 ADD add to accumulator 0 don t care operand 1 SUB subtract from accumulator 2 MUL multip...

Page 30: ...e 2 FFh Value Byte 1 ECh Value Byte 0 78h Checksum 78h Reply Status no error value 5000 Field Value Host address 02h Target address 01h Status 64h Instruction 13h Value Byte 3 FFh Value Byte 2 FFh Val...

Page 31: ...mmands JC GAP GGP GIO CALC CALCX Mnemonic COMP operand Binary Representation Instruction Type Motor Bank Value 20 0 don t care 0 don t care operand Example Jump to the address given by the label when...

Page 32: ...AIT CLE Mnemonic JC condition label Binary Representation Instruction Type Motor Bank Value 21 0 ZE zero 0 don t care jump address 1 NZ not zero 2 EQ equal 3 NE not equal 4 GT greater 5 GE greater equ...

Page 33: ...s 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 2017 TRINAMIC Motion Control GmbH Co...

Page 34: ...2 0 don t care 0 don t care jump address Example An in nite loop in TMCL 1 Loop MVP ABS 0 51200 3 WAIT POS 0 0 MVP ABS 0 0 5 WAIT POS 0 0 JA Loop Binary form of the JA Loop command when the label Loop...

Page 35: ...Binary Representation Instruction Type Motor Bank Value 23 0 don t care 0 don t care subroutine address Example Call a subroutine Loop 2 MVP ABS 0 10000 CSUB SubW Save program counter and jump to labe...

Page 36: ...tack is empty Related commands CSUB Mnemonic RSUB Binary Representation Instruction Type Motor Bank Value 24 0 don t care 0 don t care 0 don t care Example Please see the CSUB example section 3 6 15 B...

Page 37: ...pecial case for the ticks parameter When this parameter is set to 1 the contents of the accumulator register will be taken for this value So for example WAIT TICKS 0 1 will wait as long as speci ed by...

Page 38: ...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 2017 TRIN...

Page 39: ...e stopped Related commands none Mnemonic STOP Binary Representation Instruction Type Motor Bank Value 28 0 don t care 0 don t care 0 don t care Example Mnemonic STOP Binary Form of STOP Field Value Ta...

Page 40: ...te number motor number position 0 20 0 231 231 1 Example Set coordinate 1 of motor 0 to 1000 Mnemonic SCO 1 0 1000 Binary Form of SCO 1 0 1000 Field Value Target address 01h Instruction number 1Eh Typ...

Page 41: ...M only Internal function the desired value is read out of the internal coordinate array copied to the accumulator register and in direct mode returned in the value eld of the reply Related commands SC...

Page 42: ...sing 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 GCO coordinate number 255 0 copies the coordinate selected...

Page 43: ...of the selected motor is copied to selected coordinate array entry Related commands SCO GCO ACO MVP COORD Mnemonic CCO coordinate number motor number Binary Representation Instruction Type Motor Bank...

Page 44: ...ed to selected coordinate array entry Related commands SCO GCO CO MVP COORD Mnemonic ACO coordinate number motor number Binary Representation Instruction Type Motor Bank Value 39 coordinate number mot...

Page 45: ...Bank Value 33 0 ADD add X register to accumulator 0 don t care 0 don t care 1 SUB subtract X register from accumulator 2 MUL multiply accumulator by X register 3 DIV divide accumulator by X register 4...

Page 46: ...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 2017 TRINAMIC Motion Control GmbH Co KG Hamburg Germ...

Page 47: ...GIO GCO CALC CALCX Mnemonic AAP parameter number motor number Binary Representation Instruction Type Motor Bank Value 34 see chapter 4 0 value Reply in Direct Mode Status Value 100 OK don t care Exam...

Page 48: ...d with this com mand please see section 5 Related commands AAP SGP GGP SAP GAP GIO Mnemonic AGP parameter number bank number Binary Representation Instruction Type Motor Bank Value 35 parameter number...

Page 49: ...arm ag EDV clear the deviation ag EPO clear the position error ag Related commands JC WAIT Mnemonic CLE ags Binary Representation Instruction Type Motor Bank Value 36 0 ALL all ags 0 don t care 0 don...

Page 50: ...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 2017 TRINAMIC Motion Control GmbH Co KG Hamburg Germa...

Page 51: ...act the sales department of Trinamic Motion Control GmbH Co KG if you need a customized TMCL rmware Related commands none Mnemonic UF0 UF7 Binary Representation Instruction Type Motor Bank Value 64 71...

Page 52: ...one would like to have a position reached message The value eld contains a bit mask where every bit stands for one motor For one motor modules like the PD42 1270 it only makes sense to have bit 0 set...

Page 53: ...ecksum depends also on motor bit mask Additional Reply after Motor has reached Target Position Field Value Target address 01h Host address 02h Status 80h 128 Command 8Ah 138 Value Byte 3 00h Value Byt...

Page 54: ...ype Value 128 stop application stop a running TMCL application 0 don t care 0 don t care 129 run application start or continue TMCL program execution 0 from current address 0 don t care 1 from speci c...

Page 55: ...g format special reply or binary format 0 string format 1 binary format 0 don t care 137 restore factory settings Reset all settings in the EEPROM to their factory defaults This command does not send...

Page 56: ...motor 4999999 4999999 pps 0 R 4 Maximum speed The maximum speed used for posi tioning ramps 0 4999999 pps 51200 RWE 5 Maximum acceleration Maximum acceleration in positioning ramps Acceleration and de...

Page 57: ...o 0 turns off the rst acceleration deceleration phase maximum acceleration axis parameter 5 and maximum deceleration axis parameter 17 are used only 0 1000000 pps 2 RW 17 Maximum Deceleration Maximum...

Page 58: ...op mode always uses the deceleration ramp settings DMAX V1 D1 VSTOP and TZEROWAIT for stop ping the motor 0 Hard stop 1 Soft stop 0 1 0 RW 27 High speed chopper mode Switch to other chopper mode when...

Page 59: ...2 Freely usable debugging value 2147483648 2147483647 0 RW 153 debug value 3 Freely usable debugging value 2147483648 2147483647 0 RW 154 debug value 4 Freely usable debugging value 2147483648 214748...

Page 60: ...ng please note that this value is an offset to the hysteresis end value For classic const off time chopper mode this parameter will set return the sine wave offset 0 8 0 RW 167 Chopper off time The of...

Page 61: ...enable Enables the stallGuard2 lter for more precision of the movement If set reduces the measurement fre quency to one measurement per four fullsteps In most cases it is expedient to set the ltered m...

Page 62: ...phase motor in order to avoid the occurrence of a beat especially at low velocities 0 chopper sync func tion chopSync off 1 15 chopper synchronization 0 15 0 RW 186 PWM threshold speed The stealthCho...

Page 63: ...op switch from both sides 5 Search home switch in negative direction reverse the direction when left stop switch reached 6 Search home switch in positive di rection reverse the direction when right st...

Page 64: ...ion error These error ags are cleared automat ically when this parameter has been read out or when a motion command has been executed 0 3 0 R 208 Drive Status Flags TMC5130 ags of register DRVSTA TUS...

Page 65: ...e Units of velocity and acceleration de celeration settings 0 internal units of TMC5130 1 pps for velocity and pps s for ac celeration 0 1 1 RW Table 11 All PD42 1270 Axis 0 Parameters 2017 TRINAMIC M...

Page 66: ...hanging these parameters and use the appropriate func tions of the TMCL IDE to do it in an interactive way Meaning of the Letters in the Access Column Access type Command Description R GGP Parameter r...

Page 67: ...ates stored 0 1 0 RWA 85 Zero User Variables 0 user variables are restored 1 user variables are not restored 0 1 0 RWA 128 Application status Actual TMCL application status 0 stop 1 run 2 step 3 reset...

Page 68: ...an be stored in the EEPROM Table 14 Meaning of the Letters in the Access Column User Variables in Bank 2 Number Global Parameter Description Range Units Access 0 55 user variables 0 55 TMCL user varia...

Page 69: ...nput 3 Table 16 Pin Functionalities of PD42 1270 Speci c Modes In Mode Reference the three digital inputs correspond to reference switches Home Left Endstop and Rigth Endstop for GPI 1 2 and 3 respect...

Page 70: ...direction setting the reference point to the center of the two switching points The speed used for this calibration is de ned by axis parameter 195 Axis parameter 193 de nes the reference search mode...

Page 71: ...set axis parameter 193 to 66 to search the left end switch rst and then use the right end switch as the zero point left limit end stop switch L R right limit end stop switch start stop reference searc...

Page 72: ...et axis parameter 193 to 68 to search the right end switch instead left limit end stop switch L R stop reference search speed axis parameter 194 reference switch speed axis parameter 195 start Figure...

Page 73: ...e switch input L R right limit end stop switch reference search speed axis parameter 194 reference switch speed axis parameter 195 start stop home switch Figure 8 Reference search Mode 6 7 1 7 Mode 7...

Page 74: ...mainly for use with a circular axis The exact middle of the switch will be found and used as the zero point Figure 10 illustrates this Add 128 to the mode number i e set axis parameter 193 to 132 to r...

Page 75: ...This corresponds to a load angle of 90 between the magnetic eld of the stator and magnets in the rotor This also is the most energy e cient point of operation for the motor Stall detection means that...

Page 76: ...s to be con gured using parameters I169 and I171 In this chapter only basic axis parameters are mentioned which concern coolStep and stallGuard2 The complete list of axis parameters in chapter 4 conta...

Page 77: ...urements per decrement Scaling 0 3 32 8 2 1 0 slow decrement 3 fast decrement I171 smartEnergy current up step Sets the current increment step The current becomes incremented for each measured stallGu...

Page 78: ...ne has to know the fullstep resolution of the motor full steps per round and the microstep resolution setting of the module axis parameter 140 default setting is 256 microsteps per full step So to con...

Page 79: ...grams look like this 1 Initialization SAP 4 0 50000 define maximum positioning speed 3 SAP 5 0 10000 define maximum acceleration 5 MainLoop do something in this example just running between two positi...

Page 80: ...ROM back to the user variable Global parameter 85 controls if user variables will be restored from the EEPROM automatically on startup default setting or not user variables will then be initialized wi...

Page 81: ...an then change the value of a user variable using a direct mode SGP command which is regularly polled by the TMCL program e g in its main loop and so the TMCL program can react on such changes Vice ve...

Page 82: ...n or a run command with address 1 to call the second function or a run command with address 2 to call the third function You can see the addresses of the TMCL labels that are needed for the run comman...

Page 83: ...4 Reference search Mode 2 73 5 Reference search Mode 3 74 6 Reference search Mode 4 74 7 Reference search Mode 5 75 8 Reference search Mode 6 75 9 Reference search Mode 7 76 10 Reference search Mode...

Page 84: ...7 11 All PD42 1270 Axis 0 Parameters 67 12 Meaning of the Letters in the Access Column 68 13 All Global Parameters of the PD42 1270 Module in Bank 0 69 14 Meaning of the Letters in the Access Column 7...

Page 85: ...e in the document All trademarks and brand names used are property of their respective owners 11 4 Target User The documentation provided here is for programmers and engineers only who are equipped wi...

Page 86: ...c written consent TRINAMIC products are not designed nor intended for use in military or aerospace applications or environ ments or in automotive applications unless speci cally designated for such u...

Page 87: ...cription V0 8 2016 JUL 12 BS Exported from xml V0 9 2016 SEP 26 BS First complete version V1 00 2016 NOV 18 BS Final version with changes from Fw V1 0 Table 19 Document Revision 2017 TRINAMIC Motion C...

Reviews: