A Better Way to Access Variables in Complex Programs in LabVIEW
In some LabVIEW programs, we need to access the value of a variable which is inside a loop from outside before the loop is over.
Most of us will use a local variable of a indicator to do this job. But this is not a good way to do this job. For example, if you use multiple locals in multiple places all linked to the same indicator, it’ll make it very easy to lose your control of the timing of the data. And in a worse condition, if you write the local variable in multiple places in your program, it will make a nightmare for sure. SO, it’s worthy to note that try not to use local variables unless absolutely necessary.
The best way to do this, I get so far, is passing data through a queue which will adds some kind of complexity, but you will have the full control of the data especially in a much complex program which has a lot of loops and much demands of data timing.
A Note about DAQ Assistant and 200279 Error in LabVIEW
Just a few days ago, I created a simple LabVIEW program which read about 32 channels at 2KHz and display the data and write the data into file. The program is quite simple, so I used DAQ Assistant and Measurement File Express VI to read and write the data in one loop as the following graph shows:
Change Windows XP Environmental Variables in LabVIEW
The Windows XP’s environmental variables can be changed in Windows’ control panel. And if you want to change these variables in LabVIEW, you can use the System Exec function and the command “path=dir1; dir2; dir3” together to realize it.
Using “cmd/c path=dir1;dir2;dir3” as the input parameter to System Exec function in your LabVIEW program will change the Windows XP environmental variables. In fact, you can execute all commands of Windows in System Exec function in LabVIEW.
Make Artificial Data Dependency in LabVIEW
Sometime, we need the data flow in LabVIEW not to be naturally. In this case we can use sequences structure or artificial data dependency to realize it.
But, usually a single frame sequence with an error wire or other data wire is sufficient. A multiple case sequence structure is not needed. If you use artificial data dependency in LabVIEW, my advice is to add a note to the diagram to explain why the unused signal is there. Otherwise someone may remove it in the future because it appeared to be unnecessary and so the data dependency will be missing. And it’s a good idea to create a subVI for the portion of the code which has not a natural data dependency and add error clusters in the subVI. Then the subVI allows the data dependency and may have the bonus of reducing the space on the diagram.
How to Change Axis Name of Graph Control in LabWindows/CVI
We can use the SetCtrlAttribute function to change an Axis name programmatically in LabWindows/CVI. Just set the ATTR_XNAME or ATTR_YNAME attribute to any name you’d like to use in this function.
For example, change the top X-Axis name of a graph, we can use the following code.
// Make the top x-axis the active one SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_ACTIVE_XAXIS, VAL_TOP_XAXIS); // Set the name SetCtrlAttribute (panel, PANEL_GRAPH, ATTR_XNAME, "Axis Changed");
A Few Documents about Communication between Real-time and Host PC
I have to admit that NI’s support is very helpful. Because I need to make real-time machine to communicate with Windows based desktop PC in my recent project, I try to find a few tips in NI’s website, and I get everything I need about this problem.
The following are the documents about RT communication. Maybe I’ll need them later.
Real-Time VI to Host VI Communication Methods