LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW FPGA: IO, code reusability and LVOOP

Solved!
Go to solution

Hi everyone,

 

I’ve been working on an FPGA project on a cRIO for a while now.  For the initial prototype we decided to go for an object-oriented approach to leverage code re-usability in the future. In this prototype the FPGA IO was hard coded in the class methods, for example:

 

Barrier_0-1686149150464.png

 

Now I want to modify this prototype to reuse the code over multiple instances of the device connected to the cRIO.

The devices are all connected to the same module types, but over multiple modules and multiple devices to 1 module.

 

My idea was to create some empty FPGA I/O name controls as attributes to the class and assign the right IO channels:

Barrier_1-1686149150468.png

 

 

Initially I though this approach worked well. I was able to create the main VI where I make multiple instances of the class and assign different IO for each instance of the devices.

Barrier_2-1686149150469.png

 

 

Now I want to continuously read the data but when I place a while loop around the read VI I get an error when I configure the shift registers: “Shift Register: Possibility of Dynamic Refnum not supported for current target”:

Barrier_3-1686149150474.png

 

The objective is not to dynamically switch the IO but configure It once per device at the beginning of the program.

Does anybody have an idea on how to approach this issue?

 

0 Kudos
Message 1 of 4
(891 Views)
Solution
Accepted by topic author Barrier

Hi,

 

IO references going through a shift register are automatically considered "dynamic" by the compiler because it might change from one iteration to the other, even if you don't actually change them in the loop. This is simply due to the compiler not being smart enough (I guess because it would be very complex to implement and impact the editor's performance).

 

There is a similar situation with auto-indexing in a ForLoop: https://forums.ni.com/t5/LabVIEW/FPGA-Array-of-I-O-References/td-p/2090974

 

2 options I would suggest:

1. Replace the shift register with a plain tunnel;

2. Or take the IO references out of the class and input them in the Read directly.

 

Regards,

Raphaël.

Message 2 of 4
(876 Views)
Solution
Accepted by topic author Barrier

@raphschru wrote:

Hi,

 

IO references going through a shift register are automatically considered "dynamic" by the compiler because it might change from one iteration to the other, even if you don't actually change them in the loop. This is simply due to the compiler not being smart enough (I guess because it would be very complex to implement and impact the editor's performance).

 

There is a similar situation with auto-indexing in a ForLoop: https://forums.ni.com/t5/LabVIEW/FPGA-Array-of-I-O-References/td-p/2090974

 

2 options I would suggest:

1. Replace the shift register with a plain tunnel;

2. Or take the IO references out of the class and input them in the Read directly.

 

Regards,

Raphaël.


One way to accomplish getting the IO refs out of the class wire while still allowing them to be changed between implementations is to use inheritance to define them in a dynamic dispatch VI in a way that the compiler will detect as constant.

avogadro5_0-1686157498577.png

So, the IO names are defined by the type of the class wire rather than the value on it. If you create a new IODevice it has a different type and can define a different set of IO, as long as you don't try to switch between them at runtime it should compile.

 

Message 3 of 4
(849 Views)

@raphschru wrote:

Hi,

 

IO references going through a shift register are automatically considered "dynamic" by the compiler because it might change from one iteration to the other, even if you don't actually change them in the loop. This is simply due to the compiler not being smart enough (I guess because it would be very complex to implement and impact the editor's performance).

 

There is a similar situation with auto-indexing in a ForLoop: https://forums.ni.com/t5/LabVIEW/FPGA-Array-of-I-O-References/td-p/2090974

 

2 options I would suggest:

1. Replace the shift register with a plain tunnel;

2. Or take the IO references out of the class and input them in the Read directly.

 

Regards,

Raphaël.


Yes, just get rid of the shift registers. Wire statically.

Message 4 of 4
(826 Views)