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.
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.
06-09-2014 12:38 AM
Hi forum,
I am using a NI9220 with 100ks/s/ch for power monitoring where i am calculating the RMS , THD values of a current and votlage wave with the rms. and thd vis. I woulde like to implement a aggreagation of 3s and 10min and write the values to file every time the average is calculateted.
Is there a way to do this in labview mabye with the moving average example?
Thanks
Martin
Solved! Go to Solution.
06-10-2014 06:36 AM
Hi,
This can easy be done with a producer/consumer design pattern.
http://www.ni.com/white-paper/3023/en/
There is an example shipped with DAQmx - the analog input continuous example. Set "samples to read" to 300k and the aquisition rate to 100kHz. That let the aquisition loop execute exactly every 3s - because DAQmx Read waits until 300k data is there. Average all values and write them into a queue.
The consumer loop (see link) dequeues automatically every three seconds. There you can write to a file. Collect the data here for 200 cycles (10 min), make an average of this array and you have you 10 min average value.
A good file format is the .tdms
http://www.ni.com/white-paper/3727/en/
Regards
René
06-10-2014 01:53 PM
hI rESCHRI,
thank you very much that helped me a lot it is now working with the the producer/consumer design patter, but I have one issue:
I implement the Producer/consumer application to my current programm see the picture below:
I have now 2 DAQmxRead vi one is for continously daq (samples to read 100) read and the other one with the producer consumer loop (samples to read 1000). How i could run and stop both application at the same time. Would be great if you could have a idea for this.
thanks again
Martin
06-11-2014 02:54 AM
Hi,
Somthing is unclear here:
You have two different DAQ-Devices and DAQ-Tasks. You cannot have two tasks for the same Analog Inut. For instance, you cannot have analog input A0 to A3 in one task and A4 to A7 in another.
A Continous Analog Input Task means that the driver of the card sets it to continous aquisition with the parameter you´ve choen. The DAQmx Read does nothing but read out the data from the RAM of the computer.
So I do not know what you mean by "having to DAQmx Read" unless you have two devices which I cannot figure from your Screenshot.
What else concerns me: you stop the aquisition (DAQmx Stop Task) in EVERY loop iteration, meaning you do not have a continous aquisition. The task is stop, the loop iterates again, and DAQmx Read restarts the task. Use the Stop-VI AFTER the loop
The easiest way to stop multiple loops is the use of variables:
http://www.ni.com/white-paper/7585/en/
Regards
René
06-11-2014 11:59 AM
06-12-2014 02:12 AM
Hi,
Just as an update, you can have more than one task for the same analog input source depends the hardware you are using, but I didn´t want to complicate things.
What you want to do (at least I think so) aquiring on one pysical channel - only one anaolg input port is connected. Please confirm that if I am right.
And now you want to read out the buffer two times: one time a 10k piece and after 3s then a 300k piece.
When you use DAQmx Read, the data is taken out of the buffer.
You want the driver to read out 10k every 3s, while the driver buffer(!) continues to store values until 300k is reached.
This neither necessary nor possible to my knowlege. Therefore, you have LabVIEW to implement whatever logic you need. In your VI!
Read your values from the buffer with DAQmx Read. Then, store them, average them, accumulate them.
"Is there another way to get the aggregation like building a buffer over 300ksamples"
There are plenty of ways to do that:
For starters:
Passing Data Between Loop Iterations in NI LabVIEW
http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm
Regards
René
06-17-2014 12:06 AM
Hi Rene,
ok that helps me a lot.
Do you have a idea how to create this feature i would probably need an array that stores the data (300ks) and every time the array is full calculate me in another loop the average and store it into another array and then write it to file?
Thanks a lot
Martin
06-17-2014 01:19 AM
Hi,
have a look at this:
http://www.ni.com/white-paper/7188/en/
what you need is a so called ring buffer. You store data for a certain time and overwrite the oldest with the newest one. You can implement this with the library provided. You have an array of a fixed size for that.
Regards
René
06-17-2014 01:13 PM - edited 06-17-2014 01:15 PM
Hi Rene,
thank you very much! I used the ring buffer and implement a logic so i record 300ksamples calculates the rms and thd values continously and every 1s it writes the file to a text file. Looks like its working but you have a idea to size the elements in the array now i just wait 1s (buffer is full) and then start callculating. I attached the logic:
06-18-2014 06:03 AM
Hi,
you configure the simulate blocks to produce as many data points as you want per second, then you add a timing to the loop to execute every second.
http://www.ni.com/white-paper/4120/en/
Regards
René