RobotStudio event

Generic calling

Hello everyone, I'm new to RAPID programming and I'm trying to find a way to call different POSES with a generic name.

I have a TEST with several CASES, and for each one I want to call a different POSE to change it's value.

TEST GInputDnum(CodePLC)

case 1:
tpreadnum tpreadnum1," Value";
POSE1.trans.x:= tpreadnum1;

case 2:
tpreadnum tpreadnum1," Value";
POSE1.trans.y:= tpreadnum1;


etc etc

Is there a way to call those poses in a generic way? Something like this:


tpreadnum tpreadnum1," Value";
POSE(CASE).trans.(Coord_selection):= tpreadnum1;

Comments

  • Not sure if this is the function you´re looking for...but maybe you could do something like this:
      
      !Array of your pose
      PERS pose My_pose_Array{20};
      PERS pose New_Pose;
      


      FUNC pose Get_Pose(
        dnum PoseCase
        \num x
        \num y
        \num z
        )
       VAR pose PoseTemp;
       
       PoseTemp:=My_pose_Array{PoseCase};
       !
       IF present(x) PoseTemp.trans.x:=x;
       IF present(y) PoseTemp.trans.x:=y;
       IF present(z) PoseTemp.trans.x:=z;
       !
       RETURN PoseTemp; 
       !
      ENDFUNC
      
      PROC MyProc()
       VAR dnum CodePLC; 
       VAR num tpreadnum1;     
          
       New_Pose:=Get_Pose(CodePLC\x:=tpreadnum1);    
          
      ENDPROC
  • Micky
    Micky ✭✭✭
    edited November 2014

    Hi,

    you can use the instructions GetDataVal and SetDatVal.

     

    Example:

    pers pose pse1:=[[33,0,0],[1,0,0,0]];

    PROC main()

        ChangePose "pse1";

    endproc

    PROC ChangePose(string PoseDataName)

        VAR pose pseTemp;

        VAR num nValue;

        GetDataVal PoseDataName,pseTemp;

        nValue := UINumEntry(\Header:="Value "+PoseDataName\InitValue:=pseTemp.trans.x);

        pseTemp.trans.x :=nValue;

       SetDataVal PoseDataName,pseTemp;

    endproc

     

    /BR

    Micky

     

     

     

  • Thank you both for your answers. 

    I think what I want to do is an union of what you both said but I suppose it might get confusing.

    Name of the Num variable I want to change is defined by the text strings of the items in 4 lists (being the text strings in Item_List4 ([[""," X"],[""," Y"],[""," Z"]];)



    p(Item_List1)(Item_List2)_(Item_List3).trans.(Item_List4):= UIDnumEntry(etc etc);



    Is this possible to do?


    Thank you again for your time and answers


    Regards, 
    MCM

  • McM
    McM
    edited November 2014
    McM said:
    Thank you both for your answers. 

    I think what I want to do is an union of what you both said but I suppose it might get confusing.

    Name of the Num variable I want to change is defined by the text strings of the items in 4 lists (being the text strings in Item_List4 ([[""," X"],[""," Y"],[""," Z"]];)



    p(Item_List1)(Item_List2)_(Item_List3).trans.(Item_List4):= UIDnumEntry(etc etc);



    Is this possible to do?


    Thank you again for your time and answers


    Regards, 
    MCM

    I would look like this:
    Const listitem created for each list

    Const string stringArr created to save the text strings for each list

    Const num NumSel created to save the number selection for each list.


    SetDataVal "p"+StringArr_ItemsInList1{NumSel_List1}+StringArr_ItemsInList2{NumSel_List2}+"_"+StringArr_ItemsInList3{NumSel_List3}+".trans."+StringArr_ItemsInList4{NumSel_List4},tpreadnum1;

    Is this correct?
    Post edited by McM on
  • McM
    McM
    edited November 2014
    Tried it today with an ABB 2400, working properly but I had to change the ".trans."+stringArr_ItemsInList4{NumSel_List4} because it can't understand the whole thing as a Num Variable.

    Instead I used a pose as David L suggested.