How can I make it so a digital input sends the program pointer back to the beginning of Main?
I have code that sort of looks like this:
PROC main()
!pos 0
WaitDI diConveyON,0;
!pos 1
WaitDI diRunButton,1;
IF diA=1 THEN
!do A things
ELSEIF diB=1 THEN
!do B things
ELSEIF diC=1 THEN
!do C things
ENDIF
ENDPROC
!do A things
ELSEIF diB=1 THEN
!do B things
ELSEIF diC=1 THEN
!do C things
ENDIF
ENDPROC
If diConveyON becomes 1 while the PP is in pos 1, I need to go back to pos 0 and wait until it is 0 again. But if it happens anywhere else, it's irrelevant. What's the simplest and safest way to do that? I thought about using interrupts but surely there must be an easier way?
Thanks in advance.
0
Best Answers
-
Read up on system inputs in the system parameter manual. There is a signal exactly for that. You have to map it and assign the StartMain action. The program must not be running, or it will be rejected. Issue Stop system input, the STartMain when program is no longer executing.Lee Justice1
-
If you move the code into a separate routine then you could use something like:PROC Main()
WaitDI di_ConveyOn,0;
RunProcess;
ENDPROCPROC RunProcess()WaitUntil di_RunButton=1 OR di_ConveyOn=1;IF di_ConveyOn=1 THENReturn;ENDIF!the rest of your codeENDPROC1
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings