Siemens S7-300 Timers

Mylo

Member
Join Date
Aug 2002
Location
Dublin
Posts
135
Hi all,

Hoping you can help me with this little problem in Ladder. I use Siemens S7-300 cpu’s for machine control. The process our machines have relies on the “Pulsing” of a Solid state relay, Each relay must be “Pulsed” for a definable but variable amount of time in the sequence ON/OFF/ON/OFF for 8 times. i.e. 4 x ON’s & 4 OFF’s per machine cycle.
Now the problem is this uses up 8 Timers per device. I can have up to 50 or more devices in a machine = 400 Timers required !!, now the CPU’s I use in the S7-300 range tend to have 128 timers, so therefore I cannot give individual control to each device , I have to “ Common “ a lot of the timers/Devices.
I imagine my programming technique in this regard is quite labourious and can be accomplished much more easily.I could also use the 128 counters “rewired as timers” but still eventually I will face the same problem. Other key items of info:

Each timer seperatley loaded with values from DB vie OP3/7 HMI.
All Device sequence tend to run at the same time ( all start their pulsing at same time)
All timers can have completely different values (Typically 1-4 secs)

So Someone please point out my weaknesses in my programming, for this purpose I have enclosed Simatic project in .arj/.zip format (Archived) ((Not sure how to post it as Bitmap/Other))

Hope to expect some of our “Siemens” experts on this one,,,,,,,,,

Cheers,
:rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes:
 
Mylo:

You may want to try using the "Clock Memory". You can find it in the hardware properties of the CPU. It has bits that flash at different rates up to 2 seconds. As long as you start on the rising/falling edge of the bit you should be able to achieve the pulse form that you require.You could use them for any of the pulses under 2 seconds, then either use a counter with them, or a timer for the longer cycles.
 
Hi Rob,

Not sure if that would work, I need to be able to adjust pulses (perhaps wrong phrase to use) or Timer values via an OP. I usually allow adjustment of 0.1 sec increments/decrements from 0 secs to 4 secs. Typically displayed/adjusted as

2.5 First time
1.2 second time
1.5 third time
3.2 forth time
0.3 fifth time
0.2 sixth time

and so on. How would I be able to load / adjust different values for these timers/counters. I'm not sure if that would free up or allow me the same type of control. Would it be possible to adjust these presets??
 
Besides the 128 system timers, the functional SFB4/5 system blocks you can find, in step7

Look for: Libraries-->Standard Library -->System Function Blocks SFB4 (TON) / SFB5 (TOF).

Time is in IEC format: T#4S_10MS means 4 s and 10 ms. You'll can change timer preset.
 
Just throwing out ideas

Maybe my idea is not feasible but I was wondering if maybe you could use 1 timer per device and a sequential based program. Timer is reset between sequences and maybe use a compare to accumulator value to stop pulse. You can always write values from an OP to a word and let that be the compare value.

Hopefully I expressed my idea properly. You stated there may be 50 devices per machine.
Device 1 Sequence enable-Pulse 1 enable-compare timer acc to word 1
Pulse 2 enable-compare timer acc to word 2
Pusle 3 enable-compare timer acc to word 3
Device 2 Sequence enable-pusle 1 enable-compare timer acc to word ?
Timer gets reset between pulses....enabling/disabling device sequence would depend I guess on system. This way only 50 timers are needed.


It would probably take me some time with S7-300 to do this, if it can be done at all but seems it may offer a viable option.

If not then someone please explain why?
 
Good idea rsdoran!

He could total the preset times, convert it to a timer preset value, then compare his presets to the current time value of the timer, with the done bit as the final indicator. The conversion into the timer preset is the only tricky part, due to the storage format of timer presets in our controllers.
 
Good one!!

I wasn't thinking along those lines but Ron came up with a very good idea, especially if you need separate on and off times for each pulse duration. You can enter and compare your time setpoints against the timer accumulated value to drive your outputs. The timer preset would be the sum of all the pulse times. Reset the timer with it's own done bit and you have a system that handles one relay with one timer, just like Ron said.
Just remember the S7 timer format. As far as I know the timer preset is a two-byte quantity with the highest order nibble defining the timebase and the lower 3 nibbles defining a BCD number between 0 and 999. So make sure you look at the total sequence length and select a timebase accordingly. With this method you may need to trade resolution for range, which may not be an option.
Do each of the pulse times need to be different? If not that opens up some options also.

Keith
 
You're right Keith...the timer preset is 2 bytes. The high order nibble is the time base (in BCD) where:

0=0.01 sec
1=0.1 sec
2=1 sec
3=10 sec

The lower 3 nibbles are the time value. It can be stored in an MW or a data block and used as the timer preset.
 
I'll get you jump started. I have a project I did for a hands-on training and has 300 on delay and 300 off delay timers, used for photo eyes on a conveyor belt. It doesn't use and timers and the delays are stored in a DB. There is code to do indirect addresing and all times are preset and viewed using about 7-8 tags in a TP170B touch panel. It would work the same in an HMI.

Copy and paste Oktober.zip

ftp://stepxstep:[email protected]/
 
Mylo,

in the course I teach, we have an exercise like the problem you stated. I'll attach a zip file with the exercise description and a listing of the solution in pdf format. I hope you'll find what you need in it.

Kind regards,

Jean Pierre Vandecandelaere
 
Thanks all,

I've been away from my desk, sorry for the late reply, to RGB & rsdoran,rqua,kamenges. Many thanks for your solutions, hadn't a clue what you meant at first, but the more i thought about it the more it provoked lateral thinking.

To RRobbins, couldn't retrieve the file, sorry, any chance you could attach again,

To Jean Pierre, many thanks for the file, helped me visualise a lot better the provided solutions, not quite what I need but the main think was it helped to understand.

I shall go off and try out a few of the solution methods, not sure about the details , but thanks all for the correct path to follow!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Mylo. ;) ;) ;) ;)
 
Why don't you simply use the IEC timers that siemens provide, in this case you are not limited to the amount you can use
 
Why don't you simply use the IEC timers that siemens provide, in this case you are not limited to the amount you can use

Because not all S7-300 CPU' have the possibilities to work with IEC timers. If you're working with S7-314's or 312's, you simply don't have that possibility. Maybe the newest versions of these CPU's will get it.

Kind regards,

Jean Pierre Vandecandelaere
 
Its been a while

Goddamn, it was the 2nd of May when I started this quest !!!!

for any of you that remember, let alone still have an interest, I have only recently got back to trying to solve my "Timers" crisis. Since we last met I've been taken away on all the other matters that revolve around, Hence the late (Extremely) reply.

I managed to sucessfully develop a little bit of code that uses nearly all the suggestions given. I can honestly say that seeing someone elses code helped soo much as it made me realise some of the things I was doing were so long-winded and cumbersome, I certainly have not become any great programmer but like finding out new techniques it all makes us better. To this end I managed to control 12 individual Timings using just 2 Siemens Timers. I did try just one but it didn't work everytime, quite possibly to do with scantimes/my programming. but i'll tackle it again in the future. For any interest i enclose a little proj, (((to ilustrate, i'll try to post "Picture" now how does that PRINT SCRN work !!!!!!!!!!))))

:site:

I can honestly say I couldn'y have done it without you, so many thanks, to Rob, Rqua , RSDoran , Keith , RRobbins and Jean Pierre !


:site:

Cheers !
 
Since we are playing "name that tune"

I can do that one hard ware timer. I do it all the time since CPU that runs the PLC probably only has 2 or maybe 3 hardware timers and one of those is used for periodic interrupts. I do it as follows:

One the rising edge of the start timer I save away the timer in a variable

Code:
StartTime = Timer;

Then each scan the timer is active do this check

Code:
if  ( Timer-StartTime >= TimeOut ) then .....


This simple style of timer only requires one location for the timer. However the timer can't be disabled and enabled without restarting the timer from the beginning.

Since most PLC use two locations they must do their timers like this:

At the start of scan do

Code:
TimeIncrement = HWTimer - OldTimer
OldTimer = HWTimer

When a timer is started
Code:
Timer(n) = 0;

When a timer is active
Code:
If Timer(n) >= Preset(n) then set done bit;
Timer(n) = Timer(n) + TimeIncrement 


This style uses an accumulated time(n) and a preset(n).
The advantage of the second method is that the timer can be enabled and disabled with restarting the elapsed time.

I never run out of timers.  The timers that PLC people use are just packaged cleaner in one little box but they do the same thing.   You guys can't really believe that there are really hardware 128 timers in PLC?

There was a thread on this about a year or two ago where everyone was speculating on how timers were inplemented.
 

Similar Topics

Hello, I need to be able to write time directly to a Siemens TON SFB4 timer. How can I do that through Wonderware Intouch using DasSiDirect...
Replies
2
Views
4,745
Hello friends I am new in this field I try to set and up counter in S7 300 station.Its count but counter not stop on the preset veluve.Can any one...
Replies
3
Views
10,209
Hello all. I have an ESA HMI that is connected to a Simatic S7-300 (CPU312). I have uploaded the program from the PLC which is written with Step7...
Replies
6
Views
1,448
Hello. There is a problem with Siemens S7 300. We got a replacement PLC but it does not run the program from the MMC. The new PLC is dated 2011...
Replies
3
Views
689
Hi to all, Our company does not usually use Siemens PLCs, but have a press with one in it. We are trying to change the IP address in our Simatic...
Replies
2
Views
1,066
Back
Top Bottom