LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to show all data acquired after trigger in a graph or chart

Hi all

I have a DAQ card 6036E from which I am acquiring data. The sample rate is 96Khz and the samples per iteration is 10000
I have set a trigger level to write the data after the trigger is met for certain amount of seconds say 5 secs
When the trigger is met it starts to write the data to a binary file, and shows on a graph what data it is writing, but it is in chunks of 10000 data points.
I need a way to show all the  data for 5 secs which will be 96000 x 5 sec in a graph or chart.
I tried to use a chart but I was not successfull as the program would hang because of too many data points.
What is way around to show all the data points in a chart.

Regards,
Nitin
0 Kudos
Message 1 of 8
(4,384 Views)
Hi Nitin,
 
First, a screen capture of what you're doing would be helpful.  Secondly, why do you need to plot 480k pts on a single plot?  There are only so many pixels on your screen to visualize your data.  Perhaps, you will zoom in on particular regions to justify plotting that many data points and there are other ways to do this more efficiently.   Anyways, it sounds like you're daq is reading 10k pts/iteration and this is going straight to your graph.  This will only plot 10k pts each iteration unless you are storing the data from previous iterations. If you aren't storing previous data points, intialize an array of length 96000*5 outside your loop and wire this to a shift register.  Each loop iteration replace a chunk of this array with the new data starting at the appropriate offset.  If you don't have to plot until after the entire read, just wire the data to the loop border and enable autoindexing.  Use the reshape array function to change the resulting array from 2D to 1D.
 
I don't have much experience with charts but I know they keep a history.  If you don't care about plotting until all the data is read, you could try setting defer front panel updates to true before the loop and then reset back to false after the loop.  That way its not redrawing the chart each time which will take a while with the number of points you are plotting.
 
I think if you post a snippet of your plotting routine it will make more sense to me and maybe i can help out better.
 
regards
drew
Message 2 of 8
(4,377 Views)

Hi Caz

Thanks for replying to my earlier post. We are going on a field where we will be measuring firing of bullets from Helicopter, and we are not sure when it will begin, So we have made a program with trigger level, if above level start to write the data for so many seconds. So once the trigger is met it saves specified pre trigger samples based on seconds and the samples needed after the trigger based on seconds. So the engineer going in the field has asked me that if he can see all the bullets when it is being fired it would be good. He doesnt need another VI to read after it has been written, so thats the reason I need to show all the data points for as many seconds which are prescribed by the user.

I am attaching a screen shot of my VI.

Regards,

Nitin

0 Kudos
Message 3 of 8
(4,363 Views)

Hmm, firing bullets from a helicopter.  A vi named alabama.  Sounds like you are doing some testing at Redstone arsenal.  I've had labview down there before in June and the humidity was just about unbearable.  Although, the shrimp gumbo made up for it.

Okay, I see what you're doing now, sort of.  I have some ideas that might help but I have to also ask a few more questions.

1) Why not just configure a finite application using a reference trigger and setting the timeout on the read function to a high value.  In this configuration the read function would only fire once and all the data would be saved and plotted.  Currently, I think you are constantly reading data, in 1000 pt chunks, and using a homegrown vi called DAQmx soft. analog trigger to monitor the data to see if it should be saved or not.  What you have will work, it just tends more to a Rube Goldberg machine than you need it to.

2) If, for some reason, you need to continue to use what you got, I would have to know what exactly the soft. trigger vi is doing.  Best I can tell, is that it adds data to the intialized 2D array if the values meet some trigger condition.  This vi then passes a true boolean to the case structure so that the data can be written and plotted.  It also passes the boolean to a shift register, but I'm not sure what happens on the next loop iteration when the boolean is true and it gets passed to the soft. trigger vi.  Also, I wonder about your file logging scheme.  It appears that the file refnum's are the same for each loop iteration resulting in data getting written over.

If your soft. trigger vi works properly, you should be able to move the case structure outside of the loop and use the shift register 2D array which, if done properly, contains all the data you need to save.  You can leave the timing functions in the loop to give the conditions of when to stop the loop.  The plot would also sit ouside the loop and the 2D array would have to be reshaped with the reshape array function to plot all the data as 1 channel.

Again, if you only need to save data from a single firing sequence, what I mentioned in 1) should be the ticket.  This does, however, depend on the hardware you are using.  It would need to support reference analog triggering.

If you want to keep what you got, post your code so i can help you more.

regards,

Drew

Message 4 of 8
(4,357 Views)
Hi Caz,

Thanks for some great ideas, This will use a BNC 2110 and PCI- 6036E card, so I m not sure whether it would support analog reference trigger.
This Vi is just for viewing purpose to record how many bullets were fired. The actual recording will be done by PXI 4472 on a seperate computer.

As the boolean is passed to the case structure, the case structure runs for specified amount of time and then the whole VI stops running so the boolean shift register doesnt have any effect on the data. The VI has to started personally next time before the acquisition occurs.
The file logging scheme is set like that if the data is to be written simultaneously at two locations, as in the case of PXI it would be written to a external Hard drive and the laptop hard drive to duplicate a copy of the data. We usually keep a backup of all the data.
I am trying to move the case structure out of the loop and do it, but I m not able to do understand how it will work.

I am attaching my VI so you can take a look what I have done. I think you must have got the idea of what I m trying to achieve here. If it doesnt work I will make a seperate VI which will read in the data after all is done and then the Engineer can view it and see how many bullets were fired, but that will be an extra operation and I dont want that.

Regards,
Nitin
0 Kudos
Message 5 of 8
(4,348 Views)

Hi npai,

Right now the elapsed time express VI is only being incremented when your case structure is being executed.  In short, you are only counting the execution time of your case structure and not accounting for your acquisition time.  If you know how fast you are sampling and how many samples you are acquiring, then you can determine how many reads are needed to be executed before you stop acquisition. 

I would suggest using a waveform chart instead of a waveform graph to display your data.  A graph is only going to plot the data that is passed to it each iteration.  A chart is going to have history and will display all the data that is passed to it through the execution of your VI.  The history of chart can be increased so all of your data is displayed.  There are also three different modes for displaying data on a waveform chart that are similar to the different actions of an oscilloscope.

Here is a great resource for learning about Graphs and Charts.

 
Respectfully,

Rob F
Test Engineer
Condition Measurements
National Instruments
Message 6 of 8
(4,340 Views)
Nitin,
 
Your code will work just fine if you use Rob F's advice about the timing.  Basically once your trigger vi makes the trigger boolean go true, you just need to have N more loops of the while loop to get the amount of data you need.  To convert from time to number of loops, use Rob's idea of using the sample rate and number of samples/read to get N.  Outside the loop you can calculate N and wire it to the loop.  Add another initialized to 0 shift register to the while loop to hold to count value.  In the case structure you can have 0 wired for the false case and and +1 increment for the true.  When the case structure goes true it will output 1 the first time and then the next loop it will increment this to 2 and so on.  Outside the case structure but still in the loop, compare this value to the N value you calculated previously, when they are equal your while loop should be directed to terminate.  Thats just one way to do the timing, you could also use the express timing vi but I think the timing is more accurate using the iteration count method I outlined.
 
Also, it you put a waveform chart where the graph is you should be able to see all the data.  On the front panel, right click the graph and set the history to the number of points you expect or more.  This may also be able to be done with a property node but I'm not sure if the waveform chart has an accessible history length property to this programmatically.  Again, I never use charts although, I am starting to see the benefits.
 
Lastly, I checked your hardware out and I don't see any problems in doing the triggering in hardware instead of software like you are currently.   You should be able to configure a finite acquisition to sample X pts at F sampling rate.  Configure a start or reference trigger.  Reference if you want pretrigger samples.  A single read with # samples set to -1 will read all data at once and this can be plotted on either a waveform chart or graph.  Make sure to set the timeout on the read to something high since you don't know when the awesome helicopter will start to shoot relative to when you hit run on the vi.  This method gets rid of the while loop and the case structure altogether.  There are already packaged examples that almost do what you want right out of the box.
 
happy wire trails,
Drew
Message 7 of 8
(4,324 Views)

1 more thing.

If you stay with your current code, I would try to do the file writing after all the samples have been read.  Since you know the total number of samples, you could intialize and array outside the loop and wire it to a shift register.  Then in the case structure, instead of streaming to file/hard disk, use the replace array subset to add new data to the proper place in the array. That is, each time you will replace 1000 pts first starting at index 0, then the next time at index 1000 and etc.  Outside the loop, all the data will be availabe from the right had side shift register and then you can write to file so it can take its jolly ol' time.  This keeps you in RAM during the time critical DAQmx reading and the slower streaming to hard disk is done afterwards.  Also, if you go this route, I would not graph in the loop since you won't see it update anyways.  If you're loop iterates at 1 Hz or less you could graph in the loop but your loop will be going much, much faster.  Put the graph outside the loop.  This can be a waveform graph since you don't need the history capabilites of the chart. 

peace,

drew

0 Kudos
Message 8 of 8
(4,317 Views)