Hi all, first time using LabView in many years. I am trying to write a VI that will acquire data from our cDAQ (right now just trying to get it to work with a single thermocouple in a NI 9211, but eventually will be 8 X thermocouple, 4 X pressure transducer), display it in realtime on a plot, and then when the acquisition is stopped, output the data to a file for later use. I am currently using the Base LabView package.
My problem (as I remember it was 7 years ago when I last used this) is with the data types not working together. This is my thought process currently on building this VI. Everything is inside a While Loop with the Wait function at 1000ms.
- Acquire a point of data using the DAQ assistant
- Send that point of data into a bundle
- Send the iteration count into the same bundle (as a timestamp)
- Send the resulting cluster of 2 elements into a Build Array function
- Send the resulting 1D array to a shift register in the While Loop, as well as to an XY graph for realtime plotting
- Wire the incoming point on the shift register back into the Build Array function
In my mind, this allows the XY graph to plot the complete array every iteration, giving a realtime view of the signal. Everything works fine up to this point. My problems are:
When I stop and restart the program, the shift register is not cleared, so the existing data in the array remains on the graph. I know I need to initialize the shift register to clear it, but I cannot figure out what to wire to it that will be compatible with the data type (I just get broken wires with everything I tried).
Similarly, I cannot figure out how to output this data to a spreadsheet after I Stop the While Loop. I think I should wire the "Write to Spreadsheet File" VI to the outgoing shift register, but again, I can't get compatibility with data types (source is a 1D array of cluster of 2 elements).
I have attached my current program "Production" to this post.
I look forward to the help!
I would suggest you change your architecture. First, to answer your questions:
1. In order to ensure that your shift register is not reading the last value from it's memory location, you just need to create a constant for the shift register. To do this, right-click at the input of the 'left-placed' shift register and create a constant.
2. The Write to Spreadsheet is expecting a 1-d or 2-d array while you are wiring a Dynamic Data Type. Use the Convert from Dynamic Data Type to convert the data into the appropriate waveform after which you can get the waveform attributes which includes the values and the timestamp data. Or, you can use the Write to Measurement File to write to a .lvm file which can be opened in Excel as well.
Changes to your architecture:
Since you are using a lot of channels, I would advise you use a producer/consumer architecture. You can have a look at this architecture by navigating to File -> New.. and searching for the Producer/Consumer template. You will notice that this architecture uses queues. The way you will design your VI is to use DAQ to acquire the data into your producer loop, convert this data into a waveform and then send this data to the consumer loop via queues. In your consumer loop, you can write this data to a file. At this point, I would encourage you to write to a binary file instead of a spreadsheet file. The write will happen faster and you will be using less space on your hard disk when compared to ASCII writes.
I know this can be real confusing for a beginner, so be sure to post back if you have any questions.
First you just creat a constant at the input of the shift register which is connected to the second node of the build array.