From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot the last set of data ( 1000 samples ) in a loop

Solved!
Go to solution

Hi, I continuously read data from a waveform but I would like to capture and plot the last set of data after my stop triggering. As can be seen in the attacehd picture, when the condition is true I acquire data . The number of samples per read is 1000 and as can be seen I have used a shift register to store data. What I would like to see when the loop stops is the last 1000 samples but when I acquire live data I get random number of samples when the loop stops. sometimes 90 samples , sometimes 950 samples etc....could you please let me know how can I get the last 1000 samples acquired  in this loop

I have even used DAQmx buffer to buffer the data but still I can't get the last 1000 samples

 

thanks

0 Kudos
Message 1 of 13
(3,090 Views)

Please post the real VI.  We can't see how you initialize the task nor how you stop the While loop on that screenshot.

0 Kudos
Message 2 of 13
(3,088 Views)

Here you are

There is case structure inside the loop. In true case  just an empty waveform constant is connected

0 Kudos
Message 3 of 13
(3,079 Views)

I don't have LV2012 on this machine.  Can you save for 2011 or wait for someone else to help!

0 Kudos
Message 4 of 13
(3,066 Views)

Sure, please find attached .

Thanks

0 Kudos
Message 5 of 13
(3,061 Views)

A few things to address in your VI:

 1 - Why do you stop executing the VI on an Error and not on a "Done?" from your DAQmx task?

 2 - You read 100 points (or less) at a time so you are never sure how many points go into your buffer.  It is better to have a set number of points and let the Hardware pace your application.  You always get same size arrays that way.

 3 - If you only read 100 points at a time and place them in the shift register, why do you expect more on your graph?  You have to build an array or do somthing else to concatenate your data if you wish to Read the buffer more often but still display more data at the end.  Using a chart inside the while loop would also do that for you (see my example.)

 

On the VI attached, you can easily change the "chart history lenght" to remember as many data points as you wish.

 

0 Kudos
Message 6 of 13
(3,051 Views)

I would also point out to tintin99 that if not only the historical plot but the individual data points in it are important, they can be pulled out of the History property node from the Waveform Chart.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 7 of 13
(3,042 Views)

Thanks for the attached file. Your vi is much simpler than mine but I still have the previous problem.

Number of samples is not important. I would like to read  the last "n" samples before the stop trigger.

Even using your vi in the last iteration I read a random number ( which is the remaining number of samples in the buffer). Let's use an example

 

Let's say the number of samples per channel is 100 and I read 56 samples in the last iteration. How can I read the last 1000 samples after the stop triggering? I assume I need to use shift register inside the loop and then concaterate samples in every iteration and finally read the last 1000 samples outside of the loop. I used this method but it didn't work for me.

I hope I could explain the problem

0 Kudos
Message 8 of 13
(3,040 Views)
Solution
Accepted by topic author tintin_99

If your task has a set number of points to acquire, I do not see how you could have an un predictable and random number of points in the buffer.  The task should stop after it acquired the "N" points and then say that it is done. 

 

What do you mean by "Stop Triggering"?  You only have a "start trigger" and there are is no points available after the task has competed.  If you want the last 1000 points of the "samples per channel" points,  then the last read should return those.  I have never used the "Done" property before.  Count your samples read instead and stop once you've got what you wanted.

0 Kudos
Message 9 of 13
(3,027 Views)

Got it now, thanks

Just a quick question, if I put the waveform graph ouside of the loop I can only see the last set of data. How can I store the whole data waveform and observe it from start to stop ?

Do I nee dto use build array with shift register to append to the waveform in every iteration? 

0 Kudos
Message 10 of 13
(2,993 Views)