Home page of industrial control network
>

Application design

>

ABB Programming Tips - Creating Custom Functions

ABB Programming Tips - Creating Custom Functions

In ABB robot Many built-in functions are used in programming, such as clkRead, NumToStr, Crobt, etc. You can also create user-defined functions according to your own needs.

The following describes how to create a user-defined function:

The function must be terminated by the return instruction. The data type returned by return must be consistent with the data type of the function.

Functions must be called through expressions, such as assignment instructions, which cannot be completed through ProcCall. When calling a Function with parameters, the mandatory parameters must be specified and the order of the parameters must be correct; Optional parameters can be defaulted.

Example (user-defined function: please distance between two points):

FUNC Num n_Distance(robtarget pStart,robtarget pEnd)

VAR num Dx;

VAR num Dy;

VAR num Dz;

VAR num Dtemp;

Dx:=pStart.trans.x-pEnd.trans.x;

Dy:=pStart.trans.y-pEnd.trans.y;

Dz:=pStart.trans.z-pEnd.trans.z;

Dtemp:=Pow(Dx,2)+Pow(Dy,2)+Pow(Dz,2);

RETURN Sqrt(Dtemp);

ENDFUNC

Note: Pow (used to calculate the index value in any base); Sqrt (used to calculate the square root value)

Application example:

PROC main()

MoveJ p100, v100, fine, MyTool;

MoveJ p110, v100, fine, MyTool;

v_Distance := n_Distance(p100,p110);

TPWrite "v_distance="\Num:=v_Distance;

Stop;

ENDPROC

The teaching pendant displays as follows:

The distance between points p100 and p110 is 629.75mm

 1.png

Please check the video number for specific steps to create a custom function.

Audit Edit(
Wang Jing
)
Complaints and suggestions

Submit

See more comments
Other information

See more

Pioneer Network was rated as a leader in XDR field by Forrester

Exhibition | Lubeworks Lubeworks Fluid Supply System Makes a Wonderful Appearance at AMTS Exhibition

China Unicom's first quantum communication product "Quantum Secret Message" appeared!

National major equipment enterprises gather at the first China Science and Technology Exhibition held in Shenzhen in November

Dongtu made a wonderful appearance at the South China Industrial Expo, demonstrating the future industrial frontier technology