Specifications

Applications Ver. 0002 AP - 13
This is an example of how to program a Fagor PLC.
It handles the drive's control signals depending on its status and other variables.
;----- This machine has two axes (X, Z) an a spindle (S)
;----- The Z axis is vertical and it is not compensated. It has a brake controlled by the O20 output.
;----- DRIVE STATUS MANAGEMENT -----
DRSTAF1 = B1R101 ;X axis drive status
DRSTAS1 = B0R101
;
DRSTAF2 = B1R102 ; Z axis drive status
DRSTAS2 = B0R102
;
DRSTAFS = B1R103 ;Spindle drive status
DRSTASS = B0R103
;
CPS R101 GE 1 = M101 ;X axis drive OK
CPS R102 GE 1 = M102 ;Z axis drive OK
CPS R103 GE 1 = M103 ;Spindle drive OK
M101 AND M102 AND M103 = M123 ;All the drives are ready
;the machine can be powered up
;----- MANAGING EMERGENCIES -----
M123 AND I1 ;Emergency inputs
AND (other conditions) = /EMERGEN
/EMERGEN AND /ALARM
AND (other conditions) = O1 ;Emergency output
;----- MANAGING AXES ENABLES -----
CPS R101 GE 2 = M111 ;The X axis has power
CPS R102 GE 2 = M112 ;The Y axis has power
M111 AND M112 = M133 ;All the axis drives OK and with power
M111 AND NOT LOPEN AND O1 ;X axis enable
AND (others) = SERVO1ON = SPENA1 ;Speed Enable for the X axis
= TG3 1 300
T1 = DRENA1 ;Drive Enable with a 300ms delayed deactivation
; for emergency stops.
M112 AND NOT LOPEN AND O1 AND (others) ;Z axis (vertical) enable
= TG3 2 400 = O20 ;Brake controlling signal
T2 = DRENA2 = SERVO2ON = SPENA2 ;Speed and Drive Enable with a 400 ms delayed
; deactivation to prevent axis sag.
;----- MANAGING SPINDLE ENABLES -----
CPS R103 GE 2 = M113 ;The spindle drive has power
M3 OR M4 = SET M140 ;Request for Spindle rotation
M2 OR M5 OR M30 OR RESETOUT OR NOT O1= RES M140 ;Cancel spindle rotation
M19 = SET M119 ;Request for M19
M2 OR M3 OR M4 OR M5 OR M30 OR RESETOUT OR NOT O1 = RES M119 ;Cancel M19
(M140 OR (M119 AND NOT LOPEN)) AND M113 = SPENAS = TG3 3 4000
T3 = DRENAS ;4 sec. delayed deactivation
; for emergency stops.
SPENAS AND (M119 OR RIGID) AND NOT LOPEN = SERVOSON ;M19 or Rigid Tapping, close the loop.
;----- MANAGING FEED HOLD AND STOP -----
M133 AND (others) = /FEEDHOL