LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert to dynamic slows front pannel display

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?

 

 

0 Kudos
Message 1 of 10
(4,503 Views)

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.

Message Edited by Ravens Fan on 08-02-2009 08:21 PM
0 Kudos
Message 2 of 10
(4,484 Views)

OK!

 

A lot of your code make very little sense, so here are a few guidelines.

 

  1. Don't use a greedy loop to poll for input. It simply consumes all CPU while doing nothing. All polling loops need a small wait. Also why do you invert the button? Just use "stop if true" mode instead for the loop termination.
  2. Same for the main loop. switch to "stop if true" and use a plain OR of error and button. No convoluted logic needed. 😉
  3. Avoid coercions. change your diagram constants to SGL.
  4. Change the "offset" control to SGL, currently it's DBL, coercing all your data to DBL at various places. (look for the red coercion dots! There should't be any).
  5. What determines the loop rate of the DAQ loop?
  6. If speed matters, write to a binary file.
  7. You seem to acquire the same number of points as your chart history. Since there will be no history anyway, why don't you use a graphs instead?
  8. Maybe you only want to chart the mean. or the last point. Would make more sense.
  9. Since there is no deterministic loop timing, your chart X axis is meaningless too.
  10. Get rid of the sequence structure and use a simple state machine. Start out in an idle state and switch to daq mode when the button is pressed.
  11. Your detour over dynamic data makes no sense! Here are a few alternatives.
    1. All-in-one: You could simply right-click the chart and select "visible items...digital display". Now customize the chart so the digital display is a thermometer. No extra code needed! (same for the pressure).
    2. Take the mean of the array and wire it to the thermometer
    3. use index array and display the first or last element in the thermometer.

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?

Message 3 of 10
(4,479 Views)

 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.

0 Kudos
Message 4 of 10
(4,454 Views)

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?

0 Kudos
Message 5 of 10
(4,434 Views)

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! 

0 Kudos
Message 6 of 10
(4,418 Views)

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. 

0 Kudos
Message 7 of 10
(4,403 Views)
I feel like I’m getting somewhere now. The VI now plots pressure as a time history chart, but the two thermocouple charts only show instantaneous temperature. I’ve looked at the settings for the charts and they all seem identical so I don’t know what’s going on.  

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?!

I’ve attached the VI and a screenshot.

Download All
0 Kudos
Message 8 of 10
(4,383 Views)

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 😉

0 Kudos
Message 9 of 10
(4,374 Views)

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.

 

0 Kudos
Message 10 of 10
(4,361 Views)