RobotStudio event

How do I send the actual position of an ABB robot via GO's to PLC

Dear,

I want to make a clean function to send the actual position of the robot to the PLC. I want to do this via group outputs. (It is not that impirtant that the values are exact)

I programmed something that works, but I'm sure you can make it cleaner in rapid. Has someone an Idea how I can send the actual position without the detour.

(ABB, IRC5, Robotware 6.13)

Program:

VAR intnum RAX1;

VAR dnum nRAX1;

VAR dnum rRAX1;

VAR dnum sRAX1;


Loop:

ActPosCartTool0:=CRobT(\Tool:=tool0\WObj:=UserFrame0);

ActPosJnt:=CJointT();


RAX1:=ActPosJnt.robax.rax_1;

nRAX1:=NumToDnum(RAX1);

rRAX1:=RoundDnum(nRAX1);

IF rRAX1<0 THEN

sRAX1:=65535+rRax1;

ELSE

sRAX1:=rRax1;

ENDIF

SetGO GO1_CoordJ1,sRAX1;


WaitTime 0.01;

Best Answer

  • Forge_Engineering
    edited October 2022 Answer ✓
    Hi Ruben,

    I don't think you can set up the controller to automatically forward the values on to a PLC.
    You could set up a timed interrupt that updates the values periodically, or use a background task if you have the multitasking option.

    If it's just 'less code' you are seeking you could use fewer lines if you aren't concerned about checking the value at each stage of the process, the example below does the same thing, but I think using if loops is probably quicker and also easier to understand for anyone else that has to read it:

    VAR num n_RAX1;
    VAR dnum dn_RAX1;
    
    GetJointData \MechUnit:=T_ROB1, 1, \position:=n_RAX1;
    dn_RAX1:=RoundDnum(NumToDnum(n_RAX1));
    SetGO GO1_CoordJ1, ((-dn_RAX1/AbsDnum(dn_RAX1)+1)/2)*65535 + dn_RAX1;

    Good Luck,

    Harry