S7: UDT as input parameter

Jobbe

Member
Join Date
Jul 2005
Location
Antwerp
Posts
159
Hi,


I would like to use a UDT as an input parameter for a function (FC). The UDT is exactly 1 word in size but I can’t seem to link it to the function as a word. I also tried a pointer notation but that doesn’t seem to work either. Could someone help me with this?

Oh, the UDT’s are all in a DB if that should have anything to do with it.



Thx,

Jobbe
 
Hi Jobbe,

What address are you using and is the input parameter into the FC the sane as the db address. IE word/word or int/int
 
dmark88 said:
Hi Jobbe,

What address are you using and is the input parameter into the FC the sane as the db address. IE word/word or int/int

I want to use words from a DB as the input for a function. Every word in the DB is defined as a UDT. The input for the function is defined as the same UDT.
I tried to use DB1.DBW4 as input, but that results in the error "invalid parameter in the call".
 
Something like this you're looking for?


UDT1

test INT 0
bit BOOL FALSE

FC1

IN
status UDT1

DB1

temp ARRAY[1..10]
UDT1

OB1

call FC1
status:=P#DB1.DBX0.0

call FC1
status:=P#DB1.DBX4.0



HTH

WestVloamse Complimenten :)
 
Flukie,

Thx for the answer, this works. But is it also possible to do it without using an array?
I would like to give each element it's own symbolic name.


Aantwaarpse groeten
icon7.gif
 
All right, I guess someone has to ask ...
Why do you need to use a UDT (user-defined data type) for a data type (word) that isn't user-defined?

What's wrong with just having a DB named "Store" with word elements of 'Word01', 'Word02' etc and the calling the FC with a word input parameter as FC1 (Input := "Store".Word01) etc...?

If you do wish to use a UDT then this should follow exactly the same mechanism. Create the DB, create the elements defined as UDT1, not as words, and then call the FC, this time with a parameter type of UDT1, and exactly the same technique should work ...

Can't think of anything else at this stage.

Ken
 
Even though the UDT is one word long, it could be made up of 16 bits or a byte and 8 bits. A word of warning though, referencing a UDT variable within an FC will require extra processing compared to using a simple variable passed to the FC. (Each reference to the variable requires the pointer to be examined for the area it references, the correct DB opened, and the area pointer loaded into AR1 before the variable is finally accessed.)
 
The UDT ain't one word, but 16 bits like Simon said. I need to use them because they already exist in a DB from a standard function. I could also make an input for the FC that is defined as a word, but then I will lose all the symbolic names for the bits in that word. Unless there is another solution?
 
Why not use 16 boolean parameters for your FC ? You could use IN's, OUT's and INOUT's according to the use of your variables. If you call the block using STL instead of ladder you will not add the overhead of assigning the IN's to local data before calling the block. How many calls to the block will there be, and what are the chances of the interface changing as your project develops ?
 
I solved the problem :)

The correct format is "P#DB1.DBX0.0", but it can only be linked to the FC-CALL by typing it as the symbolic name (like "DB_UDT".Object1).

Thx everyone

P.S. I still wonder if there is a way to link it as a word and still keep the symbolic names for the bits like they are defined in the UDT.
 
@Simon

I could use 16 bits as normal inputs, but I have arround 40 UDT's I need to use for the FC. And this FC will be called 20 times with different parameters so that would give me 640 inputs. So that wouldn't make it easy to use.
 

Similar Topics

I want to create an AOI to take modbus data and put it together as needed. The data is going to be coming from an RTA gateway and will be 32...
Replies
4
Views
3,563
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
127
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
308
Back
Top Bottom