S7-SCL (on S7-1200): FB number ?

Join Date
Jul 2013
Location
Here
Posts
31
Hey,

is it possible to know, within a program, the number of the FB, or OB, the code is currently executed in?
Like, some function GetCurrentFB(), called from inside FB21, will return 21.
This could be helpful for debugging, e.g. I could store somewhere which FB did something. Using hard-coded numbers is not change proof.
Sure, *if* a consistent numbering scheme is used throughout a program (independent of FB numbers) and no mistakes are made, changing FB numbers would not be a problem. It would be nice to have something "automatic", though.
 
Here's one possibility - done using Simatic Manager and S7-300. I created DB999 which only contains 1 integer. In your blocks, read DB999.DBW2 which will generate an OB121 fault. In OB121 write the block number to DB999.DBW0
Read the block number from DB999.DBW0

bert.JPG
 
Ah, so this provokes an error which can be handled in OB121 and there you can query which block it was?
Haven't looked into the error handling OBs yet, but from what I found, the 1200 does not support OB121 (1500 does).
S7-1200 only has those diagnostic OBs: Time error interrupt (OB80), Diagnostic error interrupt (OB82).

Anyway, if things get big enough that we use a 1500 for something I'll have this in the back of my head, thanks!
 

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
79
Hello, I am currently forced to use s7-1200 (6ES7214-1AG40-0XB0) PLC for one small project. I do have some experience with S7-300/400 mostly in...
Replies
6
Views
5,095
Hi, I am new to Siemens and SCL. I have a datablock which is a global data block. I want to use some of the values in this DB in a FB block...
Replies
3
Views
3,558
Hi, I only know how to read one bit of e.g. an input port, using e.g. I0.7 or names from the standard table for such a single IO line. Is there...
Replies
11
Views
4,682
Hi Guys! I'm preparing a short training for some colleagues on how to use the S7-1200 CPU and while explaining the 3 different programming...
Replies
2
Views
3,447
Back
Top Bottom