Trio控制器是非常底层编程的一种控制器,对于硬件中断这种功能,完全可以用自己编写程序的方式实现。建议你去Trio的中文网站看一下,那里有很多例子及各个用户提出的问题 www.triomotion.net
下面的这个例子,希望你能看懂:
'####################################################################
' 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
init_vars:
start_0=0
grindsignal_3=3
work_14=14
alarm_15=15
currentnum_108=108
clear_108=108
countflag=0
Return
init_serial:
setcom(38400,8,1,2,1,4)
Return