Timer in FB

JOLTRON

Lifetime Supporting Member
Join Date
Aug 2006
Location
MI
Posts
692
I'm sorry for a basic questions but couldn't find the answer while searching this forum or googling.

I was given an FB that I was told worked. It used timers that are declared in the interface as "IN"s.
TimerNumber - T30 as Timer
TimerDuration - S5T#10S as S5Time

To me this will not work since the duration would have to be an IN/OUT.

When I monitor the above FB or instance DB the values do not increment.

I have the block working using the ideas in this thread:
http://www.plctalk.com/qanda/showthread.php?p=324987#post324987
Although I converted the idea to ladder.
Now I'm just looking to clarify a few things.

Can anyone confirm that timers will not work when they are inputs to FB's?

Also if I take the Duration that I want and move it to the IN/OUT of the interface and set it to S5TIME the FB will then not accept S5T#10S as in input. It just shows up in red.

InOut S5 Time Declare.png InOut S5 Time.png
 
Sorry about that, I figured the entire FB was a little over kill for my question.

Code:
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
 
If you want to monitor the timer you must assign a parameter to the timer outputs and you can monitor that output. For quickness I have used a temp. You could use a STAT and then be able to monitor the instance DB.

As you can see the Low Level fault timer does in fact operate correctly.

pap4.jpg
 
Thanks for the reply. I did alot of reading and it seemed like everywhere I read it said timer values had to be in/outs.

I now see what the problem is in this program.

The timer I was concerned about was the (SS) timer on network 1. That is reset on network 7. The timer seems to trigger once, since the timer never sees another raising edge it doesn't start again.

Thanks for the help.

I'm going to look into this a bit more.

Timer.png
 

Similar Topics

I have some logic that I have written within a 5380 series controller that tracks the time an event is started, while the event is running an RTO...
Replies
2
Views
89
Hi all, I have a simple question that I have overcomplicated and gotten stuck on. I have a variable, we can call it "light" that I need to stay...
Replies
4
Views
308
Question to anyone with ideas about my thoughts on upgrading a very vintage timer, which is being used to switch between 2 5hp domestic water...
Replies
14
Views
434
why my timer only executes once here? After first time i use it, ET stays at 0ms all the time. It is in FB
Replies
5
Views
311
Good morning guys, I'm searching for a Timer relay which accomplishes the "flasher" condition in the photo attached, however, I need the ability...
Replies
2
Views
556
Back
Top Bottom