RobotStudio event

Query

Hi everyone,
I am new to thr roboyt studio. I have  robot cutting application to build that should diplay 3 model options on the touchpendent. The user then selects one out of three options and under this Model selected he gets 3 tasks to perform.  The user can choose any one of them. Once that is done, the user press a push button on the machine which would start the robot cutting operation. SO I have tried different wayd to do this task. It would be great if some one could guide me on how can I make the program wait for the start button to be pressed before calling the particular routine.

** but if the user has to perform the same task again he wouldnt have to select the whole model and task again, he just have to press the start button and the same routine that was called previously will be called again.

I could send the program that I have written for the robot and then Some body could give a feedback on it or wat has to be changed.

****I have multitasking on this robot and I planned to run the Main menu as a seperate Task and all the robots routines and actions will be set up in another Task.
I tried to save the name of the model selected in a string variable PERS str strproduct.

I tried to call the same string strproduct in another task but for some reason it says that the str is not unknown in that Task.
How can we declare a variable as global so that it can be called in any other Task in Multitasking.

please let me know the I can send the code to you.

Bharat Suvarna

Comments

  • Hi,

     

    The exmple below should get you started

     

     

    MODULE MainModule
     PERS num ProductCode:=0;
     
    PROC main()
     !
     ! Initialise the productcode
     ProductCode:=0;
     !
     WHILE TRUE DO
      !
      ! Show product selection UI. Usinf DIBreak will abort the menu if the start button is pressed
      ProductCode:=UINumEntry(Header:="Product selection"Message:="Enter the code of the product you want cut"Icon:=IconInfoMinValue:=1MaxValue:=3AsIntegerDIBreak:=diStartCut);
      WaitDI diStartCut,1;
      !
      TEST ProductCode
      CASE 1:
       !
       ! Add code here to cut product 1
       
      CASE 2:
       !
       ! Add code here to cut product 2
       
      CASE 3:
       !
       ! Add code here to cut product 3
       
      DEFAULT:
       UIMsgBox Header:="Code error","Please select a valid code before pressing the start button"Buttons:=btnOKIcon:=iconError;
      ENDTEST
     ENDWHILE
    ENDPROC

    ENDMODULE

    Sharing variables between tasks is done by declaring the variable in each task. The variable must be a PERS. In you're declaration of "PERS str strproduct" "str" is not recognized it should say "string"

     

    Br

    Ron nakken
  • ko414du4
    ko414du4
    edited March 2016
    RonN said:

    The variable must be a PERS.
    Is this always the case? Can I use VAR for variable sharing? I asked this because when I was using instruction WaitSyncTask on multitask & multimove system with 2 robots, the documentation on WaitSyncTask is using VAR declaration for syncident type variables.
  • From the Multitasking manual:
    To share data between tasks, use persistent variables. A persistent variable is global in all tasks where it is declared. The persistent variable must be declared as the same type and size (array dimension) in all tasks. Otherwise a runtime error will occur. It is sufficient to specify an initial value for the persistent variable in one task. If initial values are specified in several tasks, only the initial value of the first module to load will be used.
    Tip When a program is saved, the current value of a persistent variable will be used as initial value in the future. If this is not desired, reset the persistent variable directly after the communication.