Specifications

Examples and tips
PROGRAMMING MANUAL 272
Revision 5.0
'Evaluates rising edge in RUN, STOP & RESET bits
GOSUB sequence
'Checks for alarms in the system and monitors the
'system status
GOSUB alarm_sequence
'Upgrade values for showing in the HMI & PLC
GOSUB monitoring
'Reports and reset warnings in servodrive
GOSUB warning_seq
GOTO loop
'--------------------------------------------------------
sequence:
'Define here your signals to STOP/START/RESET
'This example uses the following signals:
'Rising edge of bit 0 of VR(signal_state) as RUN signal
'Rising edge of bit 1 of VR(signal_state) as STOP signal
'Rising edge of bit 2 of VR(signal_state) as RESET signal
'RUN
run_ant=run_act
run_act=READ_BIT(0,signal_state)
run_bit=run_act AND NOT run_ant
'STOP
stop_ant=stop_act
stop_act=READ_BIT(1,signal_state)
stop_bit=stop_act AND NOT stop_ant
'RESET
res_ant=res_act
res_act=READ_BIT(2,signal_state)
res_bit=res_act AND NOT res_ant
RETURN
'--------------------------------------------------------
alarm_sequence:
'Alarm notification
IF SYSTEM_ERROR=0 AND MOTION_ERROR=0 AND READ_BIT(15,diag01)=1
THEN
alarm_bit=0
ELSE
IF MOTION_ERROR<>0 THEN
SET_BIT(0,status_bits) 'Motion error flag
first_error=ERROR_AXIS
ENDIF
alarm_bit=1
ENDIF
'MECHATROLINK axis alarm monitoring
FOR i=0 TO max_axis
BASE(i)
VR(servo_status+i*2)=AXISSTATUS
'if stopped by alarm, notify the alarm code
IF ATYPE>=40 AND ATYPE<=42 THEN
IF status_word=2 THEN
'if no response, notify "communication alarm"
IF (AXISSTATUS AND 4)<>0 THEN
VR(servo_alarm+i*2)=$E6
ELSEIF NOT DRIVE_ALARM(servo_alarm+i*2) THEN
VR(servo_alarm+i*2)=$E6
ELSEIF VR(servo_alarm+i*2)=0 THEN
VR(servo_alarm+i*2)=$bb
ENDIF