给你个例子程序: ' Initialisation of variables '----------------------------------------------- GOSUB init_vars
' Initialisation of serial ports '----------------------------------------------- GOSUB init_serial
'Stops all movements and programs '----------------------------------------------- GOSUB stop_all
' Initialisation axis parameters '----------------------------------------------- RUN "STARTUP",3
WAIT UNTIL PROC_STATUS PROC(3)=1 ' Wait until process is stopped WAIT UNTIL PROC_STATUS PROC(3)=0
While(true)
'Wait the start signal While(in(start_0)=0) ' Check for motion error IF MOTION_ERROR or IN(emerg_stop_1) = 0 THEN '... GoSub e_stop ENDIF Wend 'Start the application programs wdog=On wa(100) run "app1",4 run "app2",5
'------------------------------------------ 'Main loop '------------------------------------------ runflag=1 While(runflag=1) ' Check for motion error IF MOTION_ERROR THEN '... GoSub m_error runflag=0 ENDIF
' Check for emergency stop IF IN(emerg_stop_1) = 0 THEN '... GoSub e_stop runflag=0 ENDIF Wend Wend
m_error: ' Stop all movements GOSUB stop_all Return
e_stop: ' Emergency Stop GoSub Stop_all Return
stop_all: 'Stops all programs STOP "app1" STOP "app2" 'Stops all possible moves RAPIDSTOP WA(20) FOR i = 0 TO 2 BASE(i) CANCEL(1) WA(1) CANCEL(1) WA(1) CANCEL WAIT IDLE DATUM(0) 'Reset the possible following error SERVO = OFF NEXT i BASE(0) 'Disable all axis WDOG=OFF RETURN