-
TMCL: Read Analog Value
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 read an analog value and adjust the velocity of motor 0. The velocity depends on the analog value obtained at Port AIN_0. In the easiest case connect a pontiometer 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) // *** Initialization / Set up axis parameter *** // SAP 5, 0, amax //set max. acceleration SAP 6, 0, cmax //set max. current MST 0 //switch to velocity mode // *** Main Loop *** // loop: GIO 0, 1 //get 12 bit analog value of AIN_0 (0 ... 4095) and store in the accumulator CALC DIV, 2 //divide analog value by 2 and store in the accumulator AAP 2, 0 //change the velocity (0 ... 2047) to the value stored in the accumulator JA loop //jump to loop
For more details look at TMCL_reference.pdf at http://www.trinamic.com/software-tools/tmcl-ide
This sample is tested with TMCM-1161 and is compatible with Modules with 12-Bit Analog input. Modules with 10Bit analog input are not compatible.
Related
October 15, 2015 / Jonas P. Proeger / 2
Categories: Code Snippet, Tutorial
Tags: analog input, TMCL
EDN Editor Publishes Extensive Review of our Quiet Stepper Motor Technology Great Presentation on TMC Technologies at Engineering Design Show
Comments are currently closed.
2 thoughts on “TMCL: Read Analog Value”
This was very helpful but is there any way to do a 0-10v = 0-360 degrees or one full rotation??
Hi Jess,
In general this is possible and by adapting the basis of the code you should be able to achieve that. You can read up the TMCL commands with the Firmware manual with the module you are writing the program. You might need a hysteresis as otherwise the motor axis might jitter caused by noise on the analog voltage signal.
If you need further help and / or support please do not hesitate to use our support system. You will find a blue button on our main webpage on the bottom right corner: http://www.trinamic.com
Best regards,
Lars