Timer function S7

nicolas27

Member
Join Date
Jan 2007
Location
Maison
Posts
6
Hi, I want to make a timer who initialize when EN is True and count while the EN is True, if EN is false then the timer reset

At the end of the timer count the ENO ouput set to TRUE

i have make a FC but i can't initialize correctly the timer, how can i use EN input for initialize or not the timer ??


U #MemoSet // (IN_OUT : BOOL)
SPB LOOP
S #MemoSet // (IN_OUT : BOOL)
L #ValATTE // init value for wait (IN :INT)
T #RegATTE // current value for wait(IN_OUT : INT)


LOOP: L #RegATTE
L 0
<=I
SPB OK
///
U "Pulse 1 sec"
SPBN NOOK
///
L #RegATTE
L 1
-I
T #RegATTE
SPB NOOK
///
OK: NOP 0
SET
SAVE
BE
///
NOOK: NOP 0
CLR
SAVE
BE


Thank's for your HELP
 
Surely you are just describing a TON (Timer On Delay) which can be found in the program elements in ladder under the Timers folder or can be utilised in STL like this:

A I0.0 // If the input is on (or other condition ie M10.0)
L S5T#4S // initialise with 4 seconds
SD T1 // On Delay Timer T1
A T1 // If T1 times out
= Q2.0 // Bring on Q2.0 if the timer times out (ie after 4 seconds of I 0.0 being on)

Not sure why you are going into so much depth for this timer unless there's something I'm not understanding from your post (situation normal...)

Cheers

JT ;-)
 
nicolas - is the EN you are referring to the EN going into a function call when shown in ladder ?
 
yes it's the EN going into a function call when shown in ladder, and if it's possible i preffer to use my function because i need a lot of timer and it's more quickly to make find and replace than to create a timer and replace the name of the timer.
 
OK - you do realise that if EN is true then your block will be called, if EN is false, your block will not be called ! Inserting an FC into a rung is not the same as inserting a timer in a rung - view the code in STL to see what is really going on.
 
Ok but it is possible to reset a variable when the FC isn't call, because for example with the "FP" we can memorise the first call of the FC
 
The following scheme will make an FC behave like a timer provided the logic is processed every scan of OB1. The start Date and Time of the current and previous scans of OB1 are used to provide edge detection within the FC i.e. the FC can determine if it was called in the previous scan by testing its stored value of the OB1 start Date and Time with the previous OB1 scan start Date and Time.

Code:
At the start of OB1 the following processing is required where PreviousOB1DateAndtime and CurrentOB1StartDateAndTime are global data:
Call SFC51 To read DateAndTimeNow;
PreviousOB1DateAndtime = CurrentOB1StartDateAndTime;
CurrentOB1StartDateAndTime = DateandTimeNow;
 
 
 
Then inside the Timer FC the following processing logic is required:-
 
Call SFC51 To read DateAndTimeNow;
 
If (ThisFCStoredOB1DateAndTime <> PreviousOB1DateAndtime ) then
StartDateAndTime = DateAndTimeNow;
EndIf
 
ThisFCStoredOB1DateAndTime = CurrentOB1StartDateAndTime;
 
If (DateAndTimeNow - StartDateAndTime) > TimerValue then
TimerOutput = True;
Else
TimerOutput = False;
Endif
 
(Note:
ThisFCStoredOB1DateAndTime and StartDateAndTime would have to be IN_OUT variables)
 

Similar Topics

Hi guys I'm new to the forum and structured text. I'm just starting here - working on a traffic light system. So I have created this piece of...
Replies
4
Views
1,898
Studio 5000 V30. I'm more of a troubleshooter than a programmer but I need to control a TON's count time via an analog input.(0-10VDC). Looking...
Replies
9
Views
3,038
Does the timer enable bit stay enable once the timer is done timing?
Replies
6
Views
2,511
I am trying to set up a Function Block Timer (TONR in Controllogix5k) so that by changing the position of a selector switch, a different preset is...
Replies
5
Views
1,939
Hi all, I am trying to create a generic timed output function block. I dont want to create a function block for each output type. I think I am...
Replies
2
Views
3,041
Back
Top Bottom