IEC timer driving me crazy

Matchu04

Lifetime Supporting Member
Join Date
Mar 2013
Location
Northampton
Posts
287
After a previous post I have been trying my best to set up a simple s7 IEC timers within a FB (Timings) and then use it from a FC (FC1). I have managed to set up the the timers within a stat parameter within the fb and then created the DB1 for that fb.

I have called the FB within OB1, but when I come to use timer from fc 1 say, and called it "TMR".Timer1 it doesnt like it.

The other thing Im not 100% is how to load the timers with the time values I require. would I load the values in the FB that i have created the timers in, but then wouldnt the value be over written every time fb timings is called?

Please help driving me nuts!!
 
let me tell you where Im at. I fairly new to PLC prgramming and have just completed a S7 Basic course. Within the course we covered S5 style timers which I seem to grasp.

It was then brought to my attention that I should be using IEC timers so im basically trying to inplement IEC timers.

I have done a shed load of reading on this forum but whether Im being stupid or not doing it right I just cant get it to work.

There was a thread that I was read, and from what I understood the user uses a single FB to list all of there timers within a program. This FB was then called it OB1 and then you was able to use the contacts of each timer globally.

Have I got my wires mixed up or missing something?
 
if you put IEC timer inside FB then you won't see it (timer) outside it (FB) (and i guess FC1 is outside the scope respective FB). try changing IEC timer from FB part to global (create it or edit it to single instance).
 
Please forgive but this means nothing to me...

The only part I think I understand is a IEC timer is only active when its called. This is why I called the FB containing the IEC timers in OB1.
 
IEC timer when created can be chosen as single or multi instance. later would put it into FB's declaration part and as such would be available to that FB. if single instance is chosen, then timer is global, it creates its own DB and it can be accessed from everywhere in program, as i recall
 
I just created a new DB for fb1 and it gave me the option for it to be shared or instance. I tried shared but still no joy.
 
There was a thread that I was read, and from what I understood the user uses a single FB to list all of there timers within a program. This FB was then called it OB1 and then you was able to use the contacts of each timer globally.
Maybe someone programs like that, but it is not the most obvious way to use IEC timers. Maybe that user has some special reason to put all IEC times in a single IDB.
The most 'typical' way, and also the simplest, is to embed the IEC timers into the FBs where they are needed. They then become part of that FBs IDB for each instance. This is also called 'multiple instance'. Sounds intimidating, but it is easy to do.
 
The sooner you ditch FC's as general purpose blocks for holding ad hoc code the better. Functions should be used to perform a function, i.e. give the function same data and it will return a value. Although S7 allows you to use FC's in any way you like, it doesn't mean that you should.

Ditch the FC's and use FB's instead.
 
I just created a new DB for fb1 and it gave me the option for it to be shared or instance. I tried shared but still no joy.

not that. i meant that when you create a timer (i.e. insert iec timer box) THEN you choose single instance for it (progam should then create Timer's IDB)...

as for later comments from Jesper and LD, i agree with. that's the way to go, to put everything where it belongs... (once you managed timers)
 
Ahhh this is where I have been going wrong. L D[AR2,P#0.0] I took the code that you sent me the other day and like you suggested tried to use a IEC timer for T2. I took me ages to work out that it had to be in a FB and reading your recent comment just enhanced this.

My other problem is I have managed to do the timer, but for some reason its is not operating correctly. I have tried to monitor it get my head round it but my heads gone, getting around these IEC timers.

I have attached the project.. Oh yeah another thing is how to archive as a library and not complete project??
 
For the Library thing. Just go to File->New and then choose the Library tab along the top of that window (middle tab if memory serves me - not got Simatic Manager at the moment). Then type a name and click OK and you've created a Library.

Next just Insert an S7 Program into the Library and then you have a Blocks folder that you can copy and paste your blocks to. Then you can Archive / Retrieve the Library the same as a program (File->Archive etc).

;-)
 
In the first project, I1.0 and I1.1 had symbols, in the new project they do not.

In the first project the door up limit was I1.1, in the new project you are using I1.0 for the door up limit. The door down logic is not using a down limit.

Here's the corrected source code for FB2. (In the source folder add a new awl source file. Copy/paste the text into the source file then compile it - this will generate a new FB2 as long as FB2 is not already open).

Code:
FUNCTION_BLOCK "fbRollerDoor"
TITLE =
VERSION : 0.1

VAR
  DoorRequest : BOOL ; 
  OpenTime : "TON"; 
END_VAR
BEGIN
NETWORK
TITLE =Door up signal
      A(    ; 
      A(    ; 
      O     "InPEC"; 
      O     "OutPEC"; 
      )     ; 
      =     #DoorRequest; 
      A     #DoorRequest; 
      O     "DoorUp"; 
      )     ; 
      AN    I      1.1; 
      =     "DoorUp"; 
NETWORK
TITLE =
      AN    #DoorRequest; 
      AN    "DoorUp"; 
      =     L      0.0; 
      BLD   103; 
      CALL #OpenTime (
           IN                       := L      0.0,
           PT                       := T#5S);
      NOP   0; 
NETWORK
TITLE =Door  Down Signal
      A     #OpenTime.Q; 
      AN    I      1.0; 
      =     "DoorDown"; 
END_FUNCTION_BLOCK
 

Similar Topics

I recently discovered that when downloading an online edit [S7-1500] that requires the initialization of the modified FB's iDB, an IEC timer whose...
Replies
36
Views
11,916
Tried Googling and searching this forum for the answer to this, but no luck, so figured start a new post to see if anyone can help me...or confirm...
Replies
8
Views
3,410
Hi all, :huh: How the IEC timer works? I tried to simulate the IEC timer SFB4 in FB but it seems its hard for me to analyse where I...
Replies
6
Views
4,373
Hello! I intend to use the iec timer SFB4 for alarm blocks. In order not to use up one instance data block for each timer, my intention was to...
Replies
4
Views
7,744
Hello guys, I understand that Siemens IEC timers update asynchronous to the program cycle. While the Time value is stored in milliseconds, I'm...
Replies
3
Views
2,324
Back
Top Bottom