How to vary speed of robot based on an input signal

I would like to set the speed of each move type to a variable that changes according to an analog input 0-10 V.
For example MoveP which is normally
MoveP(p[x,y,z,rx,ry,rz],a,v,r)
and a specific example from a script would be
movep(p[-.476374192653, -.110109454364, .411062508372, 1.778737983435, -.728764202005, -1.755000199148], a=1.2, v=0.25, r=0.0)
How could i change the v=0.25 to a variable that is calculated from the analog input value like
var_1 := analog_in[0]
var_2 := var_1 * 2
v := var_2
The v set as var_2 does not correlate with the v in the movep(), it is simply a different object called v.
Ideally the speed would be calculated every tick (8 ms) and the value will be continually updated during the run of the program.

General info I am using a UR5/CB3 with URSoftware 3.12.1.90940
Any help would be appreciated

Hey,
I believe you are thinking about variable assignment in the wrong way.
What you would need to do is assign v=var_2 inside of the movep command.

So simply do this:

var_1 := analog_in[0]
var_2 := var_1 * 2
movep(p[-.4763, -.1101, .41106, 1.7787, -.72876, -1.755000], a=1.2, v = var_2, r=0.0)

Are you trying to change the robot speed while the robot is still moving to the pose specified in the movep command?
Usually you set the speed once per command and then only change it after the target pose was reached.
If you want to change speeds while the robot is moving you cant do that via the v-parameter in the movep command. You would need to change the override speed via a socket connection to the secondary interface as explained here:

https://www.universal-robots.com/articles/ur/programming/setting-the-speed-slider-inside-program/

Hi robin_gdwl.

Blockquote

Are you trying to change the robot speed while the robot is still moving to the pose specified in the movep command?

Yes this was what I wanted. The set slider speed program is what I used with these changes:

  1. a separate thread that calculates the speed as calculateSpeed(analog_in[0])
  2. adding the sync() command to the main thread
  3. replacing the digital_in[0] in the link with analog_in[0]
  4. setting the speed_high to the calculatedSpeed(analog_in[0])

thank you for the help!