Trinamic TMCM-351 Firmware Manual Download Page 9

TMCM-351 TMCL Firmware V4.45 Manual (Rev. 1.06 / 2014-MAY-16) 

 

 
 
www.trinamic.com 

 

2.2.2

 

Testing with Encoder 

The motor rotates between two positions and stops if itis obstructed. The position is then corrected so that 
the motor always reaches the correct target positions. 
The  encoder  multiplier  and  the  microstep  resolution  must  be  set  so  that  the  resolution  of  the  encoder 
position and the motor position match with each other. 
The  values  here  are  for  an  encoder  with  2000  steps  per  rotation  and  a  motor  with  200  full  steps  per 
rotation. The setting of 64 microsteps then results in a motor resolution of 12800 microsteps per rotation 
and the encoder multiplier of 68672 (=>6.4) also results in an encoder resolution of 12800 steps per rotation. 

 

 

 

// Encoder demo program for all modules with encoder interface 

 

           

MST

 0              

 

//Ensure that the motor is not moving

 

        

CSUB

 WaitUntilStanding 

        

SAP

 210, 0, 68672 

 

//Encoder multiplier (6.4)

 

        

SAP

 209, 0, 0      

 

//reset encoder position

 

        

SAP

 0, 0, 0        

 

//reset the motor

 

        

SAP

 1, 0, 0        

 

//position registers

 

        

SAP

 140, 0, 6      

 

//Microstep resolution (64)

 

        

SAP

 5, 0, 50       

 

//Acceleration

 

        

SAP

 212, 0, 250    

 

//use  automatic  deviation  check  to  stop

     

motor

 

                           

 

//when it is obstructed 

 
Loop:   

MVP

 

ABS

, 0, 128000        

//Rotate 10 revolutions

 

        

CSUB

 WaitUntilRunning     

//Wait until the motor is running

 

        

CSUB

 WaitUntilStanding    

//Wait until the motor has stopped

 

        

GAP

 8, 0                  

//Check  if  the  end  position  has  been 
reached 

        

JC

 

NZ

, PosReached1        

//Jump if yes

 

        

GAP

 209, 0                

//if not: copy encoder position to

... 

        

AAP

 0, 0                  

//

...

target position and...

 

        

AAP

 1, 0                  

//...actual position

 

        

WAIT

 

TICKS

, 0, 50         

//wait 0.5sec

 

        

JA

 Loop                   

//continue the move

 

 
PosReached1:                      

//End position has been reached

 

        

WAIT

 

TICKS

, 0, 200        

//Wait 2sec

 

Rst2:   

MVP

 

ABS

, 0, 0             

//Move 10 revolutions back

 

        

CSUB

 WaitUntilRunning     

//Wait until the motor is running

 

        

CSUB

 WaitUntilStanding    

//Wait until the motor has stopped

 

        

GAP

 8, 0                  

//Check  if  the  end  position  has  been 
reached 

        

JC

 

NZ

, PosReached2        

//Jump if yes

 

        

GAP

 209, 0                

//if not: copy encoder position to... 

        

AAP

 0, 0                  

//...target position and...

 

        

AAP

 1, 0                  

//...actual position

 

        

WAIT

 

TICKS

, 0, 50         

//wait 0.5sec

 

        

JA

 Rst2                   

//continue the move 

 

PosReached2:                      

//The other end position has been reached

 

        

WAIT

 

TICKS

, 0, 200        

//Wait 2sec

 

        

JA

 Loop                   

//Start again

 

 
WaitUntilRunning:                 

//Subroutine that waits until the motor is 
running 

       

GAP

 3, 0 

       

COMP

 0 

       

JC

 

EQ

, WaitUntilRunning 

       

RSUB 

 
WaitUntilStanding:                

//Subroutine  that  waits  until  the  motor

 

has stooped

 

       

GAP

 3, 0 

       

COMP

 0 

       

JC

 

NE

, WaitUntilStanding 

       

RSUB 

Summary of Contents for TMCM-351

Page 1: ...MODULE FOR STEPPER MOTORS MODULE Firmware Version V4 45 TMCL FIRMWARE MANUAL TMCM 351 3 Axis Stepper Controller Driver 2 8 A 24 V SPI RS232 RS485 CAN and USB Encoder Interface...

Page 2: ...r stop 24 4 6 4 MVP move to position 25 4 6 5 SAP set axis parameter 27 4 6 6 GAP get axis parameter 28 4 6 7 STAP store axis parameter 29 4 6 8 RSAP restore axis parameter 30 4 6 9 SGP set global par...

Page 3: ...ed Event 65 4 6 39 BIN return to binary mode 65 4 6 40 TMCL Control Functions 66 5 Axis Parameters 67 6 Global Parameters 71 6 1 Bank 0 71 6 2 Bank 1 74 6 3 Bank 2 74 6 4 Bank 3 75 7 Hints and Tips 76...

Page 4: ...power outputs all open collector 1 shutdown input enable disable driver stage in hardware 4 dedicated analogue inputs programmable 3 3V 10V input range SPI 1 connector with three chip select signals...

Page 5: ...Avoid bounding I O wires with motor power wires as this may cause noise picked up from the motor supply Do not exceed the maximum power supply of 28 5V DC Start with power supply OFF 2 1 Starting up 1...

Page 6: ...B to pin 10 1 2 9 10 Pin Label Pin Label 1 GND 2 GND 3 Encoder_0 1 2_N 4 Encoder_0 1 2_N 5 Encoder_0 1 2_A 6 Encoder_0 1 2_A 7 5V output 8 5V output 9 Encoder_0 1 2_B 10 Encoder_0 1 2_B GND B A N 5V...

Page 7: ...ED for power should glow now This indicates that the on board 5V supply is available If this does not occur switch power OFF and check your connections as well as the power supply 6 Start the TMCL IDE...

Page 8: ...3 Press icon Run The desired program will be executed 4 Click Stop button to stop the program A simple example for using TMCL and TMCL IDE ROL 0 500 Rotate motor 0 with speed 500 WAIT TICKS 0 500 MST...

Page 9: ...ration SAP 212 0 250 use automatic deviation check to stop motor when it is obstructed Loop MVP ABS 0 128000 Rotate 10 revolutions CSUB WaitUntilRunning Wait until the motor is running CSUB WaitUntilS...

Page 10: ...e is not detected please check all points above cables interface power supply COM port baud rate 3 Issue a command by choosing instruction type if necessary motor and value and click Execute to send i...

Page 11: ...eply otherwise it will stay in receive mode It will not send any data over the interface without receiving a command first This way any collision on the bus will be avoided when there are more than tw...

Page 12: ...or i 1 i 8 i Checksum Command i Command 8 Checksum insert checksum as last byte of the command Now send it to the module in Delphi var i Checksum byte Command array 0 8 of byte Set the Command array t...

Page 13: ...n EEPROM locked 6 Command not available 4 3 Standalone Applications The module is equipped with a TMCL memory for storing TMCL applications You can use TMCL IDE for developing standalone TMCL applicat...

Page 14: ...ameter bank number Store global parameter TMCL user variables only RSGP 12 parameter bank number Restore global parameter TMCL user variable only RFS 13 START STOP STATUS motor number Reference search...

Page 15: ...arameters can be set independently for the axis whereas global parameters control the behavior of the module itself These commands can also be used in direct mode and in standalone mode Mnemonic Comma...

Page 16: ...r and an X register When executed in a TMCL program in stand alone mode all TMCL commands that read a value store the result in the accumulator The X register can be used as an additional memory when...

Page 17: ...gram will be continued 4 4 2 7 3 Interrupt Vectors The following table shows all interrupt vectors for the three motors that can be used Interrupt number Interrupt type 0 Timer 0 1 Timer 1 2 Timer 2 3...

Page 18: ...sing a WAIT command for the delay Loop SIO 3 2 1 WAIT TICKS 0 50 SIO 3 2 0 WAIT TICKS 0 50 JA Loop Here is the interrupt handling routine Timer0Irq GIO 0 2 check if OUT0 is high JC NZ Out0Off jump if...

Page 19: ...download mode target command execution is stopped and all following commands are transferred to the TMCL memory don t care don t care starting address of the application 133 quit download mode target...

Page 20: ...2 500 A MST 1 ABIN These command lines would address the module with address 1 To address e g module 3 use address character C instead of A The last command line shown above will make the module retur...

Page 21: ...Bit 4 and Bit 5 determine how the characters that are entered are echoed back Normally both bits are set to zero In this case every character that is entered is echoed back when the module is addresse...

Page 22: ...ferred to axis parameter 0 target velocity The module is based on the TMC429 stepper motor controller and the TMC249 power driver This makes possible choosing a velocity between 0 and 2047 Related com...

Page 23: ...the TMC429 stepper motor controller and the TMC249 power driver This makes possible choosing a velocity between 0 and 2047 Related commands ROR MST SAP GAP Mnemonic ROL motor velocity Binary represen...

Page 24: ...ed commands ROL ROR SAP GAP Mnemonic MST motor Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 3 don t care motor 0 2 don t care Reply in direct mode STATUS VALUE 100 OK don t care Example St...

Page 25: ...oo Moving the motor to a previously stored coordinate refer to SCO for details Please note that the distance between the actual position and the new one should not be more than 2 147 483 647 231 1 mic...

Page 26: ...mic com Example Move motor 0 to previously stored coordinate 8 Mnemonic MVP COORD 0 8 Binary Byte Index 0 1 2 3 4 5 6 7 Function Target address Instruction Number Type Motor Bank Operand Byte3 Operand...

Page 27: ...nds GAP STAP RSAP AAP Mnemonic SAP parameter number motor value Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 5 parameter number motor 0 2 value Reply in direct mode STATUS VALUE 100 OK don...

Page 28: ...d adding leading zeros or ones for negative values Related commands SAP STAP AAP RSAP Mnemonic GAP parameter number motor Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 6 parameter number mo...

Page 29: ...ALUE 7 parameter number motor 0 2 don t care the value operand of this function has no effect Instead the currently used value e g selected by SAP is saved Reply in direct mode STATUS VALUE 100 OK don...

Page 30: ...on EEPROM memory to its RAM location Relate commands SAP STAP GAP and AAP Mnemonic RSAP parameter number motor Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 8 parameter number motor 0 2 don...

Page 31: ...The TMCL user variables will not be stored in the EEPROM automatically but this can be done by using STGP commands For a table with parameters and bank numbers which can be used together with this co...

Page 32: ...on the parameter is read out of the correct position in the appropriate device The parameter format is converted adding leading zeros or ones for negative values Related commands SGP STGP RSGP AGP Mne...

Page 33: ...umbers which can be used together with this command please refer to chapter 6 Internal function the specified parameter is copied from its RAM location to the configuration EEPROM Related commands SGP...

Page 34: ...ank numbers which can be used together with this command please refer to chapter 6 Internal function The specified parameter is copied from the configuration EEPROM memory to its RAM location Relate c...

Page 35: ...rence search can be checked Internal function the reference search is implemented as a state machine so interaction is possible during execution Related commands WAIT Mnemonic RFS START STOP STATUS mo...

Page 36: ...his purpose Related commands GIO WAIT Mnemonic SIO port number bank number value Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 14 port number bank number 2 value 0 1 Reply structure STATUS...

Page 37: ...E ANALOGUE INPUT It is possible to adjust the analogue input with the following commands SIO 8 0 0 for 3 3V input range SIO 8 0 1 for 10V input range COMMAND FOR SWITCHING THE PULL UP RESISTORS FOR AD...

Page 38: ...e reply without affecting the accumulator The actual status of a digital output line can also be read Internal function The specified line is read Related commands SIO WAIT Mnemonic GIO port number ba...

Page 39: ...l values only READING ALL DIGITAL INPUTS WITH ONE GIO COMMAND Set the type parameter to 255 and the bank parameter to 0 In this case the status of all digital input lines will be read to the lower eig...

Page 40: ...the OUT lines that have been set by SIO commands can be read back using bank 2 1 2 20 19 Connector 3 Pin I O port Command Comment Range 1 AIN_0 GIO 0 1 Connector 1 0 1023 3 AIN_1 GIO 1 1 Connector 1 0...

Page 41: ...ION NO TYPE operation MOT BANK VALUE 19 0 ADD add to accu 1 SUB subtract from accu 2 MUL multiply accu by 3 DIV divide accu by 4 MOD modulo divide by 5 AND logical and accu with 6 OR logical or accu w...

Page 42: ...ding to the comparison result Related commands JC jump conditional GAP GGP GIO CALC CALCX Mnemonic COMP value Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 20 don t care don t care comparis...

Page 43: ...STRUCTION NO TYPE condition MOT BANK VALUE 21 0 ZE zero 1 NZ not zero 2 EQ equal 3 NE not equal 4 GT greater 5 GE greater equal 6 LT lower 7 LE lower equal 8 ETO time out error 9 EAL external alarm 12...

Page 44: ...WAIT CSUB Mnemonic JA Label Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 22 don t care don t care jump address Example An infinite loop in TMCL Loop MVP ABS 0 10000 WAIT POS 0 0 MVP ABS 0...

Page 45: ...will be ignored if there is no more stack space left Related commands RSUB JA Mnemonic CSUB Label Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 23 don t care don t care subroutine address E...

Page 46: ...t care Binary format of RSUB Byte Index 0 1 2 3 4 5 6 7 Function Target address Instruction Number Type Motor Bank Operand Byte3 Operand Byte2 Operand Byte1 Operand Byte0 Value hex 01 18 00 00 00 00 0...

Page 47: ...earch of the motor specified by the motor field has been reached An optional timeout value 0 for no timeout must be specified by the ticks parameter The timeout flag ETO will be set after a timeout li...

Page 48: ...uld be placed at the end of every standalone TMCL program It is not to be used in direct mode Internal function TMCL instruction fetching is stopped Related commands none Mnemonic STOP Binary represen...

Page 49: ...to be sent When bit 7 of the bus number is set this value is ignored and the contents of the accumulator are sent instead Please note that in the TMCL IDE always all three values have to be specified...

Page 50: ...inary representation INSTRUCTION NO TYPE MOT BANK VALUE 30 coordinate number 0 20 motor 0 2 position 231 231 1 Reply in direct mode STATUS VALUE 100 OK don t care Example Set coordinate 1 of motor to...

Page 51: ...rdinate number motor Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 31 coordinate number 0 20 motor 0 2 don t care Reply in direct mode STATUS VALUE 100 OK don t care Example Get motor value...

Page 52: ...EPROM Note that the coordinate number 0 is always stored in RAM only Internal function the selected 24 bit position values are written to the 20 by 3 bytes wide coordinate array Related commands SCO G...

Page 53: ...M only For Information about storing coordinates refer to the SCO command Internal function the actual value of the accumulator is stored in the internal position array Related commands GCO CCO MVP CO...

Page 54: ...CTION NO TYPE operation MOT BANK VALUE 33 0 ADD add X register to accu 1 SUB subtract X register from accu 2 MUL multiply accu by X register 3 DIV divide accu by X register 4 MOD modulo divide accu by...

Page 55: ...lated commands AGP SAP GAP SGP GGP GIO GCO CALC CALCX Mnemonic AAP parameter number motor Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 34 parameter number motor 0 2 don t care Reply in dir...

Page 56: ...odified automatically by a standalone application For a table with parameters and bank numbers which can be used together with this command please refer to chapter 6 Related commands AAP SGP GGP SAP G...

Page 57: ...EAL clear the external alarm flag EDV clear the deviation flag EPO clear the position error flag Related commands JC Mnemonic CLE flags where flags ALL ETO EDV EPO Binary representation INSTRUCTION NO...

Page 58: ...1 Timer 1 2 Timer 2 3 Target position reached 0 4 Target position reached 1 5 Target position reached 2 15 stallGuard axis 0 16 stallGuard axis 1 17 stallGuard axis 2 21 Deviation 0 22 Deviation 1 23...

Page 59: ...ABLE SHOWS ALL INTERRUPT VECTORS THAT CAN BE USED Interrupt number Interrupt type 0 Timer 0 1 Timer 1 2 Timer 2 3 Target position reached 0 4 Target position reached 1 5 Target position reached 2 15 s...

Page 60: ...t address Instruction Number Type Motor Bank Operand Byte3 Operand Byte2 Operand Byte1 Operand Byte0 Value hex 01 19 FF 00 00 00 00 00 Enable interrupt when target position reached EI 3 Binary format...

Page 61: ...TABLE SHOWS ALL INTERRUPT VECTORS THAT CAN BE USED Interrupt number Interrupt type 0 Timer 0 1 Timer 1 2 Timer 2 3 Target position reached 0 4 Target position reached 1 5 Target position reached 2 15...

Page 62: ...t address Instruction Number Type Motor Bank Operand Byte3 Operand Byte2 Operand Byte1 Operand Byte0 Value hex 01 1A FF 00 00 00 00 00 Disable interrupt when target position reached DI 3 Binary format...

Page 63: ...ved registers A register X register flags are copied back Normal program execution continues Related commands EI DI VECT Mnemonic RETI Binary representation INSTRUCTION NO TYPE MOT BANK VALUE 38 don t...

Page 64: ...r a customer specific programming Internal function Call user specific functions implemented in C by TRINAMIC Related commands none Mnemonic UF0 UF7 parameter number Binary representation INSTRUCTION...

Page 65: ...The value field contains a bit mask where every bit stands for one motor bit 0 motor 0 bit 1 motor 1 bit 2 motor 2 Reply in direct mode right after execution of this command Byte Index 0 1 2 3 4 5 6...

Page 66: ...Motor Bank and Value are ignored 137 don t care Reset to factory defaults Reset all settings stored in the EEPROM to their factory defaults This command does not send back a reply Value must be 1234...

Page 67: ...this parameter is set by hardware to the maximum speed during acceleration and to zero during deceleration and rest 2047 RW 3 Actual speed The current rotation speed 2047 RW 4 Maximum positioning spe...

Page 68: ...witch in three switch mode 0 1 R 12 Right limit switch disable If set deactivates the stop function of the right switch 0 1 RWE 13 Left limit switch disable Deactivates the stop function of the left s...

Page 69: ...switch is hit 0 1 RWE 153 Ramp divisor The exponent of the scaling factor for the ramp generator should be de incremented carefully in steps of one 0 13 RWE 154 Pulse divisor The exponent of the scali...

Page 70: ...perature warning Bit 7 Overtemperature 0 255 R 209 Encoder position The value of an encoder register can be read out or written encoder steps RW 210 Encoder prescaler Prescaler for the encoder See cha...

Page 71: ...high word read only 2 cover datagram position 3 cover datagram length 4 cover datagram contents 5 reference switch states read only 6 TMC428 429 SMGP register 7 22 driver chain configuration long word...

Page 72: ...CII mode Bits 4 and 5 00 Echo back each character 01 Echo back complete command 10 Do not send echo only send command reply RWE 68 Serial heartbeat Serial heartbeat for the RS232 RS485 interface If th...

Page 73: ...ays stored in the EEPROM only 0 or 1 RWE 85 Do not store user variables 0 user variables are restored default 1 user variables are not restored 0 1 RWE 87 Serial secondary address Second module target...

Page 74: ...rpose 32 bit variables for the use in TMCL applications They are located in RAM and can be stored to EEPROM After booting their values are automatically restored to the RAM Up to 56 user variables are...

Page 75: ...rupts ms 32 bit unsigned ms RWE 27 Stop left 0 trigger transition 0 off 1 low high 2 high low 3 both 0 3 RWE 28 Stop right 0 trigger transition 0 off 1 low high 2 high low 3 both 0 3 RWE 29 Stop left...

Page 76: ...speed is identical to the maximum positioning speed axis parameter 4 unless reduced by axis parameter 194 After hitting the reference switch the motor slowly moves right until the switch is released...

Page 77: ...400 3200 6 25 SAP 210 M0 3200 10000 68672 6 4 SAP 210 M0 68672 10240 4096 8 SAP 210 M0 4096 12800 6400 12 5 SAP 210 M0 6400 20000 71808 12 8 SAP 210 M0 71808 20480 8192 16 SAP 210 M0 8192 25600 78432...

Page 78: ...step errors may occur with some motors as the minimum motor current that can be reached is slightly higher than zero depending on the inductivity resistance and supply voltage of the motor This can be...

Page 79: ...and whose failure to perform when properly used in accordance with instructions provided can be reasonably expected to result in personal injury or death TRINAMIC Motion Control GmbH Co KG 2009 2014...

Page 80: ...39 2012 APR 26 OK TMCL firmware updates for other modules 4 40 2012 JUN 15 OK TMCL firmware updates for other modules 4 41 2012 SEP 21 OK Global parameter 87 secondary address for RS232 RS485 added R...

Reviews: