Making S7 timers retentive

GTX

Member
Join Date
Dec 2003
Posts
36
Ok here is my problem.

Below is a picture of the ladder i am using to control two timers. T13 is simply a looping timer that counts down from 60 seconds over and over. T14 is a timer that take a preset time value (MW45 = 5 mins) and it times down.
ladder.jpg


Currently everytime the start button (which is a latching switch) goes false then true the timer resets. What i want is for the timer to simply resume timing where it left off like a AB retentive timer.

Can anybody help me out with what i have to do to make T14 a retentive timer ? Is there a way to make T13 retentive as well ?

Thanks for any help !!

Kindest Regards,

Barry
 
Use a S_ODTS timer (retentive on-delay timer)!
Sorry I didn´t read your question accurate enough, the timer only continues to count when the start goes to 0. I don´t remembver what happenens if you jump over the instruction when you wan´t the timer tro stop?
 
Last edited:
Barry,

MOVE the BCD value of the timer back to MW45 every time startbutton goes OFF. When it goes ON again, the timer starts with the remaining time. The BCD output has the STIME format, so it should be no problem. The only problem you have left is how you can re-initialise the timer to it's original value. I cannot answer that question for you, because you've shown us nothing else but these two timers.

Niklas,

the S_ODTS timer is no solution, since it keeps on running even if the input condition goes OFF. The question was about a timer which only runs if the input condition is ON, but keeps track of the time already taken into account.

Kind regards,
 
Last edited:
Jean Pierre,
you are close but not completely there :).
The BCD output is BCD coded, but it doesnt contain the timebase information in the first nibble of the S5TIME formatted TV value.

If you use a MOVE instructions from Tx to MWx, then it will be the same as using The "L Tx" instruction.
The "L Tx" instruction (Load Current Timer Value into ACCU 1 as Integer) doesnt include the timebase.

GTX must use the "LC Tx" instruction (Load Current Timer Value into ACCU 1 as BCD) to load the current timer value WITH the timebase. He will have to do it in STL.
 
Barry,

I can't help feeling this is a bit like saying "here's a chisel - how do I make it work like a screwdriver?" They both look broadly similar: flat-bladed mechanical tools. And sometimes you might get away with using one as the other. But it is always going to be going against the inherent nature of the tool.

The S_ODT timer is not a 're-startable' (let's try that term rather than retentive) timer. Here's the source for a function I've written which might work for you. It uses two control inputs : RUN_STOP and ENBL_RST. The timer uses IEC TIME data type for PRESET and CURRENT so you can time for several days if you wish and it's much easier to view.

Let's see if this is a start on the path to a better screwdriver.

Regards

Ken M.
 
Jesper,

your statement
The BCD output is BCD coded, but it doesnt contain the timebase information in the first nibble of the S5TIME formatted TV value.
is wrong. The BCD output DOES contain the timebase info. You're right as to your other comments, but I didn't mean he had to use a MOVE instruction from Tx to MWx. What I meant was: connect a MWx to the BCD output at the timer. In this way you're using the "LC Tx" instruction and not the "L Tx" instruction. The latter is used when you're using the BI output, as Barry has done. So it's perfectly possible to program all this in ladder as I use this as an exercise in my classes.

Kind regards,

retentive_timer.gif
 
If it works in your classroom, then you must have gotten it right :p

I just cant understand WHY you are right :unsure:, as I checked the online help regarding the BCD output value:

Parameter  Data Type  Memory Area   Description
BCD WORD I, Q, M, L, D Remaining time value, BCD format

I find it strange that it is a WORD and not an S5TIME if it contains all the same information as an S5TIME variable.
And what if you use the BCD output to display the remaining time on an HMI, will it then display some "gibberish" because of the timebase in the first nibble.
 
Oh, I *hate* S5TIME format. Am I the only one? It might have made some kind of sense 25-30 years ago when Siemens were designing the original S5 processors, but nowadays ...?

How many of us have BCD watches and clocks that only run up to 999?

Let's start a campaign to get rid of all non TIME formats. Who's with me men?

Regards

Ken M.
 
I am with you Ken ;)

Just this little thing nags me about the IEC timers:
In LAD, why cant I MOVE a TIME variable into the .PT (Preset Time) of an IEC timer ?
I get an "Actual data type TIME does not fit the formal type of the formal parameter".
.PT is a TIME variable, so I am perplexed as to the reason.

I have to do it in STL to get by.
 
Now I know why Jean Pierre's code works.

If in LAD you put a MOVE from Tx to MWx, then it will go bad.
In STL it looks like
L Tx
T MWx

If in LAD you put an MWx on the BCD pin of Tx, then it will work.
In STL it looks like
LC Tx
T MWx
 
Jesper,

I'm not sure about your problem with the IEC timer in LAD.

I created a call to SFB4 TON with instance DB60 and applied no actual parameters. On the next network I then used a MOVE with the actual input parameter as T#1m30s and the output as DB60.DBD2. No problem. If you apply a symbolic name to DB60 and have the "Report cross-references as error" option checked it will produce an error, but not related to the data-type.

I then tried applying a parameter to .PT I used MD20 and declared it as type TIME. Replacing the output of the MOVE with MD20 produced no errors.

I'm sorry - I can't get it not to work!

Regards

Ken M
 
Jesper,

I finally got around to examining your example. I can replicate the problem using V5.3 STEP7. The "problem" is the variable named 'iectimer.pt' - it doesn't actually exist!

Because 'iectimer' is an instance within your parent FB, all it's attributes exist only in the instance DB of the parent. You will have to address it using the full 'DBname.objectname.attribute' format.

Of course, this then means you have to know the name of the instance DB for the parent FB, and you may not have created that yet if you're only at the stage of adding declarations and code to the FB! I suspect there will be a way around this by coding using the DB register and AR2, but I haven't tried this yet. It would also remove a lot of the readability of IEC TIME datatypes.

I told you you should put all your timers together in one big FB!

Good luck

Regards

Ken
 
I have attached a screenshot that shows in further detail what is possible and what is not possible.

[attachment]

Notice that both the boolean variable #iectimer.IN and the TIME variable #iectimer.ET works OK, so your idea that the reason is the embedded variables doesnt exist cannot be correct.
Also, I CAN access iectimer.PT in STL.

Its only in LAD that it doesnt work. And its only the .PT variable.
(all in all, I find it very strange indeed).

And I think that I would loose some of the idea of embedded FB's if I used one large timer DB/FB block. But maybe some others can use it.

edit: To those who might wonder: No I didnt forget to put in the "#" in front of "iectimer", STEP7 automatically does that if it accepts the input.

timererr3.gif
 
Ah,

OK then, here's my second theory.

The working TON attributes are -

1) .IN which is an input to TON and being read and,
2) .ET which is an output from TON and being written.
The one which doesn't work is an input which is being written. Possible?

Good old STL seems to do very little checking of data types etc so it may not even check this aspect of data usage, whereas LAD does.

Regards

Ken.
 

Similar Topics

Hi, I have seen a few post with similar topics and I have tried contacting the authors however I have not had any luck so I am posting this new...
Replies
14
Views
1,040
Hi everyone I've created an FC that includes the blocks TCON, TDISCON, TSEND and TRCV. This block has to be as generic as possible across...
Replies
15
Views
1,595
Hi all, I have been working on a tool for my company that handles a specific task our company runs into often related to PLC's. This is a tool I...
Replies
15
Views
2,920
Hi, i need to make: 1- A PLC Program on Omron PLC CP2E-N using high speed counter E6C3-AG5B 360P/R 2M(Absolute) ,to Reject bottles on Conveyor...
Replies
4
Views
896
I was taught to go to Combined > Make Change > go to Offline > will prompt to save > Save > Exit out of program > will prompt to save again >...
Replies
0
Views
687
Back
Top Bottom