RobotStudio event

ABB Speedrefresh in Background Task

Hi guys. 
i got the problem that im not able to use the command "Speedrefresh" in the BG Task.
i always get the error "The task is not configured to control mechanical units".

Task setup on imgur link;
https://imgur.com/a/LZEe555

MODULE RBG_Velocity

  ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !
  !                                                                                             !
  !            Modul/module:                        RBG_Velocity                                !
  !                                                                                             !
  !            Ersteller/creator:                   3CON-ROB-TEAM-FLEXLINE                      !
  !            Erstellung/creation date:            04.02.2023                                  !
  !            bearbeitet von/ changed by:          3CON-ROB-TEAM-FLEXLINE                      !
  !                                                                                             !
  ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !

  ! > Routine variable's
  VAR num Velocity_ACT;
  VAR num Velocity_NEED:=100;
  ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !

  ! PASSIVE WORK FOR ROBOT IN BACKGROUND
  !----------------------------------------------!

  PROC main()

    ! > Checking the interrupt state
    Velocity;

    ! > Waittime for CPU usage reduction
    WaitTime 0.2;

  ENDPROC

  ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !

  ! SPEEDCHECK FOR ROBOT IN AUTOMODE
  !----------------------------------------------!

  PROC Velocity()

    ! > Setting up the speed if condition is given
  IF (OpMode()=OP_AUTO AND di_0058_3CS_Auto=1 AND do_INT_Autospeed_Free=0) THEN
    Velocity_ACT:=CSpeedOverride();
    IF Velocity_ACT<100 Speedrefresh Velocity_NEED;
  ENDIF
  ENDPROC

  ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !

ENDMODULE


Robotic Software Engineer

Answers

  • Forge_Engineering
    edited February 5
    Hi Braap

    According to the manual, Speedrefresh can only be used in motion tasks that control robot movement.
    You may find your own solution that fits your code structure as I have no idea how it is set up.

    The logic shown in the task here is fairly short and could run in a trap routine in the main task easily. 
    The example code in the manual for speedrefresh shows this:

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

    If you want to have logic in a background task and just do the update in the main task you could set up a PERS speed value that is shared between both tasks and trigger an interrupt in the main task if the value of the PERS speed changes to execute a speedrefresh.

    Good Luck, 

    Harry

  • Hey Harry,
    Thank you for replying. I did a Speedrefresh like u in the past with a trap. But the costumer doesnt want that in the main Task... I'm gonna let you know the solution when im able to get it :D 

    Greets.
    - Chris

    Robotic Software Engineer
  • Hi Braap.

    Unfortunately the Speedrefresh has to be called from the main routine, there is no way to have it in another task.

    You could move a all the speed checking code to a background task and just have the speedrefresh function call in the main task:

    MAIN TASK:
    PERS num DesiredSpeed = 100;
    VAR intnum i_SpeedInterrupt;
    
    PROC Main()
    	CONNECT i_SpeedInterrupt WITH Refresh_Speed;
    	IPers n_DesiredSpeed, i_SpeedInterrupt;
    	
    	! Regular Program Logic 
    	
    	IDelete i_SpeedInterrupt
    ENDPROC
    
    ! Smallest possible trap routine
    TRAP Refresh_Speed
    	speedrefresh n_DesiredSpeed;<br>ENDTRAP

    BACKGROUND TASK:
    PERS num DesiredSpeed;
    
    VAR num Velocity_ACT;
    VAR num Velocity_NEED:=100;
    
    PROC main()
    	! > Checking the interrupt state
    	Velocity;
    	! > Waittime for CPU usage reduction
    	WaitTime 0.2;
    ENDPROC
    
    PROC Velocity()
    	! > Setting up the speed if condition is given
    	IF (OpMode()=OP_AUTO AND di_0058_3CS_Auto=1 AND do_INT_Autospeed_Free=0) THEN
    		Velocity_ACT:=CSpeedOverride();
    		IF Velocity_ACT<100 DesiredSpeed = Velocity_NEED;
    	ENDIF
    ENDPROC

    This way you can keep most logic in a background task and it will only trigger when you actually change the persistent variable. 

    That's about all I can think of, not having trap routines really limits you otherwise.
    If there is a concern about CPU load you can check out the display in RobotStudio under properties -> Device Browser:
    https://imgur.com/a/1QEoUuT
    It might help you monitor the difference at idle.

    Let me know if you find a better way,
    Good Luck, 

    Harry
  • Hey Harry,
    sorry for the late awnser! I found a way to fix it without using a trap routine (finally) ;)

    ABB is giving you an option in the system output's "speed Override". 
    So i am able to speedrefresh the robot in the BG-Task without using the command "speedrefresh".

      ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !
    
      ! VELOCITY CHECK
      !----------------------------------------------!
    
      PROC Velocity_Check()
    
        ! > Routine variable's
        VAR num Curr_Velocity;
    
        ! > Getting actual robotspeed and set it on a variable
        Curr_Velocity:=CSpeedOverride();
    
        ! > Setting actual robotspeed on an integer
        WHILE Curr_Velocity<100 DO
    
          ! > Rounding the current speed so there is no error with decimal value's
          Curr_Velocity:=Round(CSpeedOverride()\Dec:=0);
          IF Curr_Velocity<=100 SetGO go_INT_ACT_Robotspeed,Curr_Velocity;
          
          ! > Setting the error message bit for the PLC
          SetGO go_0161_MSG_Nbr_R1,1;
    
          ! > Waittime for CPU usage reduction
          WaitTime 0.2;
    
        ENDWHILE
    
        ! > Setting the integer to 100 if the override is 100%
        IF Curr_Velocity=100 THEN
          SetGO go_INT_ACT_Robotspeed,Curr_Velocity;
          
          ! > Reseting the error message bit when the override is 100%
          SetGO go_0161_MSG_Nbr_R1,0;
        ENDIF
        
      ENDPROC
    
      ! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - !
    
    ENDMODULE


    Robotic Software Engineer
  • lemster68
    lemster68 ✭✭✭
    It wasn't until today that I understood what you were wanting.  It won't work.  From the rapid manual:

    Speed override set from SpeedRefresh is not equal to setting the speed from the FlexPendant. These are two different values. The product of these two values and the programmed speed will be the speed that is used in the movement.

    But I see now that you are just informing the PLC of the current speed override so that action may be taken.  I have just a little advice.

    IF Curr_Velocity<=100 SetGO go_INT_ACT_Robotspeed,Curr_Velocity;
    since less than or equal is being used, it will always evaluate the IF to be TRUE. No need for the IF, just set the
    GO to the value of the override and be done with it.
    Lee Justice