IEC timer driving me crazy

Next phase:

Re-code FB2 so you pass the inputs/outputs as parameters rather than the I/O being addressed inside the block.

Are you using plcsim to test this code?
 
They only parameters that I have used in FB2 are the timer (OpenTime) and the door request midline coil..

Yeah the plcsim
 
Yes, so add inputs and outputs and the call to FB2 will then look as below. In FB2 replace all of the real i/o with the allocated names.

tim7.JPG
 
Right.. Had a few issues to get it working but I think Im there. I found out how to create libraries as well so hopefully you will have my code. I called FB 2 in OB1 as your posted pic.

One thing I nothiced though. When I changed the code within FB2, the orignal call for FB2 in OB1 kept coming up with a time stamp error. It wasnt till I deleted it, that it went away. Any reason why it had this issue.

pic1.GIF
 

Attachments

  • Matty.zip
    20.9 KB · Views: 0
Balash is correct. If you double click DB2 it will open and you can see that it contains all the in/out/inout/stat variables for all of the FB's - these are called the interface of the FB. If the interface changes, you add or remove a variable from the interface, then DB2's contents will have to be regenerated. One method is to delete the DB and enter it again - use this method for the momement to keep things simple.

Add parameters to the simulation FB. Note that this time the inputs to the FB are the Q's and the outputs from the FB are the I's

Next, add the simulation FB1 into FB2. You add FB1 into the stat area just like the SFB4 timer by giving it a name and entering FB1 where SFB4 (or TON) is entered. When you save FB2 you will get a warning message that the interface has changed (telling you that you will have to regenerate DB2 again because you have modified the interface).
 
Morning

Im going to work on this project this afternoon, but just a quick question regarding the DB interface while it has been brought up. This is hypothecial btw but;

1- say that I was to modify and exsiting FB within a program that is already in operation. I take it you should tread with caution as the IDB may contain information that is required within the program, or will it be just regenared again whent the FB is regenerated and called??

2- When you download a project onto a PLC and it asks you to download system data, is that system data to information within the DB's, or is that something else??
 
1. You can modify an FB and download it to the PLC with no problems (unless your revised code is no good of course), as long as the declaration part is unchanged.
If the declaration part is changed, you will have to generate new IDBs, and they will also have to be downloaded. This is normally not advisable on a running machine or plant.

2. The System Data is the hardware configuration and also configured connections in NetPro. This is not related to the DBs or IDBs.
 

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