Error Recovery - Unhandled Error
JohnG
✭
I'm having trouble creating an error and having the error handler work with that error. Below is one example of a section of code that basically models a WaitDI instruction but I need it to scan faster than the default .1 second polling. I want to be able to trigger an error if the MaxTime was hit.
Every time I run the code below I get the error "40229, Unhandled error". Any help on what I'm doing wrong or missing here is appreciated!
Every time I run the code below I get the error "40229, Unhandled error". Any help on what I'm doing wrong or missing here is appreciated!
VAR clock TimeClock; VAR errnum ERR_FastWait_MaxTime:=-1; PROC main () BookErrNo ERR_FastWait_MaxTime; FastWaitDi diInspectAcqCmplt, 1, .01 \MaxTime:=.5; ERROR IF ERRNO = ERR_FastWait_MaxTime THEN !do something ENDIF ENDPROC MODULE NewModule (NOSTEPIN) PROC FastWaitDi (VAR signaldi SignalName, num TargetValue, num LoopDelay, \num MaxTime) IF Present(MaxTime) THEN ClkReset TimeClock; ClkStart TimeClock; WHILE SignalName <> TargetValue AND ClkRead(TimeClock) <= MaxTime DO WaitTime LoopDelay; ENDWHILE IF ClkRead(TimeClock) >= MaxTime THEN RAISE ERR_FastWait_MaxTime; ENDIF ELSE WHILE SignalName <> TargetValue DO WaitTime LoopDelay; ENDWHILE ENDIF ENDPROC ENDMODULE
Post edited by JohnG on
Tagged:
0
Comments
-
Change to:
TEST ERRNO
CASE ERR_FastWait_Maxtime:
DEFAULT
Stop;
ENDTEST
When the program stops look at the system variable ERRNO, it will have a value. Match the value up with the predefined errors in the list. This will tell you what the actual error was and you can accommodate for it or figure out what you have wrong.Lee Justice0 -
Thanks for the quick reply. That did help me track it down a bit.
Turns out it was fighting me by having the error handling in the procedure calling the one that raises the error. The code below seemed to have solved it by sending the error backwards in the call stack so to speak:VAR clock TimeClock; VAR errnum ERR_FastWait_MaxTime:=-1; PROC main () BookErrNo ERR_FastWait_MaxTime; FastWaitDi diInspectAcqCmplt, 1, .01 \MaxTime:=.5; ERROR IF ERRNO = ERR_FastWait_MaxTime THEN !do something ENDIF ENDPROC MODULE NewModule (NOSTEPIN) PROC FastWaitDi (VAR signaldi SignalName, num TargetValue, num LoopDelay, \num MaxTime) IF Present(MaxTime) THEN ClkReset TimeClock; ClkStart TimeClock; WHILE SignalName <> TargetValue AND ClkRead(TimeClock) <= MaxTime DO WaitTime LoopDelay; ENDWHILE IF ClkRead(TimeClock) >= MaxTime THEN RAISE ERR_FastWait_MaxTime; ENDIF ELSE WHILE SignalName <> TargetValue DO WaitTime LoopDelay; ENDWHILE ENDIF ERROR IF ERRNO = ERR_FastWait_MaxTime THEN RaiseToUser \BreakOff \ErrorNumber:=ERR_FastWait_MaxTime; ENDIF ENDPROC ENDMODULE
0
Categories
- All Categories
- 5.5K RobotStudio
- 390 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 304 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 3 RobotStudio AR Viewer
- 772 RAPID Programming
- 17 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings