05-03-2017 08:42 AM - edited 05-03-2017 08:43 AM
Hello,
I have a FPGA logic that uses 4 DIO pins. The VIs that read or write the DIOs are quite far down in the VI-Call hierarchy:
TopLevel.vi->MainLogic.vi->Sub1.vi...->SubN.vi->VI_that_uses_FPGA_IO_Node.vi
What I want to do now is to copy & paste the MainLogic.vi so it is reused multiple times in the TopLevel.vi.
TopLevel.vi->MainLogic.vi... ->MainLogic.vi... ->MainLogic.vi...
The problem I have is that all instances of the MainLogic.vi use the same DIO pins. What I want is that the first instance of MainLogic should use DIO0-3, the second instance should use DIO4-7 etc.
The DIOs to be used are currently hardcoded in the "VI_that_uses_FPGA_IO_Node.vi".
I see two possibilites to solve this problem:
Any ideas?
Thank you,
Dirk
05-03-2017 09:35 AM
Can you pass the DIO pins to MainLogic.vi from the top level? Something like this:
05-03-2017 09:46 AM
Yes, I think this might work but it is a variation of the first solution that I proposed. I would have to route the wires from the MainLogic.VI down through the entire call hierarchy and that is something I would like to avoid.
Thanks
Dirk
05-03-2017 02:27 PM - edited 05-03-2017 02:31 PM
I would do a variation of this idea, but instead have a cluster / class called something along the lines of "Hardware Configuration" that gets passed down the call stack. Its only one wire then and lets you add or remove items (more I/O, some I/O configuration, timing etc.) without altering a lot of con planes.
Even better, the data for running the digital I/O is contained in a seperate project library / class (take your pick but in this case there is very little overhead in using a class and a lot to gain in terms of enforced encapsulation). The class exposes methods to read or write to the digital I/O and the object is instantiated in your Main.vi with the appropriate confguration of I/O. The object wire is handed down your call stack to your low level VIs which then call the methods on the object (Read, Write etc.). The advantage of this over my previous suggestion is that you can very easily test and re-use this as a component in future projects.