Choose speeddata

Hi,
i'm a mechatronics student and i'm learning robotstudio and rapid programming.
I have a question: i would develop a interface command that allow to choose the speed of the movemente
I have a problem, there are an error when i declare the speeeddata, in particular with the speedata vel_con_pezzo, 
what is the cause? is the variabile  v?
Waiting for a reply,
best regards
Edoardo

 ! DEFINIZIONE VELOCITA'
    PERS num v;
    PERS speeddata vel_avuoto:=[200,200,0,0];
    PERS speeddata vel_conpezzo:=[v,v,0,0];

CONST listitem elenco{3} := [ ["","50"], ["","100"],["","200"] ];
    VAR num list_item;
    VAR btnres button_answer;

PROC selezioneVelocita()        list_item := UIListView (\Result:=button_answer\Header:="Selezione velocita",elenco\Buttons:=btnOKCancel\Icon:=iconInfo\DefaultIndex:=1);            IF button_answer = resOK THEN            IF list_item = 1 THEN                v:=50;            ELSEIF list_item = 2 THEN                v:=100;            ELSEIF list_item = 3 THEN                v:=200;            ENDIF            ELSE                ! User has select Cancel            ENDIF    ENDPROC

Comments

  • DenisFRDenisFR FRANCE ✭✭
    Hello,
    Your PERS variables have to be initialized with a value:
    PERS num v:=0;

  • jeppejeppe world
    edited January 21
    Hi,

    in my understanding you cannot declare data using another data. Instead of trying to declare vel_conpezzo.v_tcp and vel_conpezzo.v_ori using another variable v, you can reassign these values in the program code.

    ! DEFINIZIONE VELOCITA'

    PERS num v;
    PERS speeddata vel_avuoto:=[200,200,0,0];
    PERS speeddata vel_conpezzo:=[0,0,0,0];

    CONST listitem elenco{3}:=[["","50"],["","100"],["","200"]];
    VAR num list_item;
    VAR btnres button_answer;

    PROC selezioneVelocita()
    list_item:=UIListView(\Result:=button_answer\Header:="Selezione velocita",elenco\Buttons:=btnOKCancel\Icon:=iconInfo\DefaultIndex:=1);
    IF button_answer=resOK THEN
    IF list_item=1 THEN
    v:=50;
    ELSEIF list_item=2 THEN
    v:=100;
    ELSEIF list_item=3 THEN
    v:=200;
    ENDIF
    ! reassign two values of vel_conpezzo
    vel_conpezzo.v_tcp:=v;
    vel_conpezzo.v_ori:=v;
    ELSE
    ! User has select Cancel
    ENDIF
    ENDPROC
    hopefully this helps!

    -Jeppe


  • lemster68lemster68 United States ✭✭✭
    Another way for your consideration is to use UINum or TPReadNum to allow the user to input using the numeric keypad.  Also, there is an instruction SpeedRefresh to allo speeding up or slowing down an ongoing movement if you use it with an interrupt.
    Lee Justice
  • AurelienAurelien France
    edorobot said:
    Hi,
    i'm a mechatronics student and i'm learning robotstudio and rapid programming.
    I have a question: i would develop a interface command that allow to choose the speed of the movemente
    I have a problem, there are an error when i declare the speeeddata, in particular with the speedata vel_con_pezzo, 
    what is the cause? is the variabile  v?
    Waiting for a reply,
    best regards
    Edoardo

    You can try this, normaly, it works fine in all case ;)

    Please give feedback !

      ! speed definitions
      PERS speeddata vEmpty:=[200,500,1000,5000];
      PERS speeddata vWithPart:=[0,500,1000,5000];

      CONST listitem lstSpeeds{3}:=[["","50"],["","100"],["","200"]];
      VAR num noChoice;
      VAR bool bOk;
      VAR string strValue;
      VAR btnres button_answer;

      PROC selezioneVelocita()
        ! Show the differetns choices
        ! In this case, likelemster has said, you can use UINumEntry with a respond directly as num
        noChoice:=UIListView(\Result:=button_answer
                             \Header:="Please select a speed"
                             ,lstSpeeds
                             \Buttons:=btnOKCancel
                             \Icon:=iconInfo
                             \DefaultIndex:=1);

        IF button_answer=resOK THEN
          ! Convert the text from list to a value
          ! and store this value inside the v_tcp speed.
          bOk:=StrToVal(lstSpeeds{noChoice}.text,vWithPart.v_tcp);
        ELSE
          ! User has select Cancel 
          ! Default value
          vWithPart:=vEmpty;
        ENDIF
      ENDPROC

    Note : I have translate all data in english
  • edorobotedorobot Milano
    Hi to all,
    thank you very much for the support.

    Now i would try all replies.
    Have a nice day and good work
    Edoardo
Sign In or Register to comment.