RobotStudio event

Looking for a way to simplify the main module for my robot

Hello,

I'm looking for a way to simplify my main module as right now it is very lengthy. For reference, I have over 100 different part programs, and for each new part, I'm having to add a new section to the main module as well as put the routine in our PC.

Here is how we are currently calling part routines: 

                IF Part_Number=3 THEN
                    
                    StartLoad \Dynamic, "pc:" \File:="m_2YD_SLANT_FR_SHT.mod",load3;
                    WaitLoad load3;
                    %"r_2YD_SLANT_FR_SHT"%;
                    Save "m_2YD_SLANT_FR_SHT" \Filepath:="pc:m_2YD_SLANT_FR_SHT.mod";
                    UnLoad "pc:/m_2YD_SLANT_FR_SHT.mod";
                    GOTO Program_Start;
                ENDIF  

It would be important to note that we have an FTP server setup and we are loading modules/routines from a PC and dumping them after the run. 

Also I would like to know if there are any advantages to using TEST/CASE/ENDTEST vs doing an IF/ENDIF.

I know this is a lot, but thanks. Let me know if I need to give any more information. 

Best Answers

  • Tompanhuhu
    Tompanhuhu ✭✭
    Answer ✓
    Create an array with the program name at each index that corresponds to the program number.
    You can make the array longer with more programs.

    MODULE NewModule
        
        PERS string ProgramList{4}:=[
        "2YD_SLANT_FR_SHT",
            "2YD_SLANT_FR_SHT_2",
            "2YD_SLANT_FR_SHT_3",
            "2YD_SLANT_FR_SHT_4"
        ];
        
        FUNC string fGetModuleName()
            RETURN "m_"+ProgramList{Part_Number};
        ENDFUNC
        
        FUNC string fGetModuleNameWithExtension()
            RETURN "m_"+ProgramList{Part_Number}+".mod";
        ENDFUNC
        
        FUNC string fGetRoutineName()
            RETURN "r_"+ProgramList{Part_Number};
        ENDFUNC
        
        PROC main()
            !Add your code here
            StartLoad \Dynamic, "pc:" \File:=fGetModuleNameWithExtension(),load3;
            WaitLoad load3;
            %fGetRoutineName()%;
            Save fGetModuleName() \Filepath:="pc:"+fGetModuleNameWithExtension();
            UnLoad "pc:/"+fGetModuleNameWithExtension();
            GOTO Program_Start;
        ENDPROC
        
    ENDMODULE

    This is just an example, there are many ways of doing this. 
    Systemintegrator - Web / C# / Rapid / Robotstudio

    If I helped, please press Vote Up  :smile:

    ☑️2024 - RobotStudio® User Group
  • lemster68
    lemster68 ✭✭✭
    Answer ✓
    Here is a snippet of how we handled loading and unloading different program modules:

    ! get part program from operator
            itemSelected:=UIListView(\Result:=buttonAnswer,\Header:="Part Selected",partProgram,\Buttons:=btnOKCancel,\Icon:=iconInfo,\DefaultIndex:=1);
    
            IF buttonAnswer=resOK THEN
                IF itemSelected=1 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0044.MOD";
                  currentfile:="FSNA0044.MOD";
                  %"FSNA0044:main"%;
                ELSEIF itemSelected=2 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0048.MOD";
                  currentfile:="FSNA0048.MOD";
                  %"FSNA0048:main"%;
                ELSEIF itemSelected=3 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0051.MOD";
                  currentfile:="FSNA0051.MOD";
                  %"FSNA0051:main"%;
                ELSEIF itemSelected=4 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0114.MOD";
                  currentfile:="FSNA0114.MOD";
                  %"FSNA0114:main"%;
    			      ELSEIF itemSelected=5 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0061.MOD";
                  currentfile:="FSNA0061.MOD";
                  %"FSNA0061:main"%;
                ELSEIF itemSelected=6 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0106.MOD";
                  currentfile:="FSNA0106.MOD";
                  %"FSNA0106:main"%;
                ELSEIF itemSelected=7 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0086.MOD";
                  currentfile:="FSNA0086.MOD";
                  %"FSNA0086:main"%;
                ELSEIF itemSelected=8 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0012.MOD";
                  currentfile:="FSNA0012.MOD";
                  %"FSNA0012:main"%;
                ELSEIF itemSelected=9 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="FSNA0117.MOD";
                  currentfile:="FSNA0117.MOD";
                  %"FSNA0117:main"%;
                ELSEIF itemSelected=10 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="AT0015.MOD";
                  currentfile:="AT0015.MOD";
                  %"AT0015:main"%;
                ELSEIF itemSelected=11 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="AT0016.MOD";
                  currentfile:="AT0016.MOD";
                  %"AT0016:main"%;
                ELSEIF itemSelected=12 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="AT0018.MOD";
                  currentfile:="AT0018.MOD";
                  %"AT0018:main"%;
                ELSEIF itemSelected=13 THEN
                  UnLoad diskhome\File:=currentfile;
                  Load diskhome\File:="AT0045.MOD";
                  currentfile:="AT0045.MOD";
                  %"AT0045:main"%;
                ELSEIF itemSelected=14 THEN
                    GOTO StopCycle;
                ELSE
                    GOTO StopCycle;
                ENDIF
            ELSE
                ! if user selects cancel then stop cycle
                GOTO StopCycle;
            ENDIF</code>CONST listitem partProgram{14}:=[[stEmpty,"FSNA0044 - PCS 1.5 baskets"],[stEmpty,"FSNA0048 - 33K baskets"],
            [stEmpty,"FSNA0051 - GE 7FA Liner"],[stEmpty,"FSNA0114 - GE 7FA Flex Liner"],[stEmpty,"FSNA0061 - GE 9FA Liner"],
            [stEmpty,"FSNA0106 - PCS 2.1 baskets"],[stEmpty,"FSNA0086 - VLM 1.1 baskets"],[stEmpty,"FSNA0012 - 25K baskets"],
            [stEmpty,"FSNA0117 - PCS 1.5 H282 baskets"],[stEmpty,"AT0015 - 33K basket assy respray"],
            ["","AT0016 - 2.1 basket assy respray"],["","AT0018 - Siemens prototype"],["","AT0045 - liner samples"],[stEmpty,"Stop"]];
            PERS string currentfile;</pre><div><br><pre class="CodeBlock"><code>



    Lee Justice
  • mandolas
    mandolas
    Answer ✓
    HI ...
    The vector solution is very good ... my suggestion for Load is that the load instruction is already saved in the program, so when the program loads it already loads the load.
    If this is not possible, I suggest creating a RECORD vector, so you can pass an object that, in addition to the name of the program to be loaded, also contains the LOAD information.

    Good job.

Answers

  • Looks good, thanks! I've also seen that there is an instruction that is just Load instead of Load/WaitLoad. Is there any difference? Also would I need to declare each load (load1, load2, load3, etc.)? That's the way it was setup, so as of now, there are 100+ loads declared at the top of the main module.