You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 17th, 2018, 05:18 AM   #1
[PL] mk
Member
Poland

[PL] mk is offline
 
[PL] mk's Avatar
 
Join Date: Apr 2017
Location: src
Posts: 16
TIAv14 clearing temp structure

Dear Experts,

I'm new in TIA and I have question about clearing temporary area which is used in FC/FB.

Generally on Step7 V5.5 when I call FC/FB, on the beginning I clear all temps which I use inside. I create a structe called _s where I keep all temp signals and in network 1 I "FILL" whole structure with zeros.

This doesn't work on TIA. Can you guide me how to do this clearing?

PLC -> CPU 1512SP-1 PN
  Reply With Quote
Old January 17th, 2018, 06:01 AM   #2
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Fields of corn
Posts: 917
The temporary area is, to the best of my knowledge cleared automatically whenever the FC/FB is called. Have you confirmed this on TIA?
  Reply With Quote
Old January 17th, 2018, 06:37 AM   #3
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,243
For STEP7 Classic, the TEMPs are definitely not cleared upon block call or leave.
Maybe you are thinking of that the local stack is saved when another block is called, and upon return to the calling block, the calling blocks local stack is restored.
Not sure abot STEP7 TIA, but I suppose it works the same way.

When you use TEMPs you must make sure that the 1st access in a block is a write that initializes the value.
To clear TEMPs at the end of a block should be unnecessary.
__________________
Jesper
3 strikes and you're out
  Reply With Quote
Old January 17th, 2018, 06:45 AM   #4
mk42
Member
United States

mk42 is offline
 
Join Date: Jun 2013
Location: MI
Posts: 1,838
Quote:
Originally Posted by cardosocea View Post
The temporary area is, to the best of my knowledge cleared automatically whenever the FC/FB is called. Have you confirmed this on TIA?
I know this is true for OPTIMIZED blocks in 1200/1500. Not sure about unoptimized/standard in 1200/1500.

As Jesper said, definitely not true for 300/400 (and that should be true for both TIA and Simatic Manager).
  Reply With Quote
Old January 17th, 2018, 08:29 AM   #5
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,531
Turn off optimised block access and you can use fill.
Attached Images
File Type: jpg clear.jpg (67.5 KB, 53 views)
  Reply With Quote
Old January 17th, 2018, 08:45 AM   #6
[PL] mk
Member
Poland

[PL] mk is offline
 
[PL] mk's Avatar
 
Join Date: Apr 2017
Location: src
Posts: 16
I'm not sure if my post was clear enough.

In attachment you can find local data initialization (zeroing) which I perform at the begging of all fc/fb.

The same operation I want to do in TIA but it doesn't allow me to clear the structure.
Attached Images
File Type: jpg temp.jpg (45.6 KB, 53 views)
  Reply With Quote
Old January 17th, 2018, 08:55 AM   #7
[PL] mk
Member
Poland

[PL] mk is offline
 
[PL] mk's Avatar
 
Join Date: Apr 2017
Location: src
Posts: 16
Quote:
Originally Posted by L D[AR2,P#0.0] View Post
Turn off optimised block access and you can use fill.
This is it. Thank you very much.
  Reply With Quote
Old January 17th, 2018, 09:20 AM   #8
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,243
But still ..... WHY !!

__________________
Jesper
3 strikes and you're out
  Reply With Quote
Old January 17th, 2018, 09:36 AM   #9
[PL] mk
Member
Poland

[PL] mk is offline
 
[PL] mk's Avatar
 
Join Date: Apr 2017
Location: src
Posts: 16
The temp memory is global and is not cleared when exiting the function.
To be sure that the temp memory in the function area does not have any trash from the previous function, I always clear this area if it want to use it in a active fc
  Reply With Quote
Old January 17th, 2018, 09:50 AM   #10
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 13,243
Man, like I said before, it is a well-established doctrine, that TEMPs must be initialized as the first thing in a block before reading. If you adhere to this, there is absolutely no need to "clear" the temporary memory when exiting a block. I have never heard of anyone else doing like that.

edit: And what if you use library blocks from others, for example from Siemens that are closed with know-how-protection ?

edit again: And it would not be enough to clear the declared TEMP structure. The TEMP structure of one block may be a different size to another blocks TEMP structure.
The more I think of it, it is clear (to me at least) that you are doing it the wrong way around.
__________________
Jesper
3 strikes and you're out

Last edited by JesperMP; January 17th, 2018 at 09:59 AM.
  Reply With Quote
Old January 17th, 2018, 09:56 AM   #11
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,531
Following testing in PLCSIM:

For blocks with optimised access, the temp area is cleared at the start of block execution and also cleared when the block completes.

For blocks without optimised access, the temp area is not cleared.
  Reply With Quote
Old January 17th, 2018, 10:26 AM   #12
[PL] mk
Member
Poland

[PL] mk is offline
 
[PL] mk's Avatar
 
Join Date: Apr 2017
Location: src
Posts: 16
Quote:
Originally Posted by L D[AR2,P#0.0] View Post
Following testing in PLCSIM:

For blocks with optimised access, the temp area is cleared at the start of block execution and also cleared when the block completes.

For blocks without optimised access, the temp area is not cleared.
Thank's for information.

Quote:
Originally Posted by JesperMP View Post
If you adhere to this, there is absolutely no need to "clear" the temporary memory when exiting a block.
I have never said that I clear temporary memory when exiting a block. I do it in the first step after block is called.

Quote:
Originally Posted by JesperMP View Post

edit again: And it would not be enough to clear the declared TEMP structure. The TEMP structure of one block may be a different size to another blocks TEMP structure.
I know that.

Quote:
Originally Posted by JesperMP View Post
The more I think of it, it is clear (to me at least) that you are doing it the wrong way around.
What is wrong about that?
Since I clear temporary memory of executing block at the beggining I have never had problems with it.

I had such cases, that when at the beginning of blocks temporary memory was not cleared, strange things happened.
I have to look for what these cases were. It was quite a long time ago and since then I have started to clear the temporary's at the beginning of blocks
  Reply With Quote
Old January 17th, 2018, 10:34 AM   #13
m_turk
Member
Croatia

m_turk is offline
 
Join Date: Jan 2008
Location: ZG
Posts: 173
Quote:
Originally Posted by JesperMP View Post
Man, like I said before, it is a well-established doctrine, that TEMPs must be initialized as the first thing in a block before reading. If you adhere to this, there is absolutely no need to "clear" the temporary memory when exiting a block. I have never heard of anyone else doing like that.
I must say, today with this thread and the one with ENO in FB/FC i second guessed my knowledge with S7 programming. These two are so weird questions I did not think of one reason or problem where one would need that.

For me it is not "You have to use local variables by initializing them first", it is why would you use a local variable if you are not initializing them first? And how? I'd really like to know, am I missing something?

edit: @mk Please do, I really would like to know.

Last edited by m_turk; January 17th, 2018 at 10:37 AM.
  Reply With Quote
Old January 17th, 2018, 12:09 PM   #14
Bratt
Lifetime Supporting Member
Sweden

Bratt is offline
 
Join Date: Nov 2003
Location: West Sweden
Posts: 669
Quote:
Originally Posted by L D[AR2,P#0.0] View Post
Following testing in PLCSIM:

For blocks with optimised access, the temp area is cleared at the start of block execution and also cleared when the block completes.

For blocks without optimised access, the temp area is not cleared.
I can back this up i have read that in a Siemens document somewhere. I will see if i can find the document again.
  Reply With Quote
Old January 17th, 2018, 12:27 PM   #15
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,531
Yes, I remember reading it as well but couldn't find out where.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Unity Pro XL DTM Browser Issues 00sas00 LIVE PLC Questions And Answers 10 October 29th, 2012 05:56 PM
Need help with SCL REPEAT structure chauvinhloi LIVE PLC Questions And Answers 4 May 31st, 2012 07:30 AM
[Beckhoff] Declaration of structure to address Bridelance LIVE PLC Questions And Answers 6 January 28th, 2012 03:16 PM
S7 any pointer using struct in TEMP area dahnuguy LIVE PLC Questions And Answers 31 May 31st, 2011 11:43 AM
installing a panelview 600 + rjmarinaro LIVE PLC Questions And Answers 10 June 17th, 2008 11:52 AM


All times are GMT -5. The time now is 10:33 AM.


.