s7 300 timers and counters

sparkysliderz

Member
Join Date
Feb 2005
Location
Posts
68
Hiya guys,
I wondered if anyone could help me with my problem as I think i may have shot myself in the foot!

I "borrowed" S7Guys program conveyors.zip and modified it to suit my application, which is at the moment calling 72 seperate FC's which are identical except for their I/O and Timer & counter numbers! I have modified the original conveyor UDT and am now only calling 2 FB's within my modified code.

Everything was looking good until I came to de-bug my code! and it hit me like a sledge hammer what the problem is but I have no idea how to fix it! Please see the code snippet.......

TimeCount.jpg


As you can see its fine but the 3 timers and 4 counters I need never change their values as they are being re-called when the FB is reloaded with different parameters from the UDT?
Please help guys! Thanks in advance!
 
replacing timers in FB

You could use SFB0 through SFB5 and incorporate the DB for them in the Instance DB for your calls. Inother words it is possible to make a SFB's instance DB part of the Instance DB for the FB that it is called in.
 
sparkysliderz said:
Hiya guys,

Everything was looking good until I came to de-bug my code! and it hit me like a sledge hammer what the problem is but I have no idea how to fix it! Please see the code snippet.......

Could you expand on what you think the problem is ?

From your description you have 72 different FC's which are identical except for the i/o, timer and counter numbers, is my assumption correct ?
 
SimonGoldsworthy said:
Could you expand on what you think the problem is ?

From your description you have 72 different FC's which are identical except for the i/o, timer and counter numbers, is my assumption correct ?

Yes, Simon that is correct.
 
Why not change your code so your not using the built in timers and counters. Instead try to use a timebased counter for the timer and just a simple X = X + 1 for your counter.
This is usually better when you have to reuse the same code with a timer and / or counter.

Cheers
Borte
 
As each FC unique and has it's own counters and timers, the problem must be to do with the variables driving the counters/timers. Where else can you monitor the variables feeding the timers/counters? Are they in a global DB being used by an unconditionally called FB or are they in an instance DB ?
Can you "cut down" your project so it contains the relevant blocks (shortened if necessary) and then attach it to the post. We can then examine the basic scheme to see what is going on.
 
Sparky, when I am using this "UC FB" scheme, I store the timer and counter instances in the shared DB, and retrieve them when necessary. It's kind of hard to explain, but I'll try:

Let's say you have a shared DB with an array of forty motors. Each motor is a udt composed of various elements (as described in my sample project). Within this array, you can include timer instances, such as "MotorOffDelay" and "MotorOnDelay". During startup, you can load unique values for each motor (i.e. Timers 1 and 2 for Motor 1, Timers 3 and 4 for Motor 2, etc).

Then, when you call the FB, you would load these values and call the timers indirectly:

L #Motor.MotorOnDelay
T #tempOnDelayTimer

A #MotorStart
L S5T#1S
SD T[#tempOnDelayTimer]
etc.

Does that make sense?

And as Borte mentioned, you could also increment an INT instead of a timer. That would work as well.
 
Thanks for the replys guys! youv'e been a great help! I brought the CPU and a power supply home and I'm going to try a few things over the weekend(wish me luck!) I'll check in again on Monday! Thanks again everyone!
 
S7Guy said:
Sparky, when I am using this "UC FB" scheme, I store the timer and counter instances in the shared DB, and retrieve them when necessary. It's kind of hard to explain, but I'll try:

Let's say you have a shared DB with an array of forty motors. Each motor is a udt composed of various elements (as described in my sample project). Within this array, you can include timer instances, such as "MotorOffDelay" and "MotorOnDelay". During startup, you can load unique values for each motor (i.e. Timers 1 and 2 for Motor 1, Timers 3 and 4 for Motor 2, etc).

Then, when you call the FB, you would load these values and call the timers indirectly:

L #Motor.MotorOnDelay
T #tempOnDelayTimer

A #MotorStart
L S5T#1S
SD T[#tempOnDelayTimer]
etc.

Just verifying that I got this right... You're still using the built in timers of the plc so you'll still be limited by the number of timers available?

Cheers
Borte
 
Yes, that's correct. But, I just allocate them indiscriminantly on start-up, so I don't care which timers I'm using. And, I don't have to define the timers as input parameters in functions, since they are already allocated.

In a case where I might run out of timers, I would use your method.
 

Similar Topics

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
I've used the following timer code in S7-300's for a long time. When migrated to an S7-1500 plc, the timer behaviour changes so that I no longer...
Replies
22
Views
5,380
Dear all colleagues and members I have worked for a company and I created a program for them for small automation but they dont want to give my...
Replies
12
Views
4,706
Hi, I'm looking for a way to pause the timers I have in my PLC. I'm making a program which has a safety switch which is supposed to pause the...
Replies
5
Views
2,141
Hi all, I probably have some short questions for you. I'm trying to understand timers and the Siemens operating system in more detail...
Replies
9
Views
12,353
Back
Top Bottom