NI VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Using global variables in a custom device

Solved!
Go to solution

Hi everyone,

 

I am having trouble with passing data through my custom device using global variables. I would like to allow a user select a RIO device address while configuring the system definition file. This would be stored into a global variable using the Main Page VI. I would later use this RIO device address in the RT Driver to deploy a bitfile. I can hardcode it, but it is much more convenient to use a global.

 

When I try to store the address in the global variable, it updates the value temporarily (I have confirmed that the event structure recognizes the value change). When I click off the node in the system definition tree that is linked to the Main Page VI, and then click back onto it, the Main Page VI runs again. I wrote the code to repopulate the RIO device address with the value last stored in the global variable, but it is blank. I included the global variables VI in my build, so I can't think of why it might reset that value.

 

 

Any help would be much appreciated!

 

Thanks,

Mitch

0 Kudos
Message 1 of 8
(1,823 Views)
Solution
Accepted by topic author MitchD319
08-24-2016 05:52 AM

Have you tried using custom device properties to store this value instead of GVs?

In Configuration VI you can set this property and if I am not wrong, you can read these properties in RT Driver function.

Vuk Obradović
Senior R&D Engineer at Forsteh d.o.o.
Message 2 of 8
(1,795 Views)

That worked, thanks! For some reason, I thought that you could only pass properties for channels, and I wanted to avoid having to make a channel for the device address.

 

I would still like to know why globals don't work though out of curiosity. Do you know why?

0 Kudos
Message 3 of 8
(1,782 Views)

I am not completely sure but i think I can answer that:

You see, Configuration VIs are run on Host PC where you configure System definition file and so on, so they are run as part of that Configuration LLB on PC. RT Driver executes as part of Execution LLB on RT target, so these two LLBs run on different targets under different libraries. Therefore you can only use global variables to share data between configuration VIs OR share data between RT Driver VIs. 

Vuk Obradović
Senior R&D Engineer at Forsteh d.o.o.
0 Kudos
Message 4 of 8
(1,772 Views)

I include the global VI in building both the configuration and engine libraries, but it would make sense why the data would not be passed between them. However, it doesn't explain why I lose the data when setting up the system definition, because that only uses the configuration LLB.

0 Kudos
Message 5 of 8
(1,759 Views)
Solution
Accepted by topic author MitchD319
08-24-2016 07:21 AM

To answer your follow-up question, the VIs in your custom device are dynamically called by VeriStand.  Once you click away from the page, these VIs are being unloaded from memory, which is probably also removing your global VI from memory, since your VI was the only thing referencing it.  So when you go back to the page, your page VI is re-run and the global will take on its default value.

0 Kudos
Message 6 of 8
(1,749 Views)

Thanks, Devin! So in order to use global variables, it sounds like I would have to programmatically set the default values of the controls on the front panel? It will probably be easier to avoid them.

0 Kudos
Message 7 of 8
(1,742 Views)

Yeah, globals aren't really going to work in custom devices, so you should stick with the set/get property subVIs.  Those are really the only way to guarantee persistant data in your custom device.

0 Kudos
Message 8 of 8
(1,737 Views)