![background image](http://html1.mh-extra.com/html/omron/r88a-mcw151-drt-e/r88a-mcw151-drt-e_operation-manual_742243262.webp)
247
Programming Examples
Appendix C
'...
'Init I/O naming
resetting = 5
start_machine = 6
e_stop = 7
pos_torque = 16
startup_flag = 18
servo_alarm_bit = 24
rdy = 28
'...
RETURN
'Serial ports initialisation
'------------------------------
init_serial:
' Port 1
'------------------------------
baud_rate = 9600
data_bits = 7
stop_bits = 2
parity = 2 ' Even parity
option = 6 ' Host Link Master
SETCOM(baud_rate,data_bits,stop_bits,parity,1,option)
' Port 2 (MCW151-E only)
'------------------------------
baud_rate = 9600
data_bits = 7
stop_bits = 2
parity = 2 ' Even parity
option = 5 ' Host Link Slave
SETCOM(baud_rate,data_bits,stop_bits,parity,2,option)
' Host Link Slave settings
'------------------------------
HLS_NODE = 3
HLS_MODEL = $FE
' Host Link Master settings
'------------------------------
HLM_TIMEOUT = 1000
RETURN
'Motion stop and initialisation
'-------------------------------
stop_all:
'We store in those variable the cause of the error, if any, for diagnostics
BASE(0)
VR(alarm_mcw151)=AXISSTATUS
VR(alarm_servodriver)=DRV_STATUS
'Stops all programs
STOP "application"
'...
'Stops all possible moves
RAPIDSTOP
WA(200)
FOR i = 0 TO 2
BASE(i)
CANCEL(1)
CANCEL
WA(1)
CANCEL(1)
WAIT IDLE
SERVO = OFF
NEXT i
BASE(0)
'Disable the axis
WDOG = OFF
'Reset the possible following error
DATUM(0)