newtoni,
You've got an interesting app which is generating quite a bit of interest! I think I have an idea for you that ought to work out, but requires 2 counters (generally available on any of NI's multifunction boards). I'd suggest using DAQmx also. Anyway, here's an overview:
1. Configure your Analog Input task to use one of the counter outputs (let's say #0) as its sampling clock and start it.
2. Configure a Counter Input task on the
other counter (let's say #1) that measures periods of the sampling clock and start it. It should be set up with the same buffer size/type as the Analog Input task since it uses the same sampling clock.
3. Configure Counter #0 to generate a continuous pulse train at your highest desired sampling frequency. Start it, then enter your main loop. Note: it is possible to change the frequency of
this pulse train repeatedly without ever stopping it.
4. Request the 1st # of samples from both the Analog and Counter tasks. Once you've retrieved them successfully, change the frequency of Counter #0 to your next sampling rate.
5. Loop back on step 4, each time adjusting the # of samples you request and the next sampling rate until the test is done.
6. After leaving the loop, perform a cumulative sum on the periods you measured to get a hardware-accurate elapsed time to associate with the analog samples.
Note 1: It'll probably take some msec to retrieve 10000 samples and change the counter frequency. So when you next ask for 1000, the first few dozen or so will have been sampled at 10 kHz while the rest were at 1 kHz. However, you'll be able to know how many and which ones because of the period measurement you're doing with Counter #1. In fact, this issue is the reason for Counter #1.
Note 2: For your period measurement, there's a choice of a 100 kHz or a 20 MHz timebase. You'll probably need to use the 100 kHz. If you're using an E-series MIO card, you've got 24-bit counters that'll roll over in less than a second at 20 MHz. So you'd get wrong measurements for any interval longer than that.
Note 3: Yes, you should be able to build it into a standalone executable or dll.
-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).