11/3/2011 9:35 AM | |
Posts: 241 Rating: (7) |
Dear CP, I think you have your answer in the question youasked. Find the attachement. You can create your FC with UDT1 data type. Then when you call the FC just supply the corresponding UDT1 structure to that. Then you actually don't need any pointer to access the DB data in that structure. **But remember, this way the size of S7 Program (Work & load memory) will increase beyond necessary. Other way is to use pointer as input of the FC, then Calculate the address of the DB parameter you need inside FC. This is smart way to do. Some people even copy required data from Db using pointer into Temporaty Structure matched with DB structure, and then use those temporary symbol inside FC logic. Hope you have your answer. AttachmentMy Pictures.zip (62 Downloads) |
11/3/2011 10:40 AM | |
Posts: 30 Rating: (0) |
Thanks KayBee, I am already at that point. The problem is, Inside the FC, I would like to know which instance of the UDT it is within the actual DB |
11/3/2011 12:01 PM | |
Joined: 10/7/2005 Last visit: 4/24/2024 Posts: 3004 Rating: (1046)
|
Hello Chris.Percival a 6 Byte long Pointer value is stored in the local memory of the calling Block when you assign a UDT as an FC parameter. You can extract thePointers DB number (Byte 0&1 of Pointer, see also Step 7 help for pointer format) as well at its memory area (Byte 2) and addressvalue (Bytes3-5)via the following logic inside the FC: [code]L P##UDT_IN // load Pointers V memory start address into accu1 LAR1 // put it into AR1 L W [AR1,P#0.0] // loadDB number of UDTPointer into accu1 T #_DB_number // store in INT TEMP variable of FC L D [AR1,P#2.0] // load Memory area and AddressofUDT Pointer into accu1 T #_Memory_area_and_Address // store in DWORDTEMP variable of FC [/code] I hope this helps |
Cheers |
|