1/21/2011 1:17 AM | |
Joined: 10/7/2005 Last visit: 7/30/2024 Posts: 3012 Rating: (1054)
|
Hard to say dearCornfieldEng you say that you are passing on a "DB", but I doubt that you are using the data type "Block_DB" for this (as it can not be an IN_OUT), so my question is:What data types do you need to tranfer from one FB to another? Attached is a pdf taken from the Step 7 Help that shows youwhat data types can be passed on as IN's/OUT,s/IN_OUT's from FC/FB to FC/FB which may already give you the answers to your questions. If not, please give us some more details and ideally an upload opf your FB's and we can advise you further. I hope this helps AttachmentPermitted Data Types when transferring Parameters.pdf (376 Downloads) |
Cheers |
|
1/21/2011 10:28 AM | |
Joined: 1/20/2011 Last visit: 7/18/2024 Posts: 10 Rating: (0) |
fritz, thanks for the reply, it is strange how a question makes sense to the person who wrote it until somebody else points out that it doesn't make sense at all, so I will try and make more sense this time.
You are right that I am not passing a data type "Block_DB", what I am passing is a UDT that has a structure with a number of BOOL's and some WORD's. I have attached a project will the bits in that are relevant to what I am asking but I will also try and explain again. I have a DB that has a number of structures in it that are all defined by UDT's. The DB is used by a Helmholz CAN master that I am using to transfer the CAN data to and from the master. In my case I have one DB (DB100), called 'CAN_IN',for receiving data from the CAN master and one DB (DB101), called 'CAN_OUT',for sending data to the CAN master. In my software I have written an FB for each section of the machine and I have passed the relevant section of DB101to the FB via the IN_OUT so that I can manipulate what I send out via the CAN master both inside and outside of the FB. So for example I have a 'Master CR' FB with an IN_OUT called Drive_CANOut that is defined by UDT4 and attached to the input of the call for 'Master CR' I will have attached CAN_OUT.Master_CR which is also defined as a UDT4. This has worked very well until I have come to create a section of the machine that I have created with an overall FB, but also two multiinstance FB's within it. I am still passing the CAN data into the overall FB with the IN_OUT but when I then try and pass the data onto the multiinstance FB's as an IN_OUT Step 7 say no. I have looked in the help and it seems that you are not allowed to take an IN_OUT from the overall FB and pass it to contained multiinstance FB's, and from what I can gather it is because the data for an IN_OUT isn't actually copied to the instance DB but a pointer reference is sent. Now I have to confess that whilst I understand that a pointer is a value that represents where the data is stored rather than the data itself I don't really understand anything about how pointers work or can be manipulated/used. The work arround that I have come up with at the moment has me passing the data to the overall FB as an IN, using BLKMOV to copy it to a temp, passing the temp to the contained multiinstance FB as an IN_OUT and then using BLKMOVE again to copy the temp to an OUT on the overall FB. When calling the overall FB I am passing my section of the DB101 to the IN and the OUT of the overall FB. I hope that has cleared it up a bit but I have attached the section of the project and hope that you will be able to assist me. Many thanks Chris AttachmentInout_pr.zip (86 Downloads) |
1/21/2011 11:51 AM | |
Joined: 10/7/2005 Last visit: 7/30/2024 Posts: 3012 Rating: (1054)
|
Hello againCornfieldEng to start with, very nice and detailed explanation indeed, well done and thanks for that. As for your problem,UDT's are so called "Complex" Data types and - as you already know - can NOT be transfered IN_OUT -> IN_OUT from one FB to another. Apart from the work around that youhave come up with (using BLKMOV and TEMP's) I could only suggest a few other work arounds: 1.) The somewhat obvious one: Ditch the Multi-Instance calledFB 14 & 15 and instead embeed their logic inside the main FB13. 2.) In case you will call FB13 only once in your program (i.e. no need for re-useability of FB13): Get rid of all IN's, OUT,s and IN_OUT's for FB13 and use the (UDT) DB variables variables directly inside FB13. FB 14 & 15 can now have them directly assigned as IN_OUT's to their calls (should you NOT need FB14 & 15 elsewhere in your program, get rid of their call Parameters too). 3.) While I haven't checked access to all variables of every UDT, FB14 (called inside FB13) does for example only do Write access to only a few of the variables that are part of itsIN_OUT UDT. As such, you could get rid of transferring the UDT to FB14 and instead create half a dozen or so "elementary" data types and declarethe required (actually used) individual elements of UDT as OUT Parameters ofFB14 Last but not least, I'm not the biggest "fan" of transferring complex data types in and out of FC's/FB's as it is quite memory and runtime consuming and you can read more about the reasons this HERE. I hope this helps |
Cheers |
|
This contribution was helpful to1 thankful Users |
Follow us on