LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advice about application structure before starting

Hi all,

I am so sorry for this longest post, but I have to explain all thing. Sorry again.

I have been studying with Labview for a year by myself without taking any professional support. When I get stuck in preparing my VIs, I always post here and you answered me with great patient. Thank you for all. Now, I am about to start a new VI and before starting it I thought it would be good to consult you on that.

 

The goal of this VI could be classified under 4 main topics: Acquisition, control, analysis, and recording the data. I am studying on a test system. There are two types of data to be acquired from the test system: pressure and temperature. For this purpose I have 1xNI 9203 (analog input-current) & 2xN9214(analog input-temperature). The test system is desired to be under control by use of a DC compressor with a frequency converter. To control that frequency converter I have to use NI 9263 (analog output- voltage). All hardware system is installed on NI 9188 cDAQ.

 

Before preparition of this system, I have coded a VI that acquire, analyse, and record the data-there is no use of NI 9263 (attached here). In this VI, I used a basic structure and it works fine. The only problem of this VI is delaying when the stop button is pressed. Anyway, now I want to prepare a new one. The difference of the new VI from the old one is that it controls the system while acquiring, analysing, and recording processes. And this control is supported by acquired pressure and temperature values. This will be my first big project and I need your suggesttions on structure of this VI. Do I start to build it with state machine architect or another ones? To prevent the data loss what kind of precautions could be taken?

 

Thank you all in advance.

Egemen
0 Kudos
Message 1 of 4
(2,272 Views)

Egemen,

 

First, Great! It is very important to plan and design your program before starting to write it.

 

Next, you do not need to apologize for providing the information necessary for someone to respond to your request. We would very much prefer a post of several paragraphs which contains the relevant information to a brief post which only elicits questions for more details.

 

Now to your questions.

 

1. Look at the style guides.  Your block diagram was several screens high and wide.  It is recommended to keep the diagram to one screen.  Paticularly in programs which will get large and copmlicated like yours, this readability constraint will be very worthwhile.  Effective use of subVIs is one way to help minimize screen bloat.

 

2.  Look at the style guides. The use of local variables to pass data from one loop to a parallel loop is not recommended.  It can lead to race conditions, force execution of the loops in the UI thread, and is slower than wires.

 

3. Read the help on Event Structures. Only one event structure per VI is recommended. Although the way you have used them will probably work, it consumes hectares of block diagram space and may be vulnerable to problems when you or another developer decides to make a few changes.

 

4. Because there is no data dependency, it is possible (although not very likely) that the main loop could start running before the clear history property nodes execute.

 

5. How do your temperature charts know which waveform to display?

 

6. You stop on DAQ errors but do not check for file errors. You may want to consider more robust error handling.

 

Now, some general comments on program structure. You list 4 topics: Acquisition, control, analysis, and recording the data.  This may also be a good way to think about program structure. The structure probably needs one more topic: User Interface.  The program you posted essentially has 2 topics: User Inputs and everything else.  Think about the timing requirements for each topic.  User interface - needs to respond to user inputs in about 100 ms or the user begins to feel as though the program is not responding. Similarly, displays do not need to update more than a few times per second. Acquisition - Software timed.  Default value = 1.67 Hz. Output not specified, but since you are talking pressure and temperature, it is probably slow also. Once you start doing closed loop control, it may become more important to keep the timing constant. Record data - same timing as acquisition.  However, writing 8-64 channels of data two two files twice per second may not be optimum. And what happens when the OS finds that the files are fragmented and must allocate new sapce for the file and takes more than half a second to do so?  Analysis - Your subVIs were not included so I have no idea what they do, how fast they may be and what effects they may have on the overall operation.

 

What I suggest is that you study the Producer/Consumer Design Patterns and State Machines.  I think you may end up with 3 or 4 parallel loops. One will be the User Interface loop with the only event structure. Another will handle all the data acquisition (possibly including outputs when controlling your test system). This will be a state machine which initializes the DAQ, Reads and Writes, and shuts it down when finished. The File writes may be in a separate loop. If file I/O is put into a parallel loop, it should be a state machine which opens, writes, and closes the files and retains the file path or reference for repeated writes. The control and analysis (another state machine) may be in a separate loop or could run in the timeout case of the event structure in the UI loop.  Which is best depends on details of your system.

 

With the amount of data you are moving around and the number of property nodes you need to use, learn to manipulate the front panel from a subVI. Search the Forum for posts on use of control references and on updating the main front panel from a subVI. There are some good methods posted.

 

Lynn

0 Kudos
Message 2 of 4
(2,247 Views)

Hi Lynn,

 

In waveform charts, all data comes from the read daqmx function are included. By use of event structure and boolean arrays manipulation of these charts is given to the user. Hence, by pressing and activating the boolean array elements, corresponding waveform channel is shown. For temperature channels there is no need to scale but for other channels (from NI 9203-analog current output) are required. I did it like below. The selection of open waveforms is under controıl of user again by use of event structure and boolean array.

 

Actually, I do not understand what exactly you mean by controling UI from a subVI. Could you open it a little? Did you mean working with sub panels or something like that?

 

Egemen
0 Kudos
Message 3 of 4
(2,228 Views)

Egemen,

 

To control the UI from a subVI you pass a reference of the main VI to the subVI as an input. In the subVI that reference is used to get references of all the controls and indicators. Connect those references to property nodes to make the changes.

 

This can get rather complicated although not particularly difficult.  Putting it in a subVI means that the UI can be controlled from the place where it is logical to do rather than where the control terminals are. In many cases this is not required, but as the UI gets abstracted from the analysis and control, sometimes it is the best way.

 

There are some good threads on the Forum and I think a Nugget or two on the topic.  Those contain many details and some examples.

 

Lynn

0 Kudos
Message 4 of 4
(2,196 Views)