Skip to main content

Kollmorgen Support Network

Macro Language Motion | 27 Jan 2012 | |

Macro Language Motion

Valid for S300, S700

Motion Tasks in EEPROM or RAM

To handle motion tasks in a PLC program it is possible to use the commands XWRITE and COMMAND that access to ASCII variables:

Example:
COMMAND('ORDER 192 49000 2800 8192 50 50 0 0 0 0');
Creates a motion task number 192 with target position 49000, commanded speed 2800, motion task type "absolute", acceleration and deceleration ramp 50 ms, no following motion task.
It is also possible to change single values of a motion task stored in RAM:
COMMAND ('MTMUX 195'); // Set pointer to motion task 195
XWRITE ('O_P', TEMPVAR); // Write value of variable TEMPVAR
 
These two lines will change the position of motion task no. 195 to the value of the variable TEMPVAR.

Motion Task No. 0

The ASCII commands
O_P
O_V
O_C
O_ACC1
O_ACC2
O_DEC1
O_DEC2
O_FT
O_FN
have corresponding macro variables with the same names as the ASCII commands.
These commands write directly into motion task no. 0 without calling the ASCII command XWRITE.
 
Example:
The lines
O_P := 35000;
O_V := 50000;
 
set the position of motion task no. 0 to the value of 35000, the speed to the value of 50000.

Starting a Motion Task

A motion task can be started using the following lines:
MOVEP_NR:=0;   // Set motion task number
SETPTR(TRJ,G_STARTMOVE);   // Start motion task

Starting a Jog Move (in OPMODE 8)

VJOGIO:=MYJOGSPEED; // Set jog speed
SETPTR(TRJ,G_MOVEJOGIO); //Start moving
 

Starting a Reference Move

SETPTR(TRJ,G_MOVEREF);     // reference speed VREF is used

Stop Motion

SETPTR(TRJ,G_STOPMOVE);

Change OPMODE

NOPMODE:=TEMPVAR1; //set new OPMODE 
FUNCTION(CALCOPMODE); //do some internal adjustments

Camming Functions

Up to 8 profiles can be stored in the drive's memory. All profiles together can have up to 8000 points.Table numbers start with 0.
The system variables LTABL0,...LTABL7 represent the lengths of the tables.

If a cam table shall be followed based on an external master like an encoder, the parameter EXTPOS should be set to negative value according to the encoder. The camming can then be based upon the variable PFB0. Camming is done in OPMODE 5 with the position coming from the table being written to the macro NEWPOS.

The following functions can be used:

FUNCTION4(GETTAB,TABVAL,TABNR,INDEX,TABREST);

This function gets a value from a table and also does a (linear) interpolation between two values. All variables must be defined as LONG variables. 

Parameter
 Meaning of the parameters
FUNCTION4
Calls a function with 4 variables of type LONG.
GETTAB
Name of the function
TABVAL
Result of the function.
TABNR
Number of the table
INDEX
Pointer for the table. Value from table position INDEX is taken.
TABREST
Rest, used for interpolation between table values. Format 0...1023

The value of TABVAL is calculated as follows:

TABVAL:=TABLE{TABNR}{INDEX} + ((TABLE{TABNR}{INDEX+1}-TABLE{TABNR}{INDEX})*TABREST)>>10;

FUNCTION5(GEARALL,POSOUT,TABVAL,MYGEARI,MYGEARO,MYREST);

This function eine multiplies and devides and and takes care of the division remainder.
Application: Gearing functions.
All variables must be defined as LONG variables.

Parameter
 Meaning of the parameters
FUNCTION5
Calls a function with 5 variables of type LONG
GEARALL
Name of the function
POSOUT
Result of the function
TABVAL
Input to the function
MYGEARI
Gearing factor demoninator
MYGEARO
Gearing factor numerator
MYREST
Rest, not to be changed by user program

The function does the following calculations:

TEMP = TABVAL*MYGEARO+MYREST; POSOUT = TEMP/MYGEARI; MYREST = TEMP%MYGEARI; (% means Modulo operation)

Drifting of the axis because of incremental division faults (remainder) is ommitted, because MYREST is always considered.

Back to top

About this Article

Kollmorgen Support