LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to combine and save data

Solved!
Go to solution

Another new user with an issue.  Working on the attached VI, first I would like to combine the "Temperature" data with the "Voltage" data, then create and write that to an excel file.  I would also like to have a way to adjust the save rate on the front panel (sometimes I'll save at 10hz, sometimes every 30 seconds).

 

Back ground information:  The basic function of this VI to use a cDaq 9174 with a 9211 TC card and a 9221 DC card The "Measure channels" boolean starts the measuring, the "Save data" boolean is intended to start and stop data saving (the "saving data" light is only confirming that data is being saved).  The "Data Save Location" is as you'd expect, which is that I would like to pick my file save location.

 

Thank you.

0 Kudos
Message 1 of 14
(2,754 Views)

1. Combine your voltage and temperature measurements into 1 task.  That can be as simple as putting everything into one DAQ Assistant.  However...

 

2. I REALLY dislike the Express VIs and the Dynamic Data Type.  That abstract too much away.  You can make something A LOT more efficient if you use the actual DAQmx API.  Start here: Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications.

 

3. Do you really need an Excel (*.xlsx) file?  Those get really slow to write and can cause other issues.  I normally recommend a tab delimited text file with a .txt extension.  Excel can still open those up formatted into columns.  Again, get rid of the Express VI (Write Measurement File).  At the rates you are talking, you can probably get away with using the Write To Delimited Spreadsheet File.

 

4. As far as writing rate, you can use the Elapsed Time VI (pretty much the only Express VI I will use).  You set the time limit and it outputs a Boolean if that time has elapsed.  It can even autoreset to start counting again.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 14
(2,736 Views)

Thank you for the reply.

 

1.  The voltage and temp measurements were separated because of scaling.  Eventually the temps will exceed 200  - 250 degrees where the voltage will never exceed 50 (expected to be around 30, so I separated them into two different charts to help with visual resolution.

 

2.  I'll look into the "10 Functions" link you sent, maybe I'll be able to improve on what I have.  🙂

 

3.  I do not need an actual *.xls file but I do need one that Excel can easily read, so a *.csv (or other format) would be fine.

 

4.  Didn't see the "Elapsed Time VI", I'll check it out.

 

0 Kudos
Message 3 of 14
(2,724 Views)

UPDATE:  Ok, so I got it to work (VI attached), but I still have a couple questions.

 

1.  I'm running into a buffer error (# 200279) when I increase the speed, any suggestions on fixing that?,  - the current fix is to just run the DAQ Assistants at a very low frequency (1 to 3 Hz).

 

2.  The "Saving Data LED" lights up correctly when the "Save Data" boolean is switched "on", but when turned off the LED stays lit.  Any suggestions on how to turn it off when saving stops?

 

Extra Credit:  In a perfect world the graphs would update at about 100Hz and the "save data" loop would be adjustable to save from once a minute to 100Hz, any suggestions on how to do that?

0 Kudos
Message 4 of 14
(2,652 Views)

Wrote a VI using DAQ Assistant for a cDAQ-9171 with a NI-9221 card.  I would like to acquire and view the data at 100 or even 1,000 Hz but only want to save at 1Hz, any suggestion on how to fix my VI to do that?

0 Kudos
Message 5 of 14
(2,628 Views)

Hi Rich,

 


@Rich_Tennant_Tech wrote:

I would like to acquire and view the data at 100 or even 1,000 Hz


It doesn't make sense to view data at 100Hz or even 1kHz: you cannot view that fast and most monitors only update at 60Hz…

That being said: you just need to set reasonable values for samplerate and number of samples to read. There's a relation between those two values and the loop iteration time: do you know that? (Hint: Samplerate is given in "samples per second", number of samples is given in "samples" and you want to have a certain time, given in "seconds"…)

 


@Rich_Tennant_Tech wrote:

but only want to save at 1Hz, any suggestion on how to fix my VI to do that?


You need to collect the data of 100 loop iterations (when "viewing at 100Hz") and then save the data. Then collect again for 100 iterations…

(Still this doesn't make sense to me.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(2,616 Views)

For the data to smoothly scroll across my laptop screen I need it to read at 100 Hz or more, 1,000Hz shows the best, it is what it is.  But again, "right now" I only need to save at 1Hz, possibly more later but for that would be good enough.  Coding wise do you have a suggestion on how to save at the lower rate?

0 Kudos
Message 7 of 14
(2,613 Views)

Hi Rich,

 


@Rich_Tennant_Tech wrote:

Coding wise do you have a suggestion on how to save at the lower rate?


As I wrote before, even if I don't like to repeat myself:

You need to collect the data of 100 loop iterations (when "viewing at 100Hz") and then save the data. Then collect again for 100 iterations…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 14
(2,586 Views)

Well, is there a way to average it?  Say, take every 10 points and average them into 1?

0 Kudos
Message 9 of 14
(2,574 Views)

Hi Rich,

 


@Rich_Tennant_Tech wrote:

Well, is there a way to average it?  Say, take every 10 points and average them into 1?


Yes, sure!

Take the average of 10 points using the Mean function in the math palette…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 14
(2,569 Views)