FUNCTION_BLOCK "Lubrication"
TITLE =Lubrication
//(Generic Library Lubrication Code) The code uses no direct external DB or IO.
AUTHOR : HESS
FAMILY : General
NAME : Lube
VERSION : 1.0
VAR_INPUT
ManualLubeCyclePBInput : BOOL ; //NO Button, One Lube Cycle Request = ON
InCycle : BOOL ; //Memory, Automatic Cycle Running = ON
LubeOverPressurePSInput : BOOL ; //NC Switch, Lubrication Pressure Fault = OFF
LubeLowLevelLSInput : BOOL ; //NC Switch, Lubrication Level Alarm = OFF
LubeCyclePinLSInput : BOOL ; //NO Switch, Lubrication Pin Cycled = ON
PistonSystem : BOOL ; //Memory Selection, Air Piston System = ON
OnDuration : S5TIME := S5T#1S; //Timer Value, Time on per cycle
CycleDuration : S5TIME ; //Timer Value, Time period between cycles in seconds
FaultDuration : S5TIME ; //TImer Value, Time for cycle pin to change states
LubePressFltOnDelayTimer : S5TIME ; //Timer Value, Delay Before Fault = ON
LubeLevelFltOnDelayTimer : S5TIME ; //Timer Value, Delay Before Fault = ON
AcknowledgeFltPBInputNum : BOOL ; //NO Button, Unlatches Faults & Alarms = ON
CycleDurationTimerNumber : TIMER ; //TimerNumber, Auto Cycle Duration
OnDurationTimerNumber : TIMER ; //TimerNumber, Lubrication Duration
PistonOnTimerNumber : TIMER ; //TimerNumber, Piston On Duration
PistonOffTimerNumber : TIMER ; //TimerNumber, Piston Off Duration
FaultDurationTimeNumber : TIMER ; //TimerNumber, Fault Duration
PressDebounceTimerNumber : TIMER ; //TimerNumber, Debounce Pressure Switch
LevelDebounceTimerNumber : TIMER ; //TimerNumber, Debounce Level Switch
END_VAR
VAR_OUTPUT
LubeLowLevelFlt : BOOL ; //Fault, Lube Level Low = ON
LubePressHighFlt : BOOL ; //Fault, Lube High Pressure = ON
LubeCycleTimeOutFlt : BOOL ; //Fault, Lube Cycle Over Time = ON
LubeOutputDevice : BOOL ; //Sol or Motor, Lube Output Device Active = ON
END_VAR
VAR
AutoLubeMemory : BOOL ; //Memory, Start Lube Cycle = ON
PistonCycle : BOOL ; //Memory, Lube Cycle Active = ON
PistonOn : BOOL ; //Memory, Lube Pulse = ON
PistonOff : BOOL ; //Memory, Lube Pulse = OFF
PositiveEdge : BOOL ; //Memory, Positive Edge = ON
NegativeEdge : BOOL ; //Memory, Negitive Edge = ON
END_VAR
BEGIN
NETWORK
TITLE =Incycle Time Monitor
//This timer monitors the time until the next automatic lubrication cycle is
//necessary. When it expires it triggers the lube cycle.
A #InCycle;
L #CycleDuration;
SS #CycleDurationTimerNumber;
NETWORK
TITLE =Auto Lube
//This sets the automatic lubrication cycle.
A #CycleDurationTimerNumber;
= #AutoLubeMemory;
NETWORK
TITLE =Latch Lube
//Sets the lubrication on duration and turns on the output for the lubrication
//device. If the device is an eletric motor, the output is maintained on. If the
//device is a solenoid piston, it is pulsed on and off.
A( ;
A( ;
O #AutoLubeMemory;
O #ManualLubeCyclePBInput;
) ;
L #OnDuration;
SE #OnDurationTimerNumber;
A( ;
A #LubeCyclePinLSInput;
FP #PositiveEdge;
O( ;
A #LubeCyclePinLSInput;
FN #NegativeEdge;
) ;
) ;
R #OnDurationTimerNumber;
NOP 0;
NOP 0;
A #OnDurationTimerNumber;
) ;
AN #LubePressHighFlt;
AN #LubeLowLevelFlt;
= L 0.0;
A L 0.0;
A( ;
O #PistonOn;
ON #PistonSystem;
) ;
= #LubeOutputDevice;
A L 0.0;
BLD 102;
= #PistonCycle;
NETWORK
TITLE =Piston Pulsed On
//Pulses the piston on for three seconds. DO NOT CHANGE THIS TIME!!
A( ;
ON #PistonCycle;
O #PistonOff;
) ;
L S5T#3S;
SF #PistonOnTimerNumber;
NOP 0;
NOP 0;
NOP 0;
A #PistonOnTimerNumber;
= #PistonOn;
NETWORK
TITLE =Piston Pulsed Off
//Pulses the piston off for three seconds. DO NOT CHANGE THIS TIME!!
AN #PistonOn;
L S5T#3S;
SF #PistonOffTimerNumber;
NOP 0;
NOP 0;
NOP 0;
A #PistonOffTimerNumber;
= #PistonOff;
NETWORK
TITLE =Lube Time Out
//If the lubrication cycle pin does not change state by the fault duration then
//indicate a lubrication fault.
O( ;
A #PistonCycle;
AN #AcknowledgeFltPBInputNum;
L #FaultDuration;
SD #FaultDurationTimeNumber;
A( ;
A #LubeCyclePinLSInput;
FP #PositiveEdge;
O( ;
A #LubeCyclePinLSInput;
FN #NegativeEdge;
) ;
O #AcknowledgeFltPBInputNum;
) ;
R #FaultDurationTimeNumber;
NOP 0;
NOP 0;
A #FaultDurationTimeNumber;
) ;
O ;
A #LubeCycleTimeOutFlt;
AN #AcknowledgeFltPBInputNum;
= #LubeCycleTimeOutFlt;
NETWORK
TITLE =Reset Cycle Duration
//Resets the cycle duration at the end of a in cycle duration.
O #CycleDurationTimerNumber;
O #ManualLubeCyclePBInput;
R #CycleDurationTimerNumber;
NETWORK
TITLE =Lube Pressure Fault
//Indicates lubrication pressure fault if debounce timer expires. Then latch on
//fault.
O( ;
AN #LubeOverPressurePSInput;
AN #AcknowledgeFltPBInputNum;
L #LubePressFltOnDelayTimer;
SD #PressDebounceTimerNumber;
A #AcknowledgeFltPBInputNum;
R #PressDebounceTimerNumber;
NOP 0;
NOP 0;
A #PressDebounceTimerNumber;
) ;
O ;
A #LubePressHighFlt;
AN #AcknowledgeFltPBInputNum;
= #LubePressHighFlt;
NETWORK
TITLE =Lube Level Fault
//Indicates lubrication level fault if debounce timer expires. Then latch on
//fault.
O( ;
AN #LubeLowLevelLSInput;
AN #AcknowledgeFltPBInputNum;
L #LubeLevelFltOnDelayTimer;
SD #LevelDebounceTimerNumber;
A #AcknowledgeFltPBInputNum;
R #LevelDebounceTimerNumber;
NOP 0;
NOP 0;
A #LevelDebounceTimerNumber;
) ;
O ;
A #LubeLowLevelFlt;
AN #AcknowledgeFltPBInputNum;
= #LubeLowLevelFlt;
END_FUNCTION_BLOCK