You are here:
Print

TML functions are code sequences stored in the TML program of a drive. They are associated to a name (which is the name of the label corresponding to the function) and an address (the start address of the function, i.e. the address of the label where the function starts).

When a function is called from within the TML program of the drive that it has been defined on, it can be either called using its name or address.

When a function is called from within the TML program of a different drive (not the one that the function has been defined on) or from a master (different device) connected to the drive, it can only be called using its address.

To find the address of a function, one can either:

– check the *.map file corresponding to the application where the function is defined (of course, the TML program must be built and saved before checking the map file)

– interrogate the drive using EasyMotion Studio’s Command Interpreter:

?function_name;

The “function_name” is the name of the function whose address one needs to find. For more details please see the example in the picture below.


Once the address of the function is known, it can be called from any axis/master using the following syntax:

[axis_number] {CALL function_address;}

The “axis_number” represents the Axis ID of the axis where the function is saved. The “function_address” is the address of the function to be called, obtained as presented earlier. For more details please see the example in the picture below.

Remark: The CALL instruction above can be also generated with the “Data Transfer Between Axes” dialog from the Motion branch in EasyMotion Studio (see below).

In case the function needs to be called from an external master the code that the master needs to send to the drive can be obtained using the Binary Code Viewer tool in EasyMotion Studio (Application | Binary Code Viewer) and selecting the appropriate communication protocol.

Remark:

Additionally to the methods presented above, for the iPOS family of drives only, there is another method, that does not require a master device to know the address of a certain function. Using this method, one can call the first 10 defined functions by using the FUNCTION xinstruction, where x is the function number (i.e. the function position within the functions defined in the Functions sub-branch of EasyMotion Studio’s Motion branch.

Example:

FUNCTION 10;

will call the 10th defined function. In case the target drive’s TML program only has 9 functions defined, following the execution of this instruction, the drive will issue an error – MER.14 will be set (Command Error) and also DER.3 will be set (Function not available).

WARNING:

If a TML application has more than 10 functions defined, any function beyond the first 10 defined will have to be called using the standard methods (either using its name or address).

FUNCTION 12;

is an illegal instruction. The compiler will issue an error stating “INVALID OPERAND”.

Next How to save and restore the user variable values