TMCL: Reference Search with Wait Timeout
TMCL is the simple way to implement your motion control application. With this series of simple coding examples we want to provide you an easy start.
This program demonstrates how to perform a reference search with motor 0. The program stops either when the reference search is finished or when the timeout limit is reached. In case the timeout limit is reached, the reference search is stopped and the Port OUT_0 is set high before ending the program. In the easiest case connect an LED to Port AIN_0.
Before use: Restore Factory Defaults
// *** Values that have to be adapted *** // amax = 1000 //max. acceleration (0 ... 2047) cmax = 100 //max. current (0 ... 255) vsearch = 1000 //reference search speed (0 ... 2047) vswitch = 100 //reference switch speed (0 ... 2047) searchMode = 1 //reference search mode tmax = 100 //max. time in 10ms for reference search to be finished // *** Initialization / Set up axis parameter *** // SAP 5, 0, amax //set max. acceleration SAP 6, 0, cmax //set max. current SIO 0, 0, 1 //activate pull-up resistors for N.C. switches // *** Reference search initialization *** // SAP 12, 0, 0 //set right limit switch disable SAP 13, 0, 0 //set left limit switch disable SAP 149, 0, 1 //set soft stop flag: 0 = hard stop, 1 = soft stop SAP 193, 0, searchMode //set refenrece search mode SAP 194, 0, vsearch //set reference search speed SAP 195, 0, vswitch //set reference switch speed SIO 0, 2, 0 //switch OUT_0 low // *** Main Program *** // RFS START, 0 //start reference search WAIT RFS, 0, 1000 //wait until RFS is done or timeout happend after tmax * 10ms JC ETO, RefErr //jump to RefErr if timeout occurs STOP //end of Program // *** Timeout subroutine *** // RefErr: CLE 1 //delete Timeout-Flag RFS STOP, 0 //stop reference search SIO 0, 2, 1 //switch OUT_0 high STOP
For more details look at TMCL_reference.pdf at http://www.trinamic.com/software-tools/tmcl-ide
Basic Commands, this sample can be used with any TMCL module with one or multiple axes tested with TMCM-1140, TMCM-1161, TMCM-6110.
September 24, 2015 / Jonas P. Proeger / 5
Categories: Code Snippet, Tutorial
TMCL: Different Microstep Resolutions Trinamic – stealthChop Silent Stepper Motor Driver 3D-Printer Demo
Comments are currently closed.
5 thoughts on “TMCL: Reference Search with Wait Timeout”
Thanks for the sample.
How can I retract more after the reference switch is hit the first time?
I use a gearing of 1:10 and I need more retract to release the end switch before the search aproach.
Thanks for your message.
Before I try to help you, can you tell me what kind of sample you have?
Best reagrds, Lisa
Thanks for your quick reply. Meanwhile we could solve our problem and the drive is working as expected.
Thank you for the sample. I have noticed however that after using this script, I am not able to execute the ROR command. The ROL is working fine. The history log is showing no errors. After powering down/up the module everything goes to normal. I work with a Trinamic module TMCM 6110 v1.1.
I found out to regain control over the motor I need to disable the pull-up resistors and as a precaution stop the motor.
SIO 0, 0, 0 //de-activate pull-up resistors for N.C. switches
MST 0, 0, 0 // stop the motor to prevent damage in case some command are waiting in line