[r5]: / Tags / Patterns of Ladder Logic Programming / Patterns of Ladderlogic programming.project  Maximize  Restore  History

Download this file

290 lines (222 with data), 164.8 kB

-------------------------------------------------------------------------------
PLC_PRG
-------------------------------------------------------------------------------


PROGRAM PLC_PRG

VAR
    SealedinCoil: FbSealedinCoil;
    xTrigger: BOOL;
    xSealedInCoil: BOOL;
    StateCoilFaultCoil: FbStateCoilFaultCoil;
    xBreakCondition: BOOL;
    xMemoryCoil: BOOL;
    StartStopCircuit: FbStartStopCircuit;
    xStart: BOOL;
    xStop: BOOL;
    SetReset: FbSetReset;
    xRun: BOOL;
    xSet: BOOL;
    ResetSet: FbResetSet;
    xReset: BOOL;
    xQs: BOOL;
    xQr: BOOL;
    Flasher: FbFlasher;
    xFlashingLight: BOOL;
    Debounce: FbDebounce;
    xInput: BOOL;
    xInputDebounced: BOOL;
    ExtendCylinder: fbStep;
    xExtendCylinderCmd: BOOL;
    TONExtendCylinderDone: TON;
    xExtendCylinderDone: BOOL;
    tETExtend: TIME;
    RetractCylinder: fbStep;
    xRetractCylinderCmd: BOOL;
    TONRetractCylinderDone: TON;
    tETRetract: TIME;
    Mission: FbMission;
    xMission1Start: BOOL;
    xMission2Start: BOOL;
    xMission1Done: BOOL;
    xMission2Done: BOOL;
    xNoMission: BOOL;
    xMission1Busy: BOOL;
    xMission2Busy: BOOL;
    FiveRung: fbFiveRung;
    xFromSeqLogic: BOOL;
    xEStopOK: BOOL;
    xAutoMode: BOOL;
    xManMode: BOOL;
    xPushButton: BOOL;
    xSensor: BOOL;
    xResetFault: BOOL;
    xTriggerf: BOOL;
    xSafe: BOOL;
    xCommand: BOOL;
    xInPosition: BOOL;
    xTimeoutFault: BOOL;
    Mode: FbMode;
    xAutoModePB: BOOL;
    xManModePB: BOOL;
    xAutoSelected: BOOL;
    xManualSelected: BOOL;
END_VAR
                                                                                                                                                                                                                                                                                                                                                                                                    
-------------------------------------------------------------------------------
FbStateCoilFaultCoil
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbStateCoilFaultCoil

VAR_INPUT
    xTrigger: BOOL;
    xBreakCondition: BOOL;
END_VAR

VAR_OUTPUT
    xMemoryCoil: BOOL;
END_VAR
                
-------------------------------------------------------------------------------
FbStartStopCircuit
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbStartStopCircuit

VAR_INPUT
    xStart: BOOL;
    xStop: BOOL;
END_VAR

VAR_OUTPUT
    xRun: BOOL;
END_VAR
                
-------------------------------------------------------------------------------
FbSealedinCoil
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbSealedinCoil

VAR_INPUT
    xTrigger: BOOL;
END_VAR

VAR_OUTPUT
    xSealedInCoil: BOOL;
END_VAR
            
-------------------------------------------------------------------------------
FbResetSet
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbResetSet

VAR_INPUT
    xSet: BOOL;
    xReset: BOOL;
END_VAR

VAR_OUTPUT
    xQ: BOOL;
END_VAR
                    
-------------------------------------------------------------------------------
FbSetReset
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbSetReset

VAR_INPUT
    xSet: BOOL;
    xReset: BOOL;
END_VAR

VAR_OUTPUT
    xQ: BOOL;
END_VAR
                    
-------------------------------------------------------------------------------
FbFlasher
-------------------------------------------------------------------------------

                   Use of this pattern is *NOT* recommended 


FUNCTION_BLOCK FbFlasher

VAR
    Timer1: Ton;
    tET1: TIME;
    Timer2: Ton;
    tET2: TIME;
    BLINK: util.BLINK;
    xBlink: BOOL;
END_VAR

VAR_OUTPUT
    xFlashingLight: BOOL;
END_VAR
                                                                        
-------------------------------------------------------------------------------
FbDebounce
-------------------------------------------------------------------------------

                   Due to an increase in the use of solid-state sensors like proximity switches, this pattern will be less likely to be seen 


FUNCTION_BLOCK FbDebounce

VAR_INPUT
    xInput: BOOL;
END_VAR

VAR_OUTPUT
    xDebouncedInput: BOOL;
END_VAR

VAR
    DelayOn: Ton;
    tETon: TIME;
    DelayOff: Ton;
    tEToff: TIME;
END_VAR
                                                        
-------------------------------------------------------------------------------
FbInputMap
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbInputMap

VAR
    xInput: BOOL;
    xA: BOOL;
    xB: BOOL;
END_VAR
                
-------------------------------------------------------------------------------
fbStep
-------------------------------------------------------------------------------


FUNCTION_BLOCK fbStep

VAR_INPUT
    xPreviousStepComplete: BOOL;
    xStepDone: BOOL;
END_VAR

VAR_OUTPUT
    xStepComplete: BOOL;
    xStepInProgress: BOOL;
END_VAR
                            
-------------------------------------------------------------------------------
FbMission
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbMission

VAR_INPUT
    xAutoRunning: BOOL;
    xMission1Start: BOOL;
    xMission1Done: BOOL;
    xMission2Start: BOOL;
    xMission2Done: BOOL;
END_VAR

VAR_OUTPUT
    xNoMission: BOOL;
    xMission1: BOOL;
    xMission2: BOOL;
END_VAR
                                                                
-------------------------------------------------------------------------------
FbFiveRung
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbFiveRung

VAR_INPUT
    xFromSeqLogic: BOOL;
    xEStopOK: BOOL;
    xAutoMode: BOOL;
    xManMode: BOOL;
    xPushButton: BOOL;
    xSensor: BOOL;
    xResetFault: BOOL;
END_VAR

VAR_OUTPUT
    xTrigger: BOOL;
    xSafe: BOOL;
    xCommand: BOOL;
    xInPosition: BOOL;
    xTimeoutFault: BOOL;
END_VAR

VAR
    FaultTimer: TON;
    tETFault: TIME;
END_VAR
                                                                                                
-------------------------------------------------------------------------------
FbMode
-------------------------------------------------------------------------------


FUNCTION_BLOCK FbMode

VAR_INPUT
    xAutoModePB: BOOL;
    xManModePB: BOOL;
END_VAR

VAR_OUTPUT
    xAutoMode: BOOL;
    xManMode: BOOL;
END_VAR