PROGRAM Main
VAR
// M1L0
// Motors
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M1L0_Yup]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M1L0_Yup]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M1L0_Yupdwn]^FB Inputs Channel 1^Position'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS:MMS:YUP
'}
M1 : ST_MotionStage := (fVelocity:=200.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR1L0_YUP'); // M1L0 Yup
fbMotionStage_m1 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M1L0_Ydwn]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M1L0_Ydwn]^STM Status^Status^Digital input 2'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS:MMS:YDWN
'}
M2 : ST_MotionStage := (fVelocity:=200.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR1L0_YDWN'); // M1L0 Ydwn
fbMotionStage_m2 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M1L0_Xup]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M1L0_Xup]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M1L0_Xupdwn]^FB Inputs Channel 1^Position'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS:MMS:XUP
'}
M3 : ST_MotionStage := (fVelocity:=1000.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR1L0_XUP'); // M1L0 Xup
fbMotionStage_m3 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M1L0_Xdwn]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M1L0_Xdwn]^STM Status^Status^Digital input 2'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS:MMS:XDWN
'}
M4 : ST_MotionStage := (fVelocity:=1000.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR1L0_XDWN'); // M1L0 Xdwn
fbMotionStage_m4 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M1L0_PitchCoarse]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M1L0_PitchCoarse]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M1L0_PitchBender]^FB Inputs Channel 1^Position'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS:MMS:PITCH
'}
M5 : ST_MotionStage := (fVelocity:=150.0,nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR1L0_PITCH'); // M1L0 Pitch Stepper
fbMotionStage_m5 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M1L0_Bender]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M1L0_Bender]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M1L0_PitchBender]^FB Inputs Channel 2^Position'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS:MMS:BENDER
'}
M6 : ST_MotionStage := (fVelocity:=150.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR1L0_BENDER'); // M1L0 Bender
fbMotionStage_m6 : FB_MotionStage;
{attribute 'TcLinkTo' := '.fbRunHOMS.bSTOEnable1:=TIIB[EL1004_M1L0_STO]^Channel 1^Input;
.fbRunHOMS.bSTOEnable2:=TIIB[EL1004_M1L0_STO]^Channel 2^Input;
.fbRunHOMS.stYupEnc.Count:=TIIB[EL5042_M1L0_Yupdwn]^FB Inputs Channel 1^Position;
.fbRunHOMS.stYdwnEnc.Count:=TIIB[EL5042_M1L0_Yupdwn]^FB Inputs Channel 2^Position;
.fbRunHOMS.stXupEnc.Count:=TIIB[EL5042_M1L0_Xupdwn]^FB Inputs Channel 1^Position;
.fbRunHOMS.stXdwnEnc.Count:=TIIB[EL5042_M1L0_Xupdwn]^FB Inputs Channel 2^Position'}
{attribute 'pytmc' := '
pv: MR1L0:HOMS
'}
M1L0 : DUT_HOMS;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:STATS
'}
fbMR1L0GantryStats : FB_HomsStats;
// Encoder Arrays/RMS Watch:
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:Y
'}
fbYRMSErrorM1L0 : FB_RMSWatch;
fMaxYRMSErrorM1L0 : LREAL;
fMinYRMSErrorM1L0 : LREAL;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:X
'}
fbXRMSErrorM1L0 : FB_RMSWatch;
fMaxXRMSErrorM1L0 : LREAL;
fMinXRMSErrorM1L0 : LREAL;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:PITCH
'}
fbPitchRMSErrorM1L0 : FB_RMSWatch;
fMaxPitchRMSErrorM1L0 : LREAL;
fMinPitchRMSErrorM1L0 : LREAL;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:BENDER
'}
fbBenderRMSErrorM1L0 : FB_RMSWatch;
fMaxBenderRMSErrorM1L0 : LREAL;
fMinBenderRMSErrorM1L0 : LREAL;
// Pitch Control
//fbM1L0PitchControl : FB_PitchControl;
//bM1L0PitchDone : BOOL;
//bM1L0PitchBusy : BOOL;
// Bender Control
fbBenderM1L0 : FB_Bender;
// Raw Encoder Counts
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:YUP:CNT
field: EGU cnt
io: i
'}
nEncCntYupM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:YDWN:CNT
field: EGU cnt
io: i
'}
nEncCntYdwnM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:XUP:CNT
field: EGU cnt
io: i
'}
nEncCntXupM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:XDWN:CNT
field: EGU cnt
io: i
'}
nEncCntXdwnM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:PITCH:CNT
field: EGU cnt
io: i
'}
nEncCntPitchM1L0 : UDINT;
// Encoder Reference Values
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:YUP:REF
field: EGU cnt
io: i
'}
nEncRefYupM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:YDWN:REF
field: EGU cnt
io: i
'}
nEncRefYdwnM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:XUP:REF
field: EGU cnt
io: i
'}
nEncRefXupM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:XDWN:REF
field: EGU cnt
io: i
'}
nEncRefXdwnM1L0 : UDINT;
{attribute 'pytmc' := '
pv: MR1L0:HOMS:ENC:PITCH:REF
field: EGU cnt
io: i
'}
nEncRefPitchM1L0 : UDINT;
mcReadParameterPitchM1L0 : MC_ReadParameter;
fEncRefPitchM1L0_urad : LREAL; // Current Pitch encoder offset in urad
// M2L0
// Motors
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M2L0_Yup]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M2L0_Yup]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M2L0_Yupdwn]^FB Inputs Channel 1^Position'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS:MMS:YUP
'}
M7 : ST_MotionStage := (fVelocity:=200.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR2L0_YUP'); // M2L0 Yup
fbMotionStage_m7 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M2L0_Ydwn]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M2L0_Ydwn]^STM Status^Status^Digital input 2'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS:MMS:YDWN
'}
M8 : ST_MotionStage := (fVelocity:=200.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR2L0_YDWN'); // M2L0 Ydwn
fbMotionStage_m8 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M2L0_Xup]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M2L0_Xup]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M1L0_Xupdwn]^FB Inputs Channel 1^Position'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS:MMS:XUP
'}
M9 : ST_MotionStage := (fVelocity:=1000.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR2L0_XUP'); // M2L0 Xup
fbMotionStage_m9 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M2L0_Xdwn]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M2L0_Xdwn]^STM Status^Status^Digital input 2'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS:MMS:XDWN
'}
M10 : ST_MotionStage := (fVelocity:=1000.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR2L0_XDWN'); // M2L0 Xdwn
fbMotionStage_m10 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M2L0_PitchCoarse]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M2L0_PitchCoarse]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M2L0_PitchBender]^FB Inputs Channel 1^Position'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS:MMS:PITCH
'}
M11 : ST_MotionStage := (fVelocity:=150.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR2L0_PITCH'); // M2L0 Pitch Stepper
fbMotionStage_m11 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:=TIIB[EL7041-1000_M2L0_Bender]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:=TIIB[EL7041-1000_M2L0_Bender]^STM Status^Status^Digital input 2;
.nRawEncoderULINT:=TIIB[EL5042_M2L0_PitchBender]^FB Inputs Channel 2^Position'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS:MMS:BENDER
'}
M12 : ST_MotionStage := (fVelocity:=150.0, nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE, sName:='MR2L0_BENDER'); // M2L0 Bender
fbMotionStage_m12 : FB_MotionStage;
{attribute 'TcLinkTo' := '.fbRunHOMS.bSTOEnable1:=TIIB[EL1004_M2L0_STO]^Channel 1^Input;
.fbRunHOMS.bSTOEnable2:=TIIB[EL1004_M2L0_STO]^Channel 2^Input;
.fbRunHOMS.stYupEnc.Count:=TIIB[EL5042_M2L0_Yupdwn]^FB Inputs Channel 1^Position;
.fbRunHOMS.stYdwnEnc.Count:=TIIB[EL5042_M2L0_Yupdwn]^FB Inputs Channel 2^Position;
.fbRunHOMS.stXupEnc.Count:=TIIB[EL5042_M2L0_Xupdwn]^FB Inputs Channel 1^Position;
.fbRunHOMS.stXdwnEnc.Count:=TIIB[EL5042_M2L0_Xupdwn]^FB Inputs Channel 2^Position'}
{attribute 'pytmc' := '
pv: MR2L0:HOMS
'}
M2L0 : DUT_HOMS;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:STATS
'}
fbMR2L0GantryStats : FB_HomsStats;
// Encoder Arrays/RMS Watch:
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:Y
'}
fbYRMSErrorM2L0 : FB_RMSWatch;
fMaxYRMSErrorM2L0 : LREAL;
fMinYRMSErrorM2L0 : LREAL;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:X
'}
fbXRMSErrorM2L0 : FB_RMSWatch;
fMaxXRMSErrorM2L0 : LREAL;
fMinXRMSErrorM2L0 : LREAL;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:PITCH
'}
fbPitchRMSErrorM2L0 : FB_RMSWatch;
fMaxPitchRMSErrorM2L0 : LREAL;
fMinPitchRMSErrorM2L0 : LREAL;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:BENDER
'}
fbBenderRMSErrorM2L0 : FB_RMSWatch;
fMaxBenderRMSErrorM2L0 : LREAL;
fMinBenderRMSErrorM2L0 : LREAL;
// Pitch Control
//fbM2L0PitchControl : FB_PitchControl;
//bM2L0PitchDone : BOOL;
//bM2L0PitchBusy : BOOL;
// Bender Control
fbBenderM2L0 : FB_Bender;
// Raw Encoder Counts
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:YUP:CNT
field: EGU cnt
io: i
'}
nEncCntYupM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:YDWN:CNT
field: EGU cnt
io: i
'}
nEncCntYdwnM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:XUP:CNT
field: EGU cnt
io: i
'}
nEncCntXupM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:XDWN:CNT
field: EGU cnt
io: i
'}
nEncCntXdwnM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:PITCH:CNT
field: EGU cnt
io: i
'}
nEncCntPitchM2L0 : UDINT;
// Encoder Reference Values
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:YUP:REF
field: EGU cnt
io: i
'}
nEncRefYupM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:YDWN:REF
field: EGU cnt
io: i
'}
nEncRefYdwnM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:XUP:REF
field: EGU cnt
io: i
'}
nEncRefXupM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:XDWN:REF
field: EGU cnt
io: i
'}
nEncRefXdwnM2L0 : UDINT;
{attribute 'pytmc' := '
pv: MR2L0:HOMS:ENC:PITCH:REF
field: EGU cnt
io: i
'}
nEncRefPitchM2L0 : UDINT;
mcReadParameterPitchM2L0 : MC_ReadParameter;
fEncRefPitchM2L0_urad : LREAL; // Current Pitch encoder offset in urad
//SP1L0:DCCM
// Motors
{attribute 'TcLinkTo' := '.bLimitForwardEnable:= TIIB[EL7047_SP1L0_th1]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:= TIIB[EL7047_SP1L0_th1]^STM Status^Status^Digital input 2;
.nRawEncoderULINT := TIIB[EL5042_SP1L0_th1_th2]^FB Inputs Channel 1^Position;'}
{attribute 'pytmc' := '
pv: SP1L0:DCCM:MMS:TH1
'}
M13 : ST_MotionStage := (nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE); // DCCM th1
fbMotionStage_m13 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:= TIIB[EL7047_SP1L0_th2]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:= TIIB[EL7047_SP1L0_th2]^STM Status^Status^Digital input 2;
.nRawEncoderULINT := TIIB[EL5042_SP1L0_th1_th2]^FB Inputs Channel 2^Position;'}
{attribute 'pytmc' := '
pv: SP1L0:DCCM:MMS:TH2
'}
M14 : ST_MotionStage := (nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE); // DCCM th2
fbMotionStage_m14 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:= TIIB[EL7047_SP1L0_tx]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:= TIIB[EL7047_SP1L0_tx]^STM Status^Status^Digital input 2;
.nRawEncoderULINT := TIIB[EL5042_SP1L0_tx_txd]^FB Inputs Channel 1^Position;'}
{attribute 'pytmc' := '
pv: SP1L0:DCCM:MMS:TX
'}
M15 : ST_MotionStage := (nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE); // DCCM tx
fbMotionStage_m15 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:= TIIB[EL7047_SP1L0_txd]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:= TIIB[EL7047_SP1L0_txd]^STM Status^Status^Digital input 2;
.nRawEncoderULINT := TIIB[EL5042_SP1L0_tx_txd]^FB Inputs Channel 2^Position;'}
{attribute 'pytmc' := '
pv: SP1L0:DCCM:MMS:TXD
'}
M16 : ST_MotionStage := (nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE); // DCCM txd
fbMotionStage_m16 : FB_MotionStage;
{attribute 'TcLinkTo' := '.bLimitForwardEnable:= TIIB[EL7047_SP1L0_tyd]^STM Status^Status^Digital input 1;
.bLimitBackwardEnable:= TIIB[EL7047_SP1L0_tyd]^STM Status^Status^Digital input 2;
.nRawEncoderULINT := TIIB[EL5042_SP1L0_tyd]^FB Inputs Channel 1^Position;'}
{attribute 'pytmc' := '
pv: SP1L0:DCCM:MMS:TYD
'}
M17 : ST_MotionStage := (nEnableMode:=ENUM_StageEnableMode.ALWAYS, bPowerSelf:=TRUE); // DCCM tyd
fbMotionStage_m17 : FB_MotionStage;
//Analog input for Tx Brake Pressure Sensor. Sensor to monitor pressure to verify brakes are released. 90PSI to release brakes.
{attribute 'pytmc' := '
pv: DCCM:MONO:SOL
'}
{attribute 'TcLinkTo' :='TIIB[EL3054_SP1L0_AI]^AI Standard Channel 1^Value'}
nAI AT %I*:UINT;
//digital outputs
//DO for Compressed Air Solenoid Actuation on Tx to release brake. Brakes released when pressure is applied.
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TX:BRAKE
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 1^Output'}
bTx_Brake_Solenoid AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DO1
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 2^Output'}
bDO1 AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DO2
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 3^Output'}
bDO2 AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DO3
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 4^Output'}
bDO3 AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DO4
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 5^Output'}
bDO4 AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DO5
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 6^Output'}
bDO5 AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DO6
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 7^Output'}
bDO6 AT %Q*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:FAN:PWR
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL2008_SP1L0_DO]^Channel 8^Output'}
bFanOn AT %Q*:BOOL;
(* digital inputs, 6x overtravel limits, 1x STO, 1x spare *)
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TH1:POTL
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 1^Input'}
bTH1_POTL AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TH1:NOTL
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 2^Input'}
bTH1_NOTL AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TH2:POTL
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 3^Input'}
bTH2_POTL AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TH2:NOTL
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 4^Input'}
bTH2_NOTL AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TX:POTL
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 5^Input'}
bTX_POTL AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:TX:NOTL
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 6^Input'}
bTX_NOTL AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:STO
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 7^Input'}
bSTO AT %I*:BOOL;
{attribute 'pytmc' := '
pv: SP1L0:DCCM:DI7
field: ZNAM OFF ;
field: ONAM ON ;
'}
{attribute 'TcLinkTo' := 'TIIB[EL1008_SP1L0_STO_DI]^Channel 8^Input'}
bDI7 AT %I*:BOOL;
// Common
fEncLeverArm_mm : LREAL := 513.0;
// Logging
fbLogHandler : FB_LogHandler;
END_VAR
// M1L0
M1L0.fbRunHOMS(stYup:=M1,
stYdwn:=M2,
stXup:=M3,
stXdwn:=M4,
stPitch:=M5,
nYupEncRef:=GVL_M1L0_Constants.nYUP_ENC_REF,
nYdwnEncRef:=GVL_M1L0_Constants.nYDWN_ENC_REF,
nXupEncRef:=GVL_M1L0_Constants.nXUP_ENC_REF,
nXdwnEncRef:=GVL_M1L0_Constants.nXDWN_ENC_REF,
bExecuteCoupleY:=M1L0.bExecuteCoupleY,
bExecuteCoupleX:=M1L0.bExecuteCoupleX,
bExecuteDecoupleY:=M1L0.bExecuteDecoupleY,
bExecuteDecoupleX:=M1L0.bExecuteDecoupleX,
bGantryAlreadyCoupledY=>M1L0.bGantryAlreadyCoupledY,
bGantryAlreadyCoupledX=>M1L0.bGantryAlreadyCoupledX,
nCurrGantryY=>M1L0.nCurrGantryY,
nCurrGantryX=>M1L0.nCurrGantryX);
fbBenderM1L0(stBender:=M6,
bSTOEnable1:=M1L0.fbRunHOMS.bSTOEnable1,
bSTOEnable2:=M1L0.fbRunHOMS.bSTOEnable2);
// No slave motion through Epics
M2.bExecute := FALSE; // M1L0-Ydwn
M4.bExecute := FALSE; // M1L0-Xdwn
// Convert nCurrGantry to um (smaller number) to read out in epics
M1L0.fCurrGantryY_um := LINT_TO_REAL(M1L0.nCurrGantryY) / 1000.0;
M1L0.fCurrGantryX_um := LINT_TO_REAL(M1L0.nCurrGantryX) / 1000.0;
// FB_MotionStage's for non-piezo axes
fbMotionStage_m1(stMotionStage:=M1);
fbMotionStage_m2(stMotionStage:=M2);
fbMotionStage_m3(stMotionStage:=M3);
fbMotionStage_m4(stMotionStage:=M4);
fbMotionStage_m5(stMotionStage:=M5);
fbMotionStage_m6(stMotionStage:=M6);
// Calulate Gantry Stats:
fbMR1L0GantryStats(homs:=M1L0, fbUpStreamY:=M1, fbUpStreamX:=M3);
fbMR2L0GantryStats(homs:=M2L0, fbUpStreamY:=M7, fbUpStreamX:=M9);
// Calculate Pitch RMS Error:
fbYRMSErrorM1L0(stMotionStage:=M1,
fMaxRMSError=>fMaxYRMSErrorM1L0,
fMinRMSError=>fMinYRMSErrorM1L0);
fbXRMSErrorM1L0(stMotionStage:=M3,
fMaxRMSError=>fMaxXRMSErrorM1L0,
fMinRMSError=>fMinXRMSErrorM1L0);
fbPitchRMSErrorM1L0(stMotionStage:=M5,
fMaxRMSError=>fMaxPitchRMSErrorM1L0,
fMinRMSError=>fMinPitchRMSErrorM1L0);
fbBenderRMSErrorM1L0(stMotionStage:=M6,
fMaxRMSError=>fMaxBenderRMSErrorM1L0,
fMinRMSError=>fMinBenderRMSErrorM1L0);
// Pitch Control
//fbM1L0PitchControl(Pitch:=GVL_M1L0.M1L0_Pitch,
//Stepper:=M5,
//lrCurrentSetpoint:=M5.fPosition,
//q_bDone=>bM1L0PitchDone,
//q_bBusy=>bM1L0PitchBusy);
// When STO hit, need to reset SP
//IF NOT M5.bHardwareEnable THEN
//M5.fPosition := M5.stAxisStatus.fActPosition;
//END_IF
// Raw Encoder Counts For Epics
nEncCntYupM1L0 := ULINT_TO_UDINT(M1L0.fbRunHOMS.stYupEnc.Count);
nEncCntYdwnM1L0 := ULINT_TO_UDINT(M1L0.fbRunHOMS.stYdwnEnc.Count);
nEncCntXupM1L0 := ULINT_TO_UDINT(M1L0.fbRunHOMS.stXupEnc.Count);
nEncCntXdwnM1L0 := ULINT_TO_UDINT(M1L0.fbRunHOMS.stXdwnEnc.Count);
nEncCntPitchM1L0 := LINT_TO_UDINT(GVL_M1L0.M1L0_Pitch.diEncCnt);
// Encoder Reference Values For Epics
nEncRefYupM1L0 := ULINT_TO_UDINT(GVL_M1L0_Constants.nYUP_ENC_REF);
nEncRefYdwnM1L0 := ULINT_TO_UDINT(GVL_M1L0_Constants.nYDWN_ENC_REF);
nEncRefXupM1L0 := ULINT_TO_UDINT(GVL_M1L0_Constants.nXUP_ENC_REF);
nEncRefXdwnM1L0 := ULINT_TO_UDINT(GVL_M1L0_Constants.nXDWN_ENC_REF);
mcReadParameterPitchM1L0(Axis:=M5.Axis,
Enable:=TRUE,
ParameterNumber:=MC_AxisParameter.AxisEncoderOffset,
ReadMode:=READMODE_CYCLIC,
Value=>fEncRefPitchM1L0_urad);
nEncRefPitchM1L0 := LREAL_TO_UDINT(ABS(fEncRefPitchM1L0_urad) * fEncLeverArm_mm);
//Coatings States With PMPS
M1.bPowerSelf :=FALSE;
M5.bPowerSelf := FALSE;
// M2L0
M2L0.fbRunHOMS(stYup:=M7,
stYdwn:=M8,
stXup:=M9,
stXdwn:=M10,
stPitch:=M11,
nYupEncRef:=GVL_M2L0_Constants.nYUP_ENC_REF,
nYdwnEncRef:=GVL_M2L0_Constants.nYDWN_ENC_REF,
nXupEncRef:=GVL_M2L0_Constants.nXUP_ENC_REF,
nXdwnEncRef:=GVL_M2L0_Constants.nXDWN_ENC_REF,
bExecuteCoupleY:=M2L0.bExecuteCoupleY,
bExecuteCoupleX:=M2L0.bExecuteCoupleX,
bExecuteDecoupleY:=M2L0.bExecuteDecoupleY,
bExecuteDecoupleX:=M2L0.bExecuteDecoupleX,
bGantryAlreadyCoupledY=>M2L0.bGantryAlreadyCoupledY,
bGantryAlreadyCoupledX=>M2L0.bGantryAlreadyCoupledX,
nCurrGantryY=>M2L0.nCurrGantryY,
nCurrGantryX=>M2L0.nCurrGantryX);
fbBenderM2L0(stBender:=M12,
bSTOEnable1:=M2L0.fbRunHOMS.bSTOEnable1,
bSTOEnable2:=M2L0.fbRunHOMS.bSTOEnable2);
// No slave motion through Epics
M8.bExecute := FALSE; // M2L0-Ydwn
M10.bExecute := FALSE; // M2L0-Xdwn
// Convert nCurrGantry to um (smaller number) to read out in epics
M2L0.fCurrGantryY_um := LINT_TO_REAL(M2L0.nCurrGantryY) / 1000;
M2L0.fCurrGantryX_um := LINT_TO_REAL(M2L0.nCurrGantryX) / 1000;
// FB_MotionStage's for non-piezo axes
fbMotionStage_m7(stMotionStage:=M7);
fbMotionStage_m8(stMotionStage:=M8);
fbMotionStage_m9(stMotionStage:=M9);
fbMotionStage_m10(stMotionStage:=M10);
fbMotionStage_m11(stMotionStage:=M11);
fbMotionStage_m12(stMotionStage:=M12);
// Calculate RMS Error:
fbYRMSErrorM2L0(stMotionStage:=M7,
fMaxRMSError=>fMaxYRMSErrorM2L0,
fMinRMSError=>fMinYRMSErrorM2L0);
fbXRMSErrorM2L0(stMotionStage:=M9,
fMaxRMSError=>fMaxXRMSErrorM2L0,
fMinRMSError=>fMinXRMSErrorM2L0);
fbPitchRMSErrorM2L0(stMotionStage:=M11,
fMaxRMSError=>fMaxPitchRMSErrorM2L0,
fMinRMSError=>fMinPitchRMSErrorM2L0);
fbBenderRMSErrorM2L0(stMotionStage:=M12,
fMaxRMSError=>fMaxBenderRMSErrorM2L0,
fMinRMSError=>fMinBenderRMSErrorM2L0);
// Pitch Control
//fbM2L0PitchControl(Pitch:=GVL_M2L0.M2L0_Pitch,
//Stepper:=M11,
//lrCurrentSetpoint:=M11.fPosition,
//q_bDone=>bM2L0PitchDone,
//q_bBusy=>bM2L0PitchBusy);
// When STO hit, need to reset SP
//IF NOT M11.bHardwareEnable THEN
//M11.fPosition := M11.stAxisStatus.fActPosition;
//END_IF
// Raw Encoder Counts For Epics
nEncCntYupM2L0 := ULINT_TO_UDINT(M2L0.fbRunHOMS.stYupEnc.Count);
nEncCntYdwnM2L0 := ULINT_TO_UDINT(M2L0.fbRunHOMS.stYdwnEnc.Count);
nEncCntXupM2L0 := ULINT_TO_UDINT(M2L0.fbRunHOMS.stXupEnc.Count);
nEncCntXdwnM2L0 := ULINT_TO_UDINT(M2L0.fbRunHOMS.stXdwnEnc.Count);
nEncCntPitchM2L0 := LINT_TO_UDINT(GVL_M2L0.M2L0_Pitch.diEncCnt);
// Encoder Reference Values For Epics
nEncRefYupM2L0 := ULINT_TO_UDINT(GVL_M2L0_Constants.nYUP_ENC_REF);
nEncRefYdwnM2L0 := ULINT_TO_UDINT(GVL_M2L0_Constants.nYDWN_ENC_REF);
nEncRefXupM2L0 := ULINT_TO_UDINT(GVL_M2L0_Constants.nXUP_ENC_REF);
nEncRefXdwnM2L0 := ULINT_TO_UDINT(GVL_M2L0_Constants.nXDWN_ENC_REF);
mcReadParameterPitchM2L0(Axis:=M11.Axis,
Enable:=TRUE,
ParameterNumber:=MC_AxisParameter.AxisEncoderOffset,
ReadMode:=READMODE_CYCLIC,
Value=>fEncRefPitchM2L0_urad);
nEncRefPitchM2L0 := LREAL_TO_UDINT(ABS(fEncRefPitchM2L0_urad) * fEncLeverArm_mm);
//Coatings States With PMPS
M7.bPowerSelf :=FALSE;
//SP1L0
// FB_MotionStage's for non-piezo axes
fbMotionStage_m13(stMotionStage:=M13);
fbMotionStage_m14(stMotionStage:=M14);
fbMotionStage_m15(stMotionStage:=M15);
fbMotionStage_m16(stMotionStage:=M16);
fbMotionStage_m17(stMotionStage:=M17);
M13.bHardwareEnable := bSTO AND bTH1_POTL AND bTH1_NOTL;
M14.bHardwareEnable := bSTO AND bTH2_POTL AND bTH2_NOTL;
M15.bHardwareEnable := bSTO AND bTX_POTL AND bTX_NOTL;
M16.bHardwareEnable := bSTO;
M17.bHardwareEnable := bSTO;
//Turn on Fan by default
bFanOn := TRUE;
P_CoatingProtections();
// Logging
fbLogHandler();
END_PROGRAM