UDT in declaration S7

Thim

Member
Join Date
Mar 2008
Location
Belgium
Posts
392
Hello folks,

Had a question about S7
I the declaration of a FB i add a UDT
The UDT excist out of a struct
The struct has different variables in it
Now i want to know the adress area of this variables.
Assume that UDT name is A Struct name is B and variable is C then i can load this value by typing

L A.B.C

Normally when i want to know the adressarea i would type

L P##A.B.C

But this doesn't seem to work, someone out there who can help me out with this?

Thx
 
Put the UDT declaration in the IN_OUT area and call it PUMP1
to pass the UDT into the FB it would be
A.B.C (where A is the name of the DB where the struct resides B is the STRUCT name and C is the name of the declared UDT) and D would be a variable in the UDT

But inside the FB to use the variables from the passed UDT it would be
L #PUMP1.D
 
Last edited:
Yes i want the adress area of that variable not the value of that variable
I will add a picture from what i want
 
What I have done in the past is create a TEMP of the same UDT, then the FB input as a pointer.

Using SFC20 I passed the data into the TEMP area, then use the TEMP area as normal access to UDT's.


At the end if required pass the updated data back in the reverse of the above.
 
Yes i want the adress area of that variable not the value of that variable
I will add a picture from what i want


Sorry just read this bit

as above with a pointer and create an ANY, offsetting the start address and length to the variable you want.

IN: UDT_POINTER

in the block

L P##UDT_POINTER, which gets you to the start of the UDT.
 
Yep that is correct what you say i can determine the Start adress of the UDT.
But if you mean IN:UDT_pointer you mean i have to write P#58.0??
So i have to know it correct ? Or do i understand this wrong
Is there a way that Step7 determines it by it self by adressing it symbolically
If i change the UDT the adress would change also automaticly, or isn't this possible
 
I use this UDT also somewhere else in an array.
Now i code directly

L 58
SLD 3
LAR1
....

If i would ever change this UDT i have to go through the whole code to check everything so i was just checking if there would be a way to determine it
 
No not p#58.0

If your DB is called "DB" and the UDT is withinn the DB called 'UDT10', then at the FB call, put in "DB".UDT10 (NOTE, as I said you have to be in symbolic addressing mode).


In the code you would need a TEMP set up as an ANY and you can then use the pointer inputted as material to build the ANY.

That will be pointing to the start address, so you would then need to offset your start address to the word you want.
 
The TEMP UDT maybe the best solution, if you push it into the TEMP area, if you change the UDT you would need to update the TEMP area, but the code would still be OK if its accessing the data symbolically.
 
Use the following FC to achieve the functionality of

L P#A.B.C

If you don't need the DB, remove it from the FC interface.

Code:
FUNCTION FC 2 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  pData : POINTER ; 
END_VAR
VAR_OUTPUT
  dwArea : DWORD ; 
  iDB : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =
      L     P##pData; 
      LAR1  ; 
      L     W [AR1,P#0.0]; 
      T     #iDB; 
      L     D [AR1,P#2.0]; 
      T     #dwArea; 
      SET   ; 
      SAVE  ; 
END_FUNCTION

Example call in use:

fc2009008.JPG
 

Similar Topics

Afternoon all, I'm working on setting up a large excel recipe table for porting updates through the Linx Gateway RTD/DDE function into my recipe...
Replies
2
Views
110
I am trying to copy an array of real numbers into a UDT with a real data type element. I have attached a snip below showing my COP instruction...
Replies
4
Views
203
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
Does anybody have any samples of how to "Create and Use" UDT's in CCW Developer Edition? (I am using v22) I can't find any information from...
Replies
3
Views
312
Hello, I have been looking for a reference for the order that a UDT is copied in the COP instruction. More specifically - I have a set of code...
Replies
5
Views
548
Back
Top Bottom