LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

saving and plotting acquired data

Hi everyone, I'm trying to put together a simple data acquisition system and was hoping I could get some advice.

 

I've attached what I have put together so far. To start with I want to record data from a single analogue input using the DAQ assistant. I want to be able to save this data to a file as its (continuously) acquired, while also plotting it to a waveform chart. Theres also a couple of other bits which I am trying to achieve. To show this i've broken down what I want the system to do into steps.

 

1. Click start
2. Create data file using 'DAQresults' string and numeric control to generate a filename e.g. 'DAQresults1'
3. Start recording data from DAQ system, record it to data file and plot to waveform chart
4. Click stop to finish recording data
5. Save data file and increase numeric control value by 1

 

If anyone could check through what I've done and give me some advice on what else I still need to do I'd be really grateful. Eventually the program needs to be simultaneously recording 8 channels of data, and needs to be run on a PDA. This is one of the last remaining tasks for a project I'm doing and I'm really running out of time so any help would be greatly appreciated.

 

Iain

0 Kudos
Message 1 of 34
(4,276 Views)
one of the main things I'm trying to figure out is how to specify a path for the data file I'm trying to create. I've got a filename generated which I want to be able to use, how do I turn this into a complete path assuming that all data files will be saved directly to a specific directory on the hard drive?
0 Kudos
Message 2 of 34
(4,264 Views)
You've got a bit of work ahead of you. Rather than starting from scratch I would strongly suggest that you study the examples that ship with LabVIEW (Help -> Find Examples). There's lots of DAQ examples and many of them do most of what you're trying to do.
0 Kudos
Message 3 of 34
(4,233 Views)
Hint:  Build Path
0 Kudos
Message 4 of 34
(4,217 Views)

can i use an event case structure to control what happens when the buttons are pushed? So if the start button was pushed would the program run continually until the stop button was pushed, or would it only run once?

Download All
0 Kudos
Message 5 of 34
(4,169 Views)

The way you have it wired, the event will run once.   You might want to consider a master/slave state machine.

 

 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 6 of 34
(4,151 Views)

Robbo13,

 

A simple state machine should fit the bill for your project.  No need to make this any more complicated than necessary.  Since you went to the trouble to actually find the Build Path.vi, I'll offer up another hint.  ( Yes I did notice )  As previously mentioned, LV ships with some really nice bits of example code.  There is a DAQmx example that ships with LV that continuously acquires analog voltage, plots it and writes data to a file.  Pay particular attention to how the example first sets up and starts the DAQmx Task, acquires/writes data in the loop and then takes care of some housekeeping after the loop has completed.  You will need to incorporate these three stages into your state machine along with the other parts.

 

LV examples can be found at  Help>Find Examples  The search feature is particularly usefull.

Message 7 of 34
(4,130 Views)

thanks for the hints, I think the example you're referring to is the one I actually used to get this far in the first place. I was under the impression that I could use the DAQ assistant to handle most of the DAQmx functions found in that example, is this not the case?

I can probably simplify the program from how it is at current and make it more like the example, but I'm very keen to make sure that a new filename is generated automatically each time data starts recording, to prevent accidental overwriting of previous results.

Oh and finally does my use of the build path vi look correct? I wasn't sure if I had to add .tdms to my path or not? 

0 Kudos
Message 8 of 34
(4,103 Views)

Robbo13 wrote:

thanks for the hints, I think the example you're referring to is the one I actually used to get this far in the first place. I was under the impression that I could use the DAQ assistant to handle most of the DAQmx functions found in that example, is this not the case?


You could replace the code with the DAQ assistant if you really wanted to, but I'm not sure I really see the advantage if you have an example that mostly works. The DAQ assistant is an Express VI. You can think of it as a high-level wrapper for the regular DAQmx function. In fact, if you convert the Express VI into a normal VI you will see that it's using the standard DAQmx VIs.

 

I'm not sure which example you were looking at, and I don't know if Wayne was referring to this one, but a good one is the "Cont Acq&Graph Voltage - Write Data to File (TDMS)" example. What I would do is to create a state machine based on this example that has these states: Init, UI, Start, Collect, Stop, Exit. Have a shift register to keep track of whether you've started data acquisition. The Init state creates your TDMS file and configures your DAQ task. This consists of steps (1), (2), (3), and (4) from the example I mentioned. The UI thread just checks to see if the user clicked on a control (i.e., Start or Stop). If not, you can check to see if you've alread started data acquisition. If so, go to the "Collect" state which performs steps (6) and (7) from the example (without the loop, of course). If you haven't started acquisition and the user has clicked the button, then go to the appropriate state. The "Start" state performs step (5) from the example, and "Stop" performs steps (8), (9) and (10). If the user clicked the Exit button then have the state machine go to the "Stop" state and then go to the Exit state which terminates the state machine. 

 

That's really the best place to start. All in all it should take you more than a few hours to get something working if you start with a good example and a good design pattern.

 


but I'm very keen to make sure that a new filename is generated automatically each time data starts recording, to prevent accidental overwriting of previous results.


The best way to do this is to append some sort of timestamp to the filename. You can use the Time functions to return you a string to indicate the date and/or time.

 

Message 9 of 34
(4,087 Views)
Oh, you may also want to read the State Machine KB article. Note that you can create a state machine template using the LabVIEW File->New menu item.
Message 10 of 34
(4,081 Views)