S7 Function Block

honar

Member
Join Date
May 2011
Location
Iran
Posts
5
Hi
I have created a FB with multiple instance capability and assigned it two instances DB. For example FB2,DB2 and FB2,BD4. Every FB has its own actual parameters and had prefect operation when call it alone. There is a problem with FBs when they called, they are not functioning independently.
Please tell me how I can make each FB work independently.
 
The code you have posted only contains one call to FB2. It also contains two calls to FB4 which is not in the project. Please post code that we can run to attempt to replicate your problem.
 
FB2 contains the erroneous use of temp variables for edge detection storage - convert these to STAT varables.
Similarly, AM_INS is a temp variable that is not written to all of the time - convert to a STAT variable.

pop.JPG
 
Last edited:
OUT_INS is a temp that gets used in N/W 10 but is written in N/W 28

Suggest you convert all your temp variables to STAT variables and start again.

Temp variables are not remembered between calls but are stored on a stack. If you call the FB once, the stack may remain intact (depending on what else is called) and the temps will be remembered between calls. If you call the FB twice then the temps written by the first call will be used/overwritten by the second call.

pop2.jpg
 
Hi
I want to thank you for sending me the answer and guide me. I replace the TEMP variable to STAT and FB works properly. But when can we use TEMP variable in function block exactly?

Sincerely,
Honarvaran.
 
Hi
But when can we use TEMP variable in function block exactly?

Sincerely,
Honarvaran.


A TEMP does not store values between the FB calls. So eiter don't use TEMP or only as intermediate store. In practice does this mean that a TEMP is not valid until it is assigned using S, R, =, T, (and destination for BLKMOVE, Receive-functions...)

The TEMP variables (= Local variables) is a memory stack that is open for all user programs. When a block is called, the local stack pointer is preset to the first free area - and you will never know where it is - unless you have only one call from OB1 (or OB35 or another system OB) - then you'll get the same preset each time.

You can search this forum for more info on this never ending TEMP story.

Kalle
 

Similar Topics

Hi, I have attached herewith one image which our programmer has been used in S7 1500 PLC. Now we need to use the same instructions in S7 1200 PLC...
Replies
4
Views
118
Please see attached file. I need this program in Function Block form but I am totally lost on this. Any help would be appreciated. Thanks!
Replies
8
Views
294
Hi! I am using a TM200CE40T PLC from Schneider to write data over Modbus. I have used Memory words (%MW) before using the Write variable...
Replies
1
Views
533
Hi folks. New to the forum, but been working with PLCs for several years now. Would like some advice on whether you would keep this logic, or...
Replies
9
Views
1,067
Hi Yes, I'm stuck again. Trying to define a Function Block. What I've put in there so far has been a straight copy/paste from the code (and that...
Replies
22
Views
2,873
Back
Top Bottom