LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to measurement file issue

Hi, I'm having trouble with my DAQ VI.  I want to continuously sample data from sensors.  I also want to save the output of the sensors, at will, to a measurement file.  I've attached my VI.

Right now, nothing happens when I flick the "save" switch.  No files.  The "Saving..." LED stays unlit.  I tried putting it inside the while loop, which didn't work too well.
0 Kudos
Message 1 of 6
(4,523 Views)
It looks like you are having problems with dataflow. 
 
Your write to measurement file node will not execute until it has signals coming in on its wire.  Those signals won't happen until the while loop ends.   The only way your while loop ends is if the value coming out of "stopped?" for the DAQ assistant goes true.  The help for the DAQ assistant says
 
"Indicates whether the task stopped. The task stops if the stop input is set to TRUE or an error occurs. This output appears for continuous or hardware-timed single-point tasks only."
 
You have nothing going into the stop input which means this loop will run forever until an error occurs.  The DAQ assistant is set up to acquire continuously.
 
I would recommend looking at some examples in the NI Example finder.  One would definitely be TDMS - Express write data time and frequency domain.
Message 2 of 6
(4,515 Views)
Waaaait, wait, wait.  So data tunnels aren't real time?  Good to know.  If I have a bunch of DAQ going on in a while loop, it only comes out when that while loop is stopped?


I want gages on the front end to show real-time, so I thought using "continous" task generation from DAQ Assistant was the way to go.


I also want, when I push a button, this to happen:

1) Digital line outputs.
2) Record the continuous signals that go to the front end gages.

Thoughts?

Message Edited by bmunden on 04-15-2007 10:56 PM

0 Kudos
Message 3 of 6
(4,513 Views)
Hi bmunden,

That is correct; data is only passed out of the tunnels once the loop has completed execution. 

For your application, it would be best to use low level I/O instead of the Write to Measurement File.  Use the Write to Text File.vi from the NI Example Finder as an example of low level file I/O.

Use a case structure to control your digital line outputs and the recording of your continuous signals.

Please let me know if you have any further questions.  Best of luck on your application, and have a great day!!
Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
Message 4 of 6
(4,489 Views)
So, after converting from DDT, how do I control whether or not the Write to Text VI starts/stops recording?  Shall I use a reay of some sort?

It's also critical that the while loop not get hung up while I'm waiting on the user to enter a file path.  Any thoughts?  An array?
0 Kudos
Message 5 of 6
(4,482 Views)


bmunden wrote:

Waaaait, wait, wait.  So data tunnels aren't real time?  Good to know.  If I have a bunch of DAQ going on in a while loop, it only comes out when that while loop is stopped?

Correct.  Think of it this way.  If you had a loop doing repeated operations on a set of data, you wouldn't want that data leaking out of the loop until you told the loop to stop, otherwise your data may be incomplete or inaccurate.

I want gages on the front end to show real-time, so I thought using "continous" task generation from DAQ Assistant was the way to go.

I won't claim to be an expert on Express VI's.  Continuous is basically telling it DAQ to acquire continuously an indefinite number of samples until some particular condition as been met.  The other options would be acquire 1 sample, or acquire N samples. 

I also want, when I push a button, this to happen:

1) Digital line outputs.
2) Record the continuous signals that go to the front end gages.

Thoughts?

Message Edited by bmunden on 04-15-2007 10:56 PM


I made some modifications to your VI.  I can't test them as I don't have your DAQ hardware, but I think it will work.

1.  I set up the DAQ Assistant to acquire 1000 samples.  With your 1 kHz rate, it should acquire a 1 second batch of data then pass it on to the other nodes in the loop.  Thus your screen should update about once per second.  If you want faster, set it up for 500 samples for twice per second, or 250 for 4 times per second.  Any faster than would probably be faster than you could possibly and would just waste processor cycles on the screen refresh.

2.  I set up the stop button to that it would have a switch rather than latch action, this allows it to have a local variable so that it can stop the data acquisition loop as well when you are ready to end the program.  I added a flat sequence frame around both loops, and a frame after that writes a false to the stop button.  This way it will appear to act as a latch mode and reset the stop button to false once the program knows that both loops have been stopped by reading the stop variable.

3.  I put in a Wait Until Next ms function with a value of 10 in each loop.  You can play with this value if necessary.  But it is always a good idea with loops to put in a small wait so that it yields some time to the processor to do some other tasks.  Otherwise the loops will run as fast as they possibly can and will make the program appear to respond sluggishly.

4.  I put the write to file express VI inside your DAQ loop inside a case statement.  This will execute whenever the Write to File control is toggled to true.

With all of this, your VI should be able to acquire a batch of data, process it, and write it to the file.  The loops will repeat processing more data until the user hits the stop button.  There may be room for adjustments in the number of samples acquired at a time, how fast the digital output loop should run, how many DAQ samples you want to acquire in one shot.

Message 6 of 6
(4,479 Views)