On Error Handler Sample

The OE or On Error instruction is a subroutine call that is invoked whenever an error occurs during the execution of a program. The subroutine must end with either a RT (Return) if program execution is to continue or an E (End) if program execution is to end. In the following example, if a limit is activated the OE calls label j2 and in the subroutine the limit is identified, error flag set to zero, and program execution continues. If a stall or unidentified error occurs, the error number is printed and program execution is halted.


'CODE         	DESCRIPTION

'Parameter Setup
S1=2,0      	'set input 1 as positive limit, low true
S2=3,0      	'set input 2 as negative limit, low true
Ee=1        	'enable encoder
Sm=0       	'have motor stop on a stall detect

'===================================================
'Program
PG 1        	'enter program mode at address 1
LB su       	'reserved startup label
 OE j2      	'on any error call sub j2
LB aa       	'label aa
 Vm=30000   	'set max velocity to 30000 steps/sec
 MA 102400  	'move positive 102400 steps
            	'close switch at input 1 to
            	'stop motion in the positive direction
            	'and cause an error 83
            	'NOTE: PROGRAM CONTINUES TO EXECUTE
            	'leave switch open and program runs normal
 H          	'hold program execution until motion complete
 H 250      	'hold program execution for 250 millisecond
 MA 0       	'move to absolute 0
            	'close switch at input 2 to
            	'stop motion in the negative direction
            	'and cause an error 84
            	'NOTE: PROGRAM CONTINUES TO EXECUTE
 H          	'hold program execution until motion complete
 H 250      	'hold program execution for 250 millisecond
 BR aa      	'branch to label aa
E           	'end program
'========================================================
'On_Error Handler Subroutine
LB j2
PR "Error " Er 	'print the error
BR se, Er=86   	'if a stall jump to se
BR lp, Er=83   	'jump if limit plus to lp
BR Ln, Er=84   	'jump if limit minus to ln

LB ue          	'end program if error unknown
 PR "Undefined Error"
 PR "Ending Program!"
 E

LB Ln         	'limit minus - return to main pgm
 PR "Limit Minus"
 Er=0         	'clear the error flag
 RT

LB lp         	'limit plus - return to main pgm
 PR "Limit Plus"
 Er=0
 RT           	'clear the error flag

LB se         	'stall detected - end pgm
 PR "Stall"
 PR "Ending Program!"
 E

PG      		'exit program mode

'hit "Esc" key to stop program

IMS Logo Wide

370 N. Main St., P.O. Box 457
Marlborough, CT 06447 U.S.A.
Phone: 860 / 295-6102
Fax: 860 / 295-6107
Email: info@imshome.com

Contact

TECHNICAL SUPPORT (U.S.A.)
Phone: 860 / 295-6102
Fax: 860 / 295-6107
E-mail: etech@imshome.com

IMS ASIA PACIFIC OFFICE
30 Raffles Pl., 23-00 Chevron House
Singapore 048622
Phone: +65 / 6233 / 6846
Fax: +65 / 6233 / 5044
E-mail: wllee@imshome.com

IMS EUROPEAN SALES MGT.
4 Quai Des Etroits
69005 Lyon, France
Phone: +33 / 4 7256 5113
Fax: +33 / 4 7838 1537
E-mail: bmartinez@imshome.com

IMS UK Ltd
.
25 Barnes Wallis Road
Segensworth East
Fareham, Hampshire, UK  PO15 5TT
Phone: +44 / 0 1489-889825
Fax:: +44 / 0 1489-889857
E-mail: mcheckley@imshome.com

U.S.A. SALES OFFICES
Eastern Region 

Phone: 973 / 661-1270
Fax: 973 / 661-1275
E-mail: jroake@imshome.com

Central Region
Phone: 260 / 402-6016
Fax: 419 / 858-0375
E-mail: dwaksman@imshome.com

Western Region
Phone: 602 / 578-7201
E-mail: dweisenberger@imshome.com