08-04-2008 11:02 AM
I'm trying to output my data acquisition into an array so that I can perform additional data analysis. I'm using a case structure to ensure that all the samples are read from the buffer. Each time the case structure executes the array values are reinitialized and nothing is outputted. The number of samples read works fine but the data acquisition doesn't. Is the case structure the wrong thing to use or do I need to build my array differently? If I shouldn't use the case structure how do I ensure all the data is read from the buffer? This is a problem that developed after the post "for loop data acq."
Thanks
08-04-2008 11:18 AM
08-04-2008 01:06 PM
I'm using the case structure because I get a time out error with just using a while loop. Also messing with the timing of the while loop I left data points in the buffer. I'm actually collecting a data point every five seconds for 5 to 20 minutes. So I would have to have something in place to make sure the buffer was empty without getting a time out error or vice versa. This was covered under the post "for loop data acq." I don't know how to implement the two while loops with my issue being one of the stipulations.
Thanks, Eric
08-04-2008 01:22 PM
08-04-2008 02:15 PM
08-04-2008 04:25 PM
The first problem is, I’m collecting a finite number of samples. In the attached vi I set the rate for one sample per second. I’m really collecting one sample every 5 seconds for 5 to 20 minutes. I could change the time out but that is where I ran into trouble with the timing of the while loop and the wait ms. Also I want the graph to update to show the user the data acquisition is working.
By using the case statement we were able to solve the number of samples being read and making sure none were left in the buffer, which was happening. Now I’m trying to take the samples read and perform additional analysis on them. The problem is the array I’m trying to build. I can’t figure out how to capture the signals in an array with the way the case and while loop work. As a last resort I could read the data out of my measurement file, but I was thinking there had to be something easier.
08-04-2008 09:18 PM
08-05-2008 12:41 PM
Try this
I have used the producer/consumer pattern I was talking about. I got rid of the case structure and instead used the DAQ mx functions to take care of timeout issues. I also added an input for the number of samples to collect. Finally, the bottom loop saves everything to a spreadsheet and uses shift registers to compile all the data into one big array, if you need to do some analysis on this big array, you can add to it. I'm not 100% sure if this works, give it a test and see if thats what you need.
08-06-2008 12:18 PM
OK Guys,
I couldn't get the two while loops to work as TZJ suggested. I keep getting errors on the queues. I think it has to do with data being written to the queue sometimes and maybe not closing or clearing the queue others. Not really sure since I am unfamiliar with them. As far as the suggestion form Ravens Fan, I got an idea from that solution and turned it around a little. It worked but I still have one problem. The program will collect data from 1 to 4 channels. If it only collected two channels as in the attached vi no problem. I can make the program work if the channels were constant every time. I worked on it all day yesterday and today so far and can't figure out how to create the array if the number of channels changes randomly. The number of channels is chosen by the user and is inputed into this vi. This vi is a simplified version of a sub vi and doesn't have all the inputs and outputs in the real vi. Any suggestions on how to make this work?
Thanks for the help so far,
Eric
08-06-2008 12:48 PM - edited 08-06-2008 12:50 PM