RobotStudio event

Weekly Backup with Recovery in RAPID/Wöchentliches Backup mit Nachholung in RAPID

Hi everyone,

I’m trying to create a RAPID program that triggers an automatic backup on my ABB robot every Tuesday. If the robot is powered off on that day, the backup should be executed as soon as it’s powered back on.

Any suggestions on how to best implement this in RAPID?

Thanks in advance!

Cheers

locorococ

Best Answer

  • revans
    revans
    Answer ✓
    Below is some code I have used in the past. I get the time from the system in second. This needs to run in the background task. You will need to setup a system input on the robot as a backup signal. It should be noted there is a more proper way to do this where it is backed up to a computer instead, but I am less familiar with that part of the program and prefer for my backups to be on a USB with the robot. Look at the system parameters manual for information on the system inputs... One more note I say system input but am using an output. You will either need to do a cross connection from a digital output to a digital input to get this to work, or... you can create an input, set up the system input, then switch the signal to a digital output and it will let you use digital outputs as a system input that way. I have no idea if this will be patched out, I pray not because I have been using it for 7 years.

    PERS dnum Lasttimetaken:=10;

    FUNC dnum System_Time() !This caculates the system time in seconds VAR bool Check; VAR dnum math{3}; VAR dnum time; VAR string date; date:=Cdate(); !Parcing the string from the cdate command into year,month, and day respectively Check:=StrtoVal(StrPart(date,1,4),math{1}); Check:=StrtoVal(StrPart(date,6,2),math{2}); Check:=StrtoVal(StrPart(date,9,2),math{3}); !taking the time provided by the date, and adding the hour, minutes, and seconds to get system time time:=(math{1}-1970)*31536000+math{2}*2592000+math{3}*86400+NumtoDnum(GetTime(\Hour)*3600+GetTime(\min)*60+GetTime(\Sec)); RETURN time; ERROR RETURN Last_Time_Ran;
    ENDFUNC PROC AutoBackup() VAR num weekday; weekday:= GetTime(\WDay); IF weekday=2 OR (Lasttimetaken+ SecInWeek)<System_Time()  THEN            Set robotbackup; Lasttimetaken:=System_Time(); ELSEIF weekday<>2 THEN Reset robotbackup; ENDIF         ENDPROC

Answers

  • revans said:
    Below is some code I have used in the past. I get the time from the system in second. This needs to run in the background task. You will need to setup a system input on the robot as a backup signal. It should be noted there is a more proper way to do this where it is backed up to a computer instead, but I am less familiar with that part of the program and prefer for my backups to be on a USB with the robot. Look at the system parameters manual for information on the system inputs... One more note I say system input but am using an output. You will either need to do a cross connection from a digital output to a digital input to get this to work, or... you can create an input, set up the system input, then switch the signal to a digital output and it will let you use digital outputs as a system input that way. I have no idea if this will be patched out, I pray not because I have been using it for 7 years.

    PERS dnum Lasttimetaken:=10;


    FUNC dnum System_Time()
    !This caculates the system time in seconds
    VAR bool Check;
    VAR dnum math{3};
    VAR dnum time;
    VAR string date;
    date:=Cdate();
    !Parcing the string from the cdate command into year,month, and day respectively
    Check:=StrtoVal(StrPart(date,1,4),math{1});
    Check:=StrtoVal(StrPart(date,6,2),math{2});
    Check:=StrtoVal(StrPart(date,9,2),math{3});
    !taking the time provided by the date, and adding the hour, minutes, and seconds to get system time
    time:=(math{1}-1970)*31536000+math{2}*2592000+math{3}*86400+NumtoDnum(GetTime(\Hour)*3600+GetTime(\min)*60+GetTime(\Sec));
    RETURN time;
    ERROR
    RETURN Last_Time_Ran;

    ENDFUNC
    PROC AutoBackup()
    VAR num weekday;
    weekday:= GetTime(\WDay);
    IF weekday=2 OR (Lasttimetaken+ SecInWeek)<System_Time()  THEN
                Set robotbackup;
    Lasttimetaken:=System_Time();
    ELSEIF weekday<>2 THEN
    Reset robotbackup;
    ENDIF
            
    ENDPROC
    Thank you very much, i am very new to this whole RAPID stuff but i try my best. I need to learn all those commands you used first because i want to understand it and not just  "ctrl + c and ctrl +v" it :)
  • locrococ
    locrococ
    edited September 13
    @revans
    i almost understand everything, everything makes sense to me after looking and working with your programm for couple of days. But those three lines, i dont know what happens there, could you please explain it to me? I am talking about: 

    PERS dnum Lasttimetaken:=10;


    RETURN time;
    ERROR
    RETURN Last_Time_Ran;

    What are you doing here? i dont get it. 

    Thanks again very much
    Post edited by locrococ on
  • revans
    revans
    edited September 13
    There is a bit of a mistake in that code. Where you see Last_Time_Ran, that was meant to be Lasttimetaken. I typed this up a little too quick I guess. That variable represents the last time a backup was taken. This acts as a check to see if the backup was already taken this week. 

    I often run this code in my very sensitive background task that sends the robot into sys failure if the code stops. For that reason, all of my not critical things like backups have a error recovery that at least returns a value that won't cause issues. So the return time makes it so the function returns the calculated value, but if the calculations run into an error caused by the string parsing or the robot time has not been setup, this would prevent my background task from crashing.

    It will be a few more days, but I will try to make a video covering how I would do this and link it here.
  • @revans
    Thank you for your explanation. I will discuss it with my team, and once we have integrated it into our robots, I will provide you with a quick update :)
  • revans said:
    There is a bit of a mistake in that code. Where you see Last_Time_Ran, that was meant to be Lasttimetaken. I typed this up a little too quick I guess. That variable represents the last time a backup was taken. This acts as a check to see if the backup was already taken this week. 

    I often run this code in my very sensitive background task that sends the robot into sys failure if the code stops. For that reason, all of my not critical things like backups have a error recovery that at least returns a value that won't cause issues. So the return time makes it so the function returns the calculated value, but if the calculations run into an error caused by the string parsing or the robot time has not been setup, this would prevent my background task from crashing.

    It will be a few more days, but I will try to make a video covering how I would do this and link it here.
    Hey @revans
    I am currently facing the issue of trying to deploy the AutoBackup to all of our robots, and it works for most of them. However, we also have robots with Robware version 05.xx.xx in our facility, and for those, RobotStudio keeps giving me the following error message: "2600-101012/RAPID/T_ROB1/AutoBackup(41,12): Type error (56): Type signaldo for the left operand of the operator "=" or "<>" is not of type "value" or "semi-value"." This issue does not occur with newer versions. What do I need to do differently to make it work? Do you or anyone else have any ideas?
  • Hey @locrococ

    Sorry for the delayed response, I am on a different brand for a bit, so I don't check back as often.

    If I remember correctly, the robotware 5 robots do not do an automatic type conversion from signals to numbers like it does in robotware 6. To make that work, you can use the function DOutput("Signal here") and that should convert it so it does the comparison.

    That is mostly a guess without seeing your code right now. I don't see anywhere in the code I have that is doing a comparison to a signal. Good luck.

  • revans said:
    Hey @locrococ

    Sorry for the delayed response, I am on a different brand for a bit, so I don't check back as often.

    If I remember correctly, the robotware 5 robots do not do an automatic type conversion from signals to numbers like it does in robotware 6. To make that work, you can use the function DOutput("Signal here") and that should convert it so it does the comparison.

    That is mostly a guess without seeing your code right now. I don't see anywhere in the code I have that is doing a comparison to a signal. Good luck.

    Thanks, it worked