Jump to content

Plotting real-time data from a sub-VI


Recommended Posts

Hi ! First time posting here. Please pardon my relative newbieness to LabVIEW : I've received little training before beginning this project.

I'll try to explain my problem as clearly as possible. I've isolated all analog port reading-related code in a sub-VI, which stores the read data in an array, which is returned when the reading time is over. The problem is that it will fill my waveform chart only after the sub-VI finished executing, which means that instead of seeing my data in real-time, I get all of it in one shot. Whic is precisely what I do NOT want, heh.

So, how could I get my data from my sub-VI to return my data "one by one" instead of all in one big blob ?

Hope I was clear enough. :( Thanks for your help.

Link to comment

First make sure that that you are using Waveform Charts not Graphs.

Graphs will only accept arrays or special clusters.

Try this code to pull the data out of the subvi.

Download File:post-584-1117597826.llb

I would only do this if the subvi acquiring the data is slow >200 ms per reading.

The reference method is useful for this type of application but it is not recommended

for acquiring data fast.

Link to comment

Hi SolarBear:

The key point is that a Sub-Vi doesn't, through its output terminals, return anything until it completes execution. :nono:

In the same way that the FOR loop in the example Mballa posted doesn't provide any data to the outside until after it completes all 20 iterations.

There are a bunch of ways around this problem. The simplest, perhaps, is to have your sub-vi that collects data collect only one sample, and add it to the display one sample at a time (like data is put into Mballa's "Wave Chart During" indicator.) That is not as efficient, and timing might not be as accurate, as collecting data many samples at the time, but if your sample rate is slow, it is the most straightforward approach.

If life needs to be more complicated, you might collect a few samples each time you call the sub-vi, and add them to the display, or post the data to a Queue, and read it in a separate display loop as it becomes available, or a variety of other more complicated tricks.

NI has nice example vi's for most of their hardware, your best approach might be to check those out, and start with one that you can modify to fit your needs. :thumbup:

Good luck & best Regards, Louis

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.