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

Qiaotian ITES review: three products shine together to help the production line become flexible

Sony Enterprises in China Jointly Hold the 2024 Earth Hour Activity with WWF

Panoramic customization has been expanded infinitely, and the Ark smart biological sample library scheme has been upgraded completely!

Grasping the general trend of intelligent manufacturing, the annual event of intelligent manufacturing came to a successful conclusion in Beijing

The Road to the Development of Engineering Intelligence (I): China's Rising Power