08-02-2009 12:12 PM
I'm fairly new to labview so I'm having a bit of trouble getting my VI to work properly. I'm trying to acquire 3 channels of data continuously from my DAQ card and display it to the screen whilst also saving to a file at the same time. When I run the Vi the front pannel runs increadibly slowly. I've tracked it down to the use of convert to dynamic data prior to sending the data to the indicators and the write labview measurements file. Is there a better method of implementing what I am trying to do that will enable both a live display and write to file?
08-02-2009 07:17 PM - edited 08-02-2009 07:21 PM
Why are you converting to dynamic data at all? Worse when you do convert to it, you are using split signal to get a single signal when it has only one in it to begin with.
If you have an array, you can use the Index Array function to get the first element to send to the numeric scalar indicators.
In the first frame of your sequence structure, put a wait statement in that loop perhaps with 100 milliseconds. You don't need to use all available cycles of the CPU to determine when the start button has been pressed. If you change the loop's terminal to Stop when True instead of Continue While True, you can get rid of the Not! function coming out of the Start button.
08-02-2009 07:40 PM
OK!
A lot of your code make very little sense, so here are a few guidelines.
In summary, apply one of the suggestions of point 7 and see if things improve. Good luck! For more detailed help, tell us a bit more what you are actually trying to do. Where does the data come from? How does the raw data look like? How fast do you need to go?
08-03-2009 04:42 AM
Thanks both for your advice. The VI is adapted from one that shipped with my DAQ card, so the loops and stop/start button logic were not my doing (honest!).
The aim of the VI is to continuously acquire 4 channels of data from a PCI DAQ card (Amplicon) at 1 KHz and plot the history to the screen whilst saving to a file at the same time. I forgot to mention I want the chart history to be plotted. The raw data comes out in volts, so it needs converting to engineering units before the charts/saving. Now, I will be recording data for long periods of time (up to 30 mins) so I think I may have to reduce the number of samples that are sent to the graphs. Will I need a buffer for the chart history?
Again, any help will be greatly appreciated.
08-03-2009 08:36 AM
David _B wrote:Thanks both for your advice. The VI is adapted from one that shipped with my DAQ card, so the loops and stop/start button logic were not my doing (honest!).
No, I believe you. It means that these VIs are very old. Early (very early!) versions of LabVIEW did not have "stop if true". 🙂
I don't have any DAQ installed, so I cannot tell what you are actually doing. How big are the arrays at each iteration? What is the loop rate?
08-03-2009 03:49 PM
Ok, here's where I probably get really confused! Just for reference I've attached an image of the VI so that you can see what the sub VIs are supposed to be doing and to see if they are in the right place. The only bit I have added is the index array and the graphs (everything in the bottom part of the loop).
I’ve tried to implement all the changes you’ve suggested, apart from getting rid of the sequence structure. Which parts of the diagram should I have outside of the while loop? Everything that is currently outside of the loop? I’ve added a wait until next ms into the loop, but I was under the assumption that if the card was set to a scan rate of 1KHz (outside of the main loop) then this would be the rate at which data would be graphed and saved at until the VI is stopped?
I’m not sure how to find the array size per loop iteration so I may need some help here!
The main thing that I need from it is to real-time plot the history of the thermocouple data whilst also saving it so I thought it would be an easy VI to build until I started!
08-03-2009 09:56 PM
OK, it already looks much better. You still have coercions from some of the diagram constants (the orange zero and 4096 near the upper left should probably be blue. Instead of placing diagram constants, simply right-click the desired terminal and do a "create constant" ths will give you the correct type automatically. The "1" going to the wait should be U32). Try to avoid all these backwards wires, they are bad form and confusing.
Place an "array size" at one of the wires going to the charts and create an indicator on the output. What does it say when you run the program?
There is no way to tell from the image how your file writing is configured. Are you still creating a new file with each iteration? That seems expensive! Why don't you use lowlevel file IO: open the file outside the loop and write the header, then keep the file open and keep appending new data inside the loop. Close the file once the loop finishes.
08-04-2009 05:06 AM
08-04-2009 06:09 AM
David _B wrote:
The array size is confusing me. It is 4096 (the same length as the circular buffer) if I use a SGL constant, but if I replace it with a ‘create constant’ then the array size is 1?!
Don't use array constants, leave them as scalars! (If you use array constants and only make them size=1 as you did, the result of the operation is size=1 no matter how large the other input is. My "create constant" suggestion only gives the correct datatype, not necessarily the correct size.
You are getting 4096 data points with each iteration, maybe you only want one. Do a "array max", "mean" or whatever you like to reduce each array to a single number. if you send 4096 points to a chart and the chart history is also 4096, you don't keep any history between iterations. Or change the acquisition so you only get one point.
You also might want to set dx the same as your wait time for correct units.
What kind of file format do you want. Don't call a binary file *.txt 😉
08-04-2009 09:48 AM
Right, now all the graphs show time history, but the x-axis units aren't correct. I couldn't find "dx" is it the multiplier for the x axis scaling?
Also another problem, the file size is quite big - a few MB for around 10seconds. I need to run the VI for long periods of time so need to keep the file size down. What format would be best for small file size? Currently I’m sampling at 10KHz, but want to reduce this to 1KHz, but the front panel update is quite delayed when I do this.