04-08-2009 06:55 AM
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
04-08-2009 07:19 AM
04-08-2009 09:20 AM
04-08-2009 09:55 AM
04-09-2009 05:15 AM
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?
04-09-2009 07:25 AM
The way you have it wired, the event will run once. You might want to consider a master/slave state machine.
04-09-2009 08:35 AM
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.
04-09-2009 12:18 PM
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?
04-09-2009 01:17 PM
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.
04-09-2009 01:27 PM