# injCollLadderControls.template # Ladder controls for injector collimator # # Select which 'configuration' to activate # STEP 1 record(mbbo, "$(P):SelectSetpt") { field(DESC, "Select Configuration") field(ZRST, "Extract") field(ONST, "YAG Screen with hole") field(TWST, "YAG Screen") field(THST, "24 mm collimator") field(FRST, "20 mm collimator") field(FVST, "16 mm collimator") field(SXST, "12 mm collimator") field(VAL, "0") field(ZRVL, "0") field(ONVL, "1") field(TWVL, "2") field(THVL, "3") field(FRVL, "4") field(FVVL, "5") field(SXVL, "6") field(OUT, "$(P):Setpt.SELN PP") } # STEP 2: Based on the active configuration, select the motor target position # VAL field for this record contains motor setpoint position record(sel, "$(P):Setpt") { field(DESC, "Select motor setpoint") field(INPA, "$(P):P0:Setpt CP MS") field(INPB, "$(P):P1:Setpt CP MS") field(INPC, "$(P):P2:Setpt CP MS") field(INPD, "$(P):P3:Setpt CP MS") field(INPE, "$(P):P4:Setpt CP MS") field(INPF, "$(P):P5:Setpt CP MS") field(INPG, "$(P):P6:Setpt CP MS") } # Step 3: Based on the active configuration, select the deadband record(sel, "$(P):SetptDeadband") { field(DESC, "Select setpoint deadband") field(NVL, "$(P):SelectSetpt CP") field(INPA, "$(P):P0:Deadband CP MS") field(INPB, "$(P):P1:Deadband CP MS") field(INPC, "$(P):P2:Deadband CP MS") field(INPD, "$(P):P3:Deadband CP MS") field(INPE, "$(P):P4:Deadband CP MS") field(INPF, "$(P):P5:Deadband CP MS") field(INPG, "$(P):P6:Deadband CP MS") } # Apply setpoints to the motor # The motor will start moving record(seq, "$(P):ApplySetpt") { field(DESC, "Apply setpoint to motor") field(DOL1, "1") field(LNK1, "$(P):MOTR.CNEN PP") field(DLY1, "1.0") field(DOL2, "$(P):Setpt") field(LNK2, "$(P):MOTR.VAL PP") field(DLY3, "0.5") field(DOL3, "1") field(LNK3, "$(P):Moving.VAL PP") } # Store if the motor is moving record(bi, "$(P):Moving"){ field(DESC, "Store if motor is moving") field(ONAM, "Moving") field(ZNAM, "Idle") } # Trigger actions when motion is complete record(calcout, "$(P):DmovTrig") { field(DESC, "Trigger of motion complete sequence") field(CALC, "A") field(INPA, "$(P):MOTR.DMOV CP") field(OUT, "$(P):DmovSQ.PROC PP") field(OOPT, "Transition To Non-zero") field(DOPT, "Use OCAL") field(OCAL, "1") } # Disable motor when motion is complete record(seq, "$(P):DmovSQ") { field(DESC, "Motion complete seq") field(DLY1, "1") field(DOL1, "0") field(LNK1, "$(P):MOTR.CNEN PP") field(DLY2, "0.5") field(DOL2, "0") field(LNK2, "$(P):Moving.VAL PP") } # Calculate device error (at most one device can be insterted at the same time) record(bi, "$(P):DeviceError"){ field(DESC, "Device Error") field(ONAM, "Error") field(ZNAM, "No Error") field(OSV, "MAJOR") } # Calculate device error: only one position can be active at a time record(calcout, "$(P):DeviceErrorCalc"){ field(DESC, "Calculate Device Error") field(INPA, "$(P):P0:State CP") field(INPB, "$(P):P1:State CP") field(INPC, "$(P):P2:State CP") field(INPD, "$(P):P3:State CP") field(INPE, "$(P):P4:State CP") field(INPF, "$(P):P5:State CP") field(INPG, "$(P):P6:State CP") field(CALC, "(A+B+C+D+E+F+G)>1?1:0") field(OUT, "$(P):DeviceError PP") } # Check and tell to the user which device is active record(calcout, "$(P):ActiveDeviceCheck"){ field(DESC, "Check which device is active") field(INPA, "$(P):P0:State CP") field(INPB, "$(P):P1:State CP") field(INPC, "$(P):P2:State CP") field(INPD, "$(P):P3:State CP") field(INPE, "$(P):P4:State CP") field(INPF, "$(P):P5:State CP") field(INPG, "$(P):P6:State CP") field(CALC, "A?1:B?2:C?3:D?4:E?5:F?6:G?7:0") field(OUT, "$(P):ActiveDevice PP") } record(mbbi, "$(P):ActiveDevice") { field(DESC, "Display Active Device") field(ZRST, "No device active") field(ONST, "Extracted") field(TWST, "YAG Screen with hole") field(THST, "YAG Screen") field(FRST, "24 mm collimator") field(FVST, "20 mm collimator") field(SXST, "16 mm collimator") field(SVST, "12 mm collimator") field(UNSV, "MAJOR") field(ZRSV, "MINOR") } # Check and tell the user which MPS switch is active record(calcout, "$(P):MPSActiveDeviceCheck"){ field(DESC, "Check which MPS device is active") field(INPA, "$(P):P0_SWITCH CA MS") field(INPB, "$(P):P1_SWITCH CA MS") field(INPC, "$(P):P2_SWITCH CA MS") field(INPD, "$(P):P3_SWITCH CA MS") field(INPE, "$(P):P4_SWITCH CA MS") field(INPF, "$(P):P5_SWITCH CA MS") field(INPG, "$(P):P6_SWITCH CA") field(CALC, "A?1:B?2:C?3:D?4:E?5:F?6:G?7:0") field(OUT, "$(P):MPSActiveDevice PP") } record(mbbi, "$(P):MPSActiveDevice") { field(DESC, "Display MPS Active Device") field(ZRST, "No device active") field(ONST, "Extracted") field(TWST, "YAG Screen with hole") field(THST, "YAG Screen") field(FRST, "24 mm collimator") field(FVST, "20 mm collimator") field(SXST, "16 mm collimator") field(SVST, "12 mm collimator") field(UNSV, "MAJOR") field(ZRSV, "MINOR") } # Check that the active device shown by motion control and MPS are consistent record(calcout, "$(P):ActiveDeviceComp") { field(DESC, "Compare motor and MPS active device") field(INPA, "$(P):ActiveDeviceCheck CP MS") field(INPB, "$(P):MPSActiveDeviceCheck CP MS") field(CALC, "A=B?1:0") field(HIGH, "1") field(LOW, "0") field(HSV, "NO_ALARM") field(LSV, "MAJOR") }