# Choose speeddata

**URL:** <https://tech-community.robotics.abb.com/t/choose-speeddata/9287>\
**Category:** RAPID Programming\
**Created:** [January 21, 2020, 8:33am UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287 "2020-01-21T08:33:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![edorobot](https://avatars.discourse-cdn.com/v4/letter/e/3ec8ea/32.png) [@edorobot](https://tech-community.robotics.abb.com/u/edorobot)\
**Post date:** [January 21, 2020, 8:33am UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287/1 "2020-01-21T08:33:32Z")

</div>

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

```auto

 ! 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

```

---

<div class="post-metadata">

**Author:** ![DenisFR](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DenisFR](https://tech-community.robotics.abb.com/u/DenisFR)\
**Post date:** [January 21, 2020, 12:21pm UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287/2 "2020-01-21T12:21:37Z")

</div>

Hello,  
Your PERS variables have to be initialized with a value:

```auto
PERS num v:=0;

```

---

<div class="post-metadata">

**Author:** ![jeppe](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/jeppe/32/3164_2.png) [@jeppe](https://tech-community.robotics.abb.com/u/jeppe)\
**Post date:** [January 21, 2020, 1:01pm UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287/3 "2020-01-21T13:01:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lemster68](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lemster68/32/1945_2.png) [@lemster68](https://tech-community.robotics.abb.com/u/lemster68)\
**Post date:** [January 21, 2020, 1:45pm UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287/4 "2020-01-21T13:45:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Aurelien](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/aurelien/32/1414_2.png) [@Aurelien](https://tech-community.robotics.abb.com/u/Aurelien)\
**Post date:** [January 21, 2020, 3:11pm UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287/5 "2020-01-21T15:11:26Z")

</div>

> [@edorobot](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![edorobot](https://avatars.discourse-cdn.com/v4/letter/e/3ec8ea/32.png) [@edorobot](https://tech-community.robotics.abb.com/u/edorobot)\
**Post date:** [January 22, 2020, 9:30am UTC](https://tech-community.robotics.abb.com/t/choose-speeddata/9287/6 "2020-01-22T09:30:02Z")

</div>

Hi to all,  
thank you very much for the support.

Now i would try all replies.  
Have a nice day and good work  
Edoardo
