11-28-2011 11:15 AM
Hi everyone,
I'm somewhat of a newbie and would like to know how to continuously sample at 1k for display and write to file at slower rates.
I'm attaching a simple vi which is using simulate signal in place of the usb board. I'm currently using the following settings on the board, Acquisition mode = countinuous samples, Rate = 1k, Samples to Read = 100. I'm wiring the signals to front panel indicators and to write to measurement file (eventually plan to write to spreadsheet file). What I want to do is keep the indicators sampling at 1k while writing to file at a different rate (10 or 50 samples per second). Currently it writes to file at 1000 samples per second. I've read through several posts and would just like to have a simple example that shows what would be the better approach to accomplish this. Any help would be greatly appreciated. Editing the attached code to show how to do it would be wonderful.
Thank you,
techy1
11-29-2011 12:44 PM
Hi techy1,
I think the best way you can implement this is to use the Producer Consumer architecture. More information about this can be found here: http://zone.ni.com/devzone/cda/tut/p/id/3023. The general idea is to Produce data (sampling at 1k) and put the data into a queue. Then you will have another loop to consume the data (writing to file). You may also want to stay away from using express vi's. Especially for writing the file, I would open the file once, outside of the while loop and close the file when all writing is complete, which will save computational power and increase performance.
Jason L
11-30-2011 08:24 AM
Thanks for the advice Jason, I actually plan to use write to spreadsheet file. I'll give the Producer Consumer a try. Do you know if there is a Producer Consumer example writing to a spreadsheet file?
Thanks again,
techy1
11-30-2011 12:14 PM
Techy1,
Though not exactly what you want, here are two examples that are really similar to your application:
Use them both as a starting point to understand producer/consumer and to get your code going.
Jason L