Step7: Acquiring the adresspointer of an FB-output

Bakkei

Member
Join Date
May 2006
Location
Arnhem
Posts
63
Hi guys,

don't ask me why but I'd like to acquire the adresspointer of an output of a multiple instance FB. For example if I've got an FB like this:


xxx+----------+
xxx|XXXFB50xxx|
xxx+----------+
---|ENxxxxOutp|--Q100.7
xxx|xxxxxxxxxx|
xxx|xxxxxxxxxx|
---|Inpxxxxxxx|
xxx+----------+



Now I need INSIDE the call of FB 50 the pointer to Q100.7
Is this possible, and if so how?
 
Last edited:
I think it goes something like this:

Code:
TAR2		 // get the start address of the instance DB 
LAR1 P##Outp	 // get the address of output inside the instance DB
+AR1		 // add both adress registers
 
Sparkz said:
I think it goes something like this:

Code:
  TAR2		 // get the start address of the instance DB 
  LAR1 P##Outp	 // get the address of output inside the instance DB
  +AR1		 // add both adress registers

Thanks, but that's not what I meant. Your solution gives me the pointer to the adress within the instance DB. I need the pointer to Q100.7 itself!
 
It's possible. You can use either area-crossing or area-internal pointer defined in FB TEMP section as DWORD (possible in STAT too). Advantage in comparison with AR using is symbol addressing possibility. This looks like

A Var
= Q[pMyOutputBit]
where pMyOutputBit: DWORD. pMyOutputBit in this case is area-internal pointer.
This is simplest method.
 
Unfortunatelly you cannot get pointer to the inputs and outputs in the FB's. S7 always returns pointer to data in the instance DB. If you want get phisical address you have to transfer it to FB via pointer and create additional DWORD variable as Gambrinus pointed.
 
gregoryg said:
Unfortunatelly you cannot get pointer to the inputs and outputs in the FB's. S7 always returns pointer to data in the instance DB. If you want get phisical address you have to transfer it to FB via pointer and create additional DWORD variable as Gambrinus pointed.

Too bad, but that's what I allready expected. I just asked to be sure.

Can it be a solution to connect the output to an in/out on the FB?
 
If you connect the output to in/out (BOOL) of FB you will get the same results. With in/out parameters of type STRUCT there is a pointer transferred to the FB.
 
gregoryg said:
If you connect the output to in/out (BOOL) of FB you will get the same results. With in/out parameters of type STRUCT there is a pointer transferred to the FB.

Aha, that's the difference. Oh well: No Mr. Smartypants here then, I'll just need to do a whole lot of typing. *cranks up the music*
 
Here's an example FB that uses a pointer input parameter to control a Q output. You use bQ inside the block as if it is the Q you are pointing to.

Code:
FUNCTION_BLOCK FB 1
TITLE =
VERSION : 0.1

VAR_INPUT
  pQ : POINTER ; 
END_VAR
VAR_TEMP
  dwQptr : DWORD ; 
  bQ : BOOL ; 
END_VAR
BEGIN
NETWORK
TITLE =get Q address from pointer parameter
	  LAR1  AR2; 
	  L	 P##pQ; 
	  +AR1  ; 
	  L	 DID [AR1,P#2.0]; 
	  T	 #dwQptr; 
NETWORK
TITLE =load Q value to get current value

	  A	 Q [#dwQptr]; 
	  =	 #bQ; 
NETWORK
TITLE =Rest of the code
 

NETWORK
TITLE =output Q value
	  A	 #bQ; 
	  =	 Q [#dwQptr]; 
END_FUNCTION_BLOCK
 

Similar Topics

This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
142
When you download a DB, the values get overwritten by what is in the "actual" column in offline DB. Does this happen at the start of the PLC...
Replies
6
Views
142
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
128
Hi all, I am trying to convert RSLogix 5000 program to Step7. I need to bit shift left my array of double integers for tracking the product on...
Replies
2
Views
519
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
533
Back
Top Bottom