Post Go back to editing

TMCL Language/Host does not work correctly with 5160-EVAL-KIT

Category: Software
Product Number: TMC5160
Software Version: TMCL-IDE 4.3.0

I would like to write a script in the TMCL Host/PC script environment to operate a stepper motor. 

I have a TMC5160-EVAL-KIT, which includes the USB to PC board (Landungsbruecke?), an interconnecting board, and the TMC5160 eval driver board. 

I have a 23 frame stepper and an optical switch wired to the L reference switch. 

What I would like to do is rotate the motor until the switch changes from 5V to 0V, stop the motor, change the direction and rotate again until the same switch changes from 5V to 0V again.
And then repeat this cycle. 

I'm getting inconsistent results. When I run in direct mode, things seem to work, but in the Host/PC script environment nothing happens. 

SCRIPT:

#module 1 "COM6/USB/id1/LandungsbrueckeV3" "[LandungsbrueckeV3]"

SAP 4, 0, 10000, 1 //Set the maximum speed

SAP 1, 0, 0, 1 //set Actual position : TMC5160

Loop:

MVP ABS, 0, 150000, 1 //Move to position 150000

WAIT POS, 0, 0, 1

WAIT TICKS, 0, 200

MVP ABS, 0, 0, 1 //Move back to position 0

WAIT POS, 0, 0, 1

WAIT TICKS, 0, 100

Any help would be appreciated.

  • I'm just getting to grips with the 5160, so see how it works for you.

    The form of your program is in an example

    https://github.com/analogdevicesinc/TMCL-Script-Examples/blob/master/general/single%20axis/EX0007-Digital_Input.tmc

    your module address may need the 5160 detail adding to it.

    #module 1 COM6/USB/id1/LandungsbrueckeV3/TMC5160-EVAL

    This works for me:

    #module 1 COM10/USB/id1/LandungsbrueckeV3/TMC5160-EVAL

    // select module

    vtarget = 200000

    // set defaults

    //SAP 1, 0, 0, 1 // set ref position to 0

    SAP 6, 0, 10, 1 // max. current

    SAP 7, 0, 3, 1 // max. standby current

    //WMC SW_MODE, 0, $0000000F, 1 //0x34: R&L Ref inverted (active low)

    SAP 4, 0, 200000, 1 // Maximum speed

    SAP 5, 0, 500, 1 // Maximum acceleration

    SAP 15, 0, 1000, 1 // Acceleration A1

    SAP 16, 0, 0, 1 // Velocity V1

    SAP 17, 0, 700, 1 // Maximum Deceleration

    SAP 18, 0, 700, 1 // Deceleration D1

    SAP 19, 0, 0, 1 // Velocity VSTART

    SAP 20, 0, 10, 1 // Velocity VSTOP

    SAP 21, 0, 0, 1 // Waiting time after ramp down

    // *** Reference search initialization *** //

    SAP 12, 0, 0, 1 //don't set 'right limit switch disable'

    SAP 13, 0, 0, 1 //don't set 'left limit switch disable'

    SAP 149, 0, 1, 1 //set soft stop flag: 0 = hard stop, 1 = soft stop

    SAP 193, 0, 2, 1 //set reference search mode

    SAP 194, 0, vtarget, 1 //set reference search speed

    SAP 195, 0, 10000, 1 //set reference switch speed

    loop:

    GAP 11, 0, 1 //get Left endstop

    COMP 0 //compare with 0

    JC EQ, turnRight //if equal jump to turn right

    ROL 0, vtarget, 1 //if not equal turn left at vmax

    JA loop //jump to loop

    turnRight:

    ROR 0, vtarget, 1 //turn right at vmax

    JA loop //jump to loop

    you may want to experiment with the register instruction to change active logic:

    // use TMC5160 register addresses

    #include TMC5160_register_addresses.tpc

    WMC SW_MODE, 0, $0000000F, 1 //0x34: R&L Ref inverted (active low)