S7 - What is it about me and timers?

RMA

Member
Join Date
Sep 2004
Location
North of Hamburg, Germany
Posts
2,052
I don't know, but I suspect it's got to do with my general problems with getting my head round the cyclical nature of PLCs in general!

As long as the timer's being started by a plant event, everything's OK. The trouble starts when I need to provide the edge-trigger to start the timer myself. Either I finish up with the Trigger signal permanently set, so there's no edge, or I finish up resetting it as soon as it's been cleared so that the timer keeps getting re-started!

I've just spent nearly an hour trying to get a simple impulse timer to work and still haven't managed it!!! :oops:

The trouble really starts, as in this case, when the FB has to run continuously, I can usually solve it when I'm only calling the FB on demand.

Can some kind soul please show me the definitive way to provide an edge-trigger to start a Timer (impulse in this case) and how to safely reset the trigger Bit afterwards, preferably in an FB using STATs.

Many thanks in advance from an extermely frustrated (not to mention embarassed)

Roy
 
Try this if you always want the pulse produced on the rising edge of bStart.

FUNCTION_BLOCK FB 1
TITLE =Produce pulse on rising edge of bStart.
VERSION : 0.1


VAR_INPUT
bStart : BOOL ;
tTimer : TIMER ;
s5TimeValue : S5TIME ;
END_VAR
VAR_OUTPUT
bPulse : BOOL ;
END_VAR
VAR
bTimerStartEdge : BOOL ;
bPulseStart : BOOL ;
bTimerNegEdge : BOOL ;
END_VAR
BEGIN
NETWORK
TITLE =detect start edge and timer timed edge


A #bStart;
FP #bTimerStartEdge;
S #bPulseStart;
A #tTimer;
FN #bTimerNegEdge;
R #bPulseStart;
NOP 0;
NETWORK
TITLE =pulse timer


A #bPulseStart;
L #s5TimeValue;
SP #tTimer;
NOP 0;
NOP 0;
NOP 0;
A #tTimer;
= #bPulse;
END_FUNCTION_BLOCK
 
I'm not quite sure what you're trying to suggest there Simon. Although my question was fairly specific, my problem is much more general. Regardless of the type of timer, where I always have trouble is providing a single edge to start the timer and then resetting the Merker Bit (or whatever Bit) so that it is available for the next time. As I said, I usually finish up either not clearing the Bit at all, or clearing it and then immediately setting it again on the next cycle.

I've just copied your FB into a text editor to transport it to my S7 system to compile it, so I'll be trying it out in the next hour or so.

What I'm trying to do is test various outputs. To this end I've created a test screen in ProTool where I have a button to click on to drive the output and the display shows the state of the output and of the feedback contacts. In the case of the Thyristor I want to pulse it on for a short time so I have an FC dedicated to this button. If the Test Screen is active, the FC is being called permanently, but the first thing it does is check whether the Button for the Thyristor has been clicked and if not it exits immediately.

If the button has been clicked, then I set up the data to determine which Thyristor is to be pulsed (yes, we're playing with my beloved FM352-5 here, again!). I then need to start the timer to pulse it for 10 ms and then on completion reset the data that is being sent to the FM and clear the Bit which was set by clicking the Trigger button in ProTool. My problem is that either I have my edge-trigger Bit permanently set, so that I don't start the Timer, or alternatively, depending where I set and clear this Bit inside the FB, having once cleared it it immediately gets reset next time round!

Anyway, I'll go and compile your FB and see if it helps shed a light on things - be back in while!
 
I've compiled your block - that was an exercise in itself since I've only done it once before - worked fine after translating the commands into German and even got it to show up in FBD.

As I suspected, it doesn't address my main problem.

My block has to run cyclically for as long as the timer is running (OK, in this case that's probably only two or three times, but in other cases it may be longer) what I'm looking for is a way, within the block, to set bStart once (switch from 0 to 1) then sometime later (with most Timers, after the Timer expires, with an impulse, as in this case, any time after the Timer has started) to set bStart back to zero, so that the next time the Block is called, the process can be repeated.

It's this only setting and resetting the Bit once while the block is running for several cycles that is screwing me up. If possible I want to this entirely within the block. If it's not possible then I guess I'll need to do it outside, but I'd really like to keep it entirely self-contained if possible.
 
From your description, my guess is I have the wrong end of the stick, but I'll ask anyway: If the block only runs when the timer is running, how can the timer ever get started ?
 
Well, actually, that's probably part of the problem!

The block is called continously when the test screen in ProTool is active.

If the SCR Test Button has not been clicked (i.e. a particular Bit in the "Test Buttons" DB is not set), then the block is exited immediately.

If the Bit is set, then I set up the conditions to tell the FM to turn on the output which controls the Laser Diode which will trigger the SCR for the chosen module. In order not to overload the diode I want to give just a short pulse, the shortest I can set in the 317 appears to be 10 ms. So I need to have a Bit change from "0" to "1" in order to provide the edge to start the Timer. When this Timer pulse expires (two or three cycles later), I then want to clear the data going to the FM, clear the Bit in the Test Buttons DB and reset the Bit that I use to edge-trigger the timer.

After that, as long as the Test screen is still active, the block will still be called every cycle, but will immediately exit unless I click on the SCR Test Button again, in which case the above sequence should be repeated.
 
Problem solved!

And it really couldn't have been easier.

I moved the Network with the Timer in it up to the start of the program - NW1 and changed the S-input so that it used the SCR Test-Button Bit as its input. So as soon as the Test Screen is active, the Block is called and the Timer sees a 0 on its S-input. In NW2 the check is made to see if the Button has been clicked and if not, we exit the Block. Now when I click on the Button, the Timer's input goes high and off we go.

I wonder when I'll get to the state where things like this are second nature, instead of having to waste half a day going round in circles first! Still, at least it's working now, I guess that's the main thing! :D
 

Similar Topics

Hi, I'm quite new to Rockwell PLC and currently trying to implement the following if Sw1 then for i:=1 to 20 by 1 do xEnable := 1...
Replies
4
Views
143
I'm writing some alterations to an FPWin program and need to see the running value of timers so I can set them correctly. It's my first time with...
Replies
0
Views
131
Hi everyone I am using Winproladder software for programming FATEK FBs PLCs and in programming, we often use Timers for activation of the...
Replies
4
Views
561
Hi all, I have what is likely not a complex issue, but I am working in Automation Studio and want an accumulating/retentive timer when a...
Replies
17
Views
1,898
Dear all, I want to use the interrupt service routine in FATEK PLC using WinproLadder Software. I had configured the interrupt in software as...
Replies
17
Views
1,562
Back
Top Bottom