LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a timed csv file?

So I have been struggling with this for a very long time, maybe someone here can help.  I will try to be as clear as possible.
 
What I want to do:
  • Read data from a distributed USB device (I can do this).  I am sampling in the 10+ kHz range.
  • Process the data (I can do this).  For simplicity we can say that I am measuring a 100 Hz sinusoid, then I use LV to find the RMS value.  This is no problem.
  • Now the problem:  I want to be able to have two numeric controls (Rate, and Time) and a Start button on the front panel.  The operation of these controls should be as follows:
    • Rate:  Sets the rate at which to log the RMS value found above to a user specified csv file.
    • Time:  Sets how long to continue to log data.
    • Start:  Begins logging.
It seems like it should be very simple, but I just cant get it to work.  Have tried using a for loop inside a case structure, but that didn't work.  It would log data, but it would not update the data as it logged; it would log the same number for every point, even if the rms value changed while it logged.
 
Can anyone offer any help? 
 
Thanks.
0 Kudos
Message 1 of 4
(2,300 Views)
Hi DrewM,
welcome to the forum.
Can you show your vi, which you have until now?

Mike
0 Kudos
Message 2 of 4
(2,297 Views)

The attached file shows basically what I am trying to do.  Here I simulatethree signals then try to log their RMS values.  It saves to a tab delimited file, but that is fine.

If you set the Time to Log to be long enough, then vay the Sinusoid Amplitude as it is logging, you will see that the values on the screen (and in the file) do not update with the control.

I hope this helps.

 

0 Kudos
Message 3 of 4
(2,290 Views)
Hi Drew,

I took a look at your program and was able to understand why you are reading the same values everytime. The first time the for loop runs, you read values from the RMSs into the case structure into the for loop. The for loop concatenate the values and enters into a case structure where it gets written to a file. The next time the for loop runs, it is still using the old values from the RMS because it is not reading the RMSs again to get new values. It uses the same values as before and goes through the process again. You have used a used a shift register to account for the new values but you are not reading new values itself. I hope this makes sense. To fix the issue, you will need to read you RMS inside a for/while loop, so that everytime the loop runs, you get a new value (simulated or otherwise).

I was not able to run your program because I was getting an error (20309) but the above paragraph explains what the problem is.

I hope this helps!

Warm regards,
Karunya R
National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(2,254 Views)