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: 

Online Data Acquisiton Median Average Problem

Solved!
Go to solution

To begin with, I am extremely new to Labview and its different applications. I would really appreciate it if you can answer accordingly. In my experimental setup, I am trying to record 5 different thermocouple measurements and log them into a single file. I am collecting the data using a DAQcard. By following some tutorials I was able to do this in a simple manner, although it might not be code efficient. My problem is trying to apply a median filter to the online incoming data and save it. What I mean by this is: I would like to collect thermocouple measurements at 1000 Hz (1000 data points every second) and find the median value of this 1000 data set and log it in the file as a single datum for that recorded second. I would like to continue doing this every second for all the coming online data. By using a similar problem in this forum, I was somewhat able to median average the data, but I was not able to save it properly because of the loop and case structures. Can anyone point me in the correct direction? Also I would really appreciate all the possible improvements for the general program.

 

In the beginner's code I am attaching, I was able to get the median for the selected window size of incoming data and display it; however I was not able to write this information in the log file in any way I tried. Please let me know if I should attach anything else than the program itself.

0 Kudos
Message 1 of 5
(2,569 Views)

Cleaning up your diagram us Control+U or Edit > Clean Up Diagram may make your VI a bit more compact and easy to read.

 

Your DAQ task is using on demand timing. I'm not sure what DAQ card you have, but you could hardware time it. In the DAQ Assistant, for each channel, change On Demand to N samples and choose a sample rate of 1000 and 1000 samples. I think you won't need the Collector then. However, perhaps not all DAQ devices can do the N Samples acquisition. It seems like your DAQ card might be good because it looks like maybe it is in a PXI chassis.

 

To find the median of a dynamic signal, look into the Statistics Express Vi. In fact, that VI will do everything you are doing with these other VIs.


Hopefully that starts you in the right direction.

Message 2 of 5
(2,533 Views)

First of all, thank you very much for the quick response. Let me give the details of the hardware: I connect the thermocouples to a NI SCB-68 Shielded I/O Connector Block, then the block is connected to a NI PXI-6220 DAQ board which is located in a NI PXI-1033 Chassis. 

 

I have tried your solution for Hardware Timing and it seems that the PXI-6220 DAQ board has that property. However, I ran into some problems. The main problem is that, the program calculates the median value of all the data points collected in the whole experimental run, not the median value of all the data collected in a certain second. I could not figure out how to let the program know it needs to get the number of data collected in a second, get the median value and record that value as the median for that specific second. Then continue doing this for every second. Also, I could not get the program to collect meaningful data without the collector, I am not sure why. I am attaching updated programs with and without the collector and their output files at the end of a 100 iteration run.

0 Kudos
Message 3 of 5
(2,512 Views)
Solution
Accepted by topic author onurdogu

I'm not sure we're on the same page yet possibly because I was unclear. Look at the DAQ Assistant Express Vi. In Timing Settings at the bottom of the DAQ Assistant, you need to update the settings to N Samples, 1000 Samples to Read, 1000 Hz. This allows the Labview VI to take 1000 samples all at once and let you process them. It's also possible to do the Continuous Samples in the same way. Generally, this would mean there would be no gap in sampling the data if that is something you are interested in. However, with Continuous Samples you need to be a bit careful because it's possible you could take too long processing your data and you might run into issues then. You can also replace the CHART on the front panel with a GRAPH if you just want to see the last 1000 samples each iteration (or not if you want to accumulate data on that CHART). Hope that helps.

 

1.JPG

0 Kudos
Message 4 of 5
(2,500 Views)

Thank you for your answers. I solved the problem by changing the data acquisition mode to N samples, and now I can change the number of samples I can record and take the median of in a given interval.

0 Kudos
Message 5 of 5
(2,450 Views)