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.
October 15, 2015 / Jonas P. Proeger / 2