RobotStudio event

How do I adjust velocity with program data during program execution?

How I tried to accomplish this:

PERS num vSpraySpeed:=500;
PERS speeddata vSpray_Fast:=[vSpraySpeed,500,5000,1000];

MoveL Spray_pos10, vSpray_Fast, fine, t_spray;

But, this doesn't work.
Is there another way to accomplish this?

Best Answer

Answers

  • It works perfectly! Thank you so much!
  • In case you would like to reduce speed globally (via percentage override) you can use "SpeedRefresh" instruction... Like this:

    ----------------------------------------------------------

    <i>VAR intnum time_int;</i><br><i> </i><p><i>VAR num override;</i></p><i> </i><p><i>...</i></p><i> </i><p><i>PROC main()</i></p><i> </i><div><i> </i><p><i>CONNECT time_int WITH speed_refresh;</i></p><i> </i><p><i>ITimer 0.1, time_int;</i></p><i> </i><p><i>ISleep time_int;</i></p><i> </i><p><i>...</i></p><i> </i><p><i>MoveL p1, v100, fine, tool2;</i></p><i> </i><p><i>! Read current speed override set from FlexPendant</i></p><i> </i><p><i>override := CSpeedOverride (\CTask);</i></p><i> </i><p><i>IWatch time_int;</i></p><i> </i><p><i>MoveL p2, v100, fine, tool2;</i></p><i> </i><p><i>IDelete time_int;</i></p><i> </i><p><i>! Reset to FlexPendant old speed override</i></p><i> </i><p><i>WaitTime 0.5;</i></p><i> </i><p><i>SpeedRefresh override;</i></p><i> </i><p><i>...</i></p></div><i> </i><p><i>TRAP speed_refresh</i></p><i> </i><div><i> </i><p><i>VAR speed_corr;</i></p></div><i> </i><div><i> </i><p><i>! Analog input signal value from sensor, value 0 ... 10</i></p><i> </i><p><i>speed_corr := (ai_sensor * 10);</i></p></div><i> </i><div><i> </i><p><i>SpeedRefresh speed_corr;</i></p><i> </i><p><i>ERROR</i></p><i> </i><div><i> </i><p><i>IF ERRNO = ERR_SPEED_REFRESH_LIM THEN</i></p><i> </i><div><i> </i><p><i>IF speed_corr > 100 speed_corr := 100;</i></p><i> </i><p><i>IF speed_corr < 0 speed_corr := 0;</i></p><i> </i><p><i>RETRY;</i></p></div><i> </i><p><i>ENDIF</i></p></div></div><i> </i><p><i>ENDTRAP</i></p>

    ----------------------------------------------------------

    For speed reducing to the exact value there is probably the best way using LimitSpeed SYS_DI and TRAP routine with SpeedLimCheckPoint instruction. Like this:

    ----------------------------------------------------------

    VAR num limit_speed:=200;

    SpeedLimCheckPoint limit_speed;

    This will limit the speed to 200 mm/s for the TCP robot when system input LimitSpeed is set to 1.

    ----------------------------------------------------------

    BR
  • In case you would like to reduce speed globally (via percentage override) you can use "SpeedRefresh" instruction... Like this:

    ----------------------------------------------------------

    <i>VAR intnum time_int;</i><br><i> </i><p><i>VAR num override;</i></p><i> </i><p><i>...</i></p><i> </i><p><i>PROC main()</i></p><i> </i><div><i> </i><p><i>CONNECT time_int WITH speed_refresh;</i></p><i> </i><p><i>ITimer 0.1, time_int;</i></p><i> </i><p><i>ISleep time_int;</i></p><i> </i><p><i>...</i></p><i> </i><p><i>MoveL p1, v100, fine, tool2;</i></p><i> </i><p><i>! Read current speed override set from FlexPendant</i></p><i> </i><p><i>override := CSpeedOverride (\CTask);</i></p><i> </i><p><i>IWatch time_int;</i></p><i> </i><p><i>MoveL p2, v100, fine, tool2;</i></p><i> </i><p><i>IDelete time_int;</i></p><i> </i><p><i>! Reset to FlexPendant old speed override</i></p><i> </i><p><i>WaitTime 0.5;</i></p><i> </i><p><i>SpeedRefresh override;</i></p><i> </i><p><i>...</i></p></div><i> </i><p><i>TRAP speed_refresh</i></p><i> </i><div><i> </i><p><i>VAR speed_corr;</i></p></div><i> </i><div><i> </i><p><i>! Analog input signal value from sensor, value 0 ... 10</i></p><i> </i><p><i>speed_corr := (ai_sensor * 10);</i></p></div><i> </i><div><i> </i><p><i>SpeedRefresh speed_corr;</i></p><i> </i><p><i>ERROR</i></p><i> </i><div><i> </i><p><i>IF ERRNO = ERR_SPEED_REFRESH_LIM THEN</i></p><i> </i><div><i> </i><p><i>IF speed_corr > 100 speed_corr := 100;</i></p><i> </i><p><i>IF speed_corr < 0 speed_corr := 0;</i></p><i> </i><p><i>RETRY;</i></p></div><i> </i><p><i>ENDIF</i></p></div></div><i> </i><p><i>ENDTRAP</i></p>

    ----------------------------------------------------------

    For speed reducing to the exact value there is probably the best way using LimitSpeed SYS_DI and TRAP routine with SpeedLimCheckPoint instruction. Like this:

    ----------------------------------------------------------

    VAR num limit_speed:=200;

    SpeedLimCheckPoint limit_speed;

    This will limit the speed to 200 mm/s for the TCP robot when system input LimitSpeed is set to 1.

    ----------------------------------------------------------

    BR