S7: Good programming practice using static variables

STL???

Member
Join Date
Sep 2005
Location
UK
Posts
879
Hi Guys,
I would apprieciate some advise from the more experienced S7 users with regard to the use of static variables,

I'm looking at a machine program at the moment where static variables are read/written to outside the instance data block they were created in - Would you deem this bad practice or risky?

The strange part is that the FB where the stat is declared, there is no code related to it - whats that about?

Surely a shared datablock would be more suitable?
 
I guess the purists would say that it's definitely bad practice, don't do it, end of story!

I see it a little differently. If I know somebody else is likely to have to modify or update the program, then I'm on the side of the purists and wouldn't do it. However, where I'm pretty sure that nobody else is likely to have make major modifications to the program, then I do do it, because it sometimes makes life easier. Technically there's no problem, IDBs and normal DBs are identical in all other respects.

Where the STAT is declared, but not used in the FB, I can imagine two reasons (there may well be more!).

One possibility is that as the program developed a point was reached where it became sensible to move a part of the program to another block. If the STAT isn't called from anywhere, then they just forgot to delete it after modifying the program.

Another possibility is that the programmer wants to keep a standard format for the data (for display purposes, for example).
 
I do read and write IDB STAT variables outside their FBs.
Absolutely critical is that you use symbolic adress priority, but then I dont see any problem with it at all.
 

Similar Topics

I'm looking for some starter kits but there aren't so many on the market, so I'm thinking about buying individual components for my needs. I just...
Replies
15
Views
2,455
Good Day Friends! I really want to advance in PLC Programming like our guys here in this forum, and I'm Pleading to all friends here to help by...
Replies
5
Views
2,753
hi al.. i am a bigginer to plc programming..ladder logic can anybody pls suggest the best programming practices using in industries..
Replies
21
Views
5,194
Morning folks--I have been programming in RS 5 and 500 for quite a few years. I need to get proficient in navigating in 5000 and I would like to...
Replies
3
Views
1,795
Back
Top Bottom