s7 300 fc's temp areas

tny

Member
Join Date
Jun 2005
Location
usa
Posts
105
hi all,
i have a question about function's temp variables.
i know that a temp variable must not be read before writing on it.
so if i have to set a variable and use it later, it must be a in_out variable and i have to allocate a memory bit (or dbx) for it.
but i saw a code like: (still working on a huge warehouse controlled by 4 s7 300s for 3 years)

on i_emergency
o
a temp13
an i_reset
= temp13

this means if i push emergency button i set temp13, if i release emergency button, temp13 still remains "1" until i press reset button.
but how can it be?
can i set a temp variable and trust it later?
i mean, if i call this fc from fc1 and fc1 writes 1 on temp13, than i call it from fc2 again and fc2 writes 0 on temp13, when fc1 calls it again, what will be the value of temp13?
(i think it will be 0 now but how is the system working if so?)
 
Temp=temp.
During a PLC cycle you can not use the temp values from the previous scan. These temp memory is used for all function blocks and functions. You must use STAT variabele to store data needed the next cycle.
 
Maybe "temp13" is just a symbol for a global variable or a STAT and not really a TEMP.

Anyway, faulty code or not, I sure hope that someone didn't solve a real emergency stop function with plain PLC code.
 
s7xp.com said:
Temp=temp.
During a PLC cycle you can not use the temp values from the previous scan. These temp memory is used for all function blocks and functions. You must use STAT variabele to store data needed the next cycle.

i see, so my understanding about temp vars is ok right?
but how does fc1 (and other fcs) work correctly? i still can not understand it.

here is the fc1:
function 1

ON I 15.7
O
A #TEMP9
AN I 15.6
= #TEMP9

ON #IN2
O
A #OUT8
AN #IN4
= #OUT8

A I 15.5
A(
AN #IN1
A #IN3
O
A #IN1
A #IN6
)
AN #TEMP9
AN #OUT8
AN #IN5
AN M 215.5
= #OUT7




ON I 15.7
O
A #TEMP13
AN I 15.6
= #TEMP13

and temp13 is defined in temps.

as i said before, i think it wrong,but i want to beleive that it should work for the robustness of our warehouse.

i wanted to send the program but it is too big to attach.
 
Last edited:
JesperMP said:
Anyway, faulty code or not, I sure hope that someone didn't solve a real emergency stop function with plain PLC code.

i couldn't understand, could you please explain it?
 
Whilst you cannot rely on a temp variable maintaining it's value from one call to another, it is possible that it will be retained if a predictable call structure is in place and no other code overwrites the area. I have seen several cases of code using temp data as if it was static data and working correctly until the program structure was altered.

Another possible (but unlikely) scenario is that whole of the temp data area is preloaded with the contents of a global db at the start of the FC and then the whole temp area is copied out to the gloabl db at the end of the FC. The temp area can now be used as if it is static data.
 
Correct, I made in my "early days" a communication program which uses only input, output and temp vars in a FB. There was only one FB in my project and everything works fine. Until I add another FB ...
 
L D[AR2 said:
Whilst you cannot rely on a temp variable maintaining it's value from one call to another, it is possible that it will be retained if a predictable call structure is in place and no other code overwrites the area. I have seen several cases of code using temp data as if it was static data and working correctly until the program structure was altered.

Another possible (but unlikely) scenario is that whole of the temp data area is preloaded with the contents of a global db at the start of the FC and then the whole temp area is copied out to the gloabl db at the end of the FC. The temp area can now be used as if it is static data.

no there's no such copying procedure, it just 4 nw as in the picture.
i you have time, you should have a look at the program. i divided the folder in to two parts, but extensions must be rar.
i had to change them to zip to upload them.
thanks
 
tny said:
i couldn't understand, could you please explain it?
The symbol "i_emergency" could mean that it has to do with enabling/blocking equipment in an emegency. That is not OK if it is done with plain PLC code.
If it is only about generating an error message for example then it is quite OK.
 
JesperMP said:
The symbol "i_emergency" could mean that it has to do with enabling/blocking equipment in an emegency. That is not OK if it is done with plain PLC code.
If it is only about generating an error message for example then it is quite OK.

you are right, it is only for error message.
 

Similar Topics

Dear experts, I have a question about temp interface address, If i have a temp "temp75.temp78", and i found that this address in DB7, and this...
Replies
4
Views
1,336
Hi all, I would like to know if anyone has any good advice for connecting a generic PT100 temp probe to a Siemens S7-300. I have read some posts...
Replies
1
Views
3,764
We have a project to communicate Siemens S7 plc using CP341 to Pyromat Plus 300 (Temp controller). We need to know the protocol used by this...
Replies
0
Views
1,861
hi every one!. i have a question about using temp variables in FC's of s7 300 for example when i write a script like this A #in1...
Replies
29
Views
12,370
Hey all, first time poster here. I am wondering if anyone has tried using a Keyence SR-X300 barcode scanner to a Micrologix 1400. Keyence sent...
Replies
0
Views
22
Back
Top Bottom