Siemens FB, actual DB acccess.

sapoleon

Member
Join Date
Aug 2003
Location
salta, salta
Posts
315
Hi,
a simple question, I don't know if it has a simple answer:

How can I identify in which instance DB I'm working of a certain FB?

To explain a little better, I have a FB, and I want to access a certain value of it, but the value will change according to the instance DB... so, how can I know which value it is?

a second question is,
How can I pass a certain value in an instance DB to a function call in a FB?

I am trying to use SFC17 for generating alarms, and I have a lot of them. We have a CPU315, that will collect from a lot of inputs that came from different machines, and generate the alarms.
What I am making, is a FB that generates the alarms for every machine (10 alarms, like 30 machines). So, I want to make an instance of this FB for every machine, but I have to pass a parameter, that is fixed in the DB, but the DB is changing from machine to machine...

example code:
//associated values

//double integer
L #MachineNo //machine number
L 10000
*D
L 2 //first alarm
+D
T DID 32


CALL "ALARM_SQ"
SIG :=DB406.DBX0.1
ID :=W#16#EEEE
EV_ID :=#EV_ID2
SD :=DB2.DBD32
RET_VAL:=#retvalue2

in DBn.DBD32 I have the machine and error number that I want to pass for an error description.

Is it even possible to do?

thanks

ps, does is has something to do with DI?
 
Last edited:
You can monitor in debug mode and can set the path for monitoring, or I believe the specific IDB to monitor.

The Instance DB is only a Data Block at the end of the day. You can access to read or write data to/from it anywhere in your program.

I rememeber one programmer who called the same FB 5 or 6 times in a row, and all the IN parameters were left blank at the FB calls, he actually put data into these elswhere in the programs, as the IN parameters are part of the IDB, simply by using 'T DBx.DBWy'.
 
Yes, that I understand, but what I need is to access from a FB the actual instance DB that is running for it. Most precisely an actual DWord in the DB.
 
Why are you referring to an absolute address ? - create a variable name (I used diSD) and pass the variable name to SFC17

Code:
//double integer
	  L	 #MachineNo				  //machine number
	  L	 10000
	  *D	
	  L	 2						   //first alarm
	  +D	
	  T	 #diSD

	  CALL  SFC   17
	   SIG	:=DB406.DBX0.1
	   ID	 :=W#16#EEEE
	   EV_ID  :=#EV_ID2
	   SD	 :=#diSD
	   RET_VAL:=#retvalue2
 
well, the truth is that I started working with the examples of Siemens, I didn't even thought of using the variable name.
The variable is already created :)
Thanks.

In any case, how can I reference an absolute address?
I tried the DID, but it doesn't seems to work....

thanks
 
Any data type

Could it be because it is an ANY data type? What happens if you enter P#DIX32.0 Dword 1? Just a thought..
 
Just a thought, if your talking about inside the block you want to know which IDB is currently the DB that is active, i.e. which call your are in.


L DINO

Will load the current open Instance DB number into the accumulator.

Similarily

L DBNO

Does the same for Data Blocks


So for example, if you have called FB200, DB210

Then L DINO inside the FB will transfer 210 into the accumulator.
 
Thanks for the answers.
First of all, like L D[AR2,P#0.0] said, it works wonderful with a variable.

I will try the P#DIX32.0 Dword 1 for recreational purposes....
and it does not work. Its the same as in DID32...

But, when I use P#DIX32.0 DInt 1 instead of DWord, it works perfectly...
Why is that? With DWord, or DID, I get in response 457 in the alarm messages. with DInt, or with the variable, I get 30000001, that is the number I am generating for the alarm text? and it does not mater if I ask the alarm text configuration to be DWord or DInt.
Does anyone has a clue on this? For educational curiosity.
 
30000001(decimal) = 1C9C382 (Hex)

If you use a dword for SD (DID32 or P#DIX32 DWORD 1) the processing inside SFC17 has to make a decision about what the DWORD represents, as, by implication it is not a signed double integer. From the results you have posted SFC17 is using the lower 16 bits of the DWORD to generate the message as 1C9(hex)=457(Decimal).

If you specify SD as a DINT (P#DIX32.0 DINT 1) then SFC17 will interpret the data as a signed double integer and give you the result you are expecting.
 

Similar Topics

Siemens Profibus DP Slave properties "StartUp When Expected/actual config. differ"? Hello Everyone, I am configuring IM 153-1 Order number: 6ES7...
Replies
0
Views
1,803
Hello, I am very very new with Siemens S7 and I was wondering how to check the actual memory consumption of the S7 cpu while offline? How do I...
Replies
11
Views
18,803
Hi All, sorry to be a pain, I've re-read all the previous posts, I've tried to read the Siemens FAQ's & manuals, however it has all simply added...
Replies
55
Views
32,200
I have never had the pleasure of working with a "Thermistor" until now and have a question. The Thermistor is a 10KOhm 4-20mA 2-wire device and I...
Replies
0
Views
33
Hello, I have a CPU 317-2DP Firmware Version V2.1.8. In TIA Portal only V2.6 is available, and there is no option to upgrade FW. Then I open it...
Replies
9
Views
163
Back
Top Bottom