05-01-2020 08:54 AM
I want to perform a relatively straightforward task. I have a TTL signal at ~8kHz that I want to use to control an analog output channel. Specifically, each time the trigger arrives, I want to increment the AO voltage by a given amount (say, in increments of 0.01 V). It is critical that the TTL signal is synchronized with the AO output. I tried various methods but none have worked. The latest idea I had was to use a counter task synchronized with the AO task. The counter value is multipled by some increment value and added to an offset, which is then fed into the Write VI of the AO channel. However, I get error -201025 (Non-buffered hardware-times operations are not supported …) when I run it. The only thing I was able to do was remove the timing vi, but then the tasks are not properly synchronized. My feeling is that I need to use the non-regenerative mode, create the entire waveform of a stepped, ramp function, and then read out parts of that waveform according to the counter value. I've included screen shots of the code I wrote (the one that gave the buffered error and the one without error but no synchronization). Note, I realize that using the TTL signal as the clock doesn't make much sense but I get errors if I use the onboard clock... I'm relatively new to daqmx so I'm sure I'm missing something simple here. Any suggestions would be greatly appreciated!
Solved! Go to Solution.
05-01-2020 11:16 AM
Yeah, there is a *much* simpler way to do this.
- define an array of values that increment by 0.01 V each sample
- use the 8 kHz signal as an external sample clock for your AO task.
Below is a snippet of code that will ramp from 0 to 5 V, with a 0.01 V increment for each pulse of the external 8 kHz signal.
-Kevin P
05-01-2020 11:33 AM
Thanks Kevin. That certainly is a good way of doing it and works. I am a bit confused on what the external clock rate means in this context. It seems like it shouldn't matter what rate I choose. For instance, if my external clock source is an 8 kHz TTL signal, then putting 8000 for the rate doesn't produce a different output than say 1000.
05-01-2020 01:18 PM
I used to think it shouldn't matter as well, and used to have the habit of declaring the sample rate as 1, thinking of it as "1 sample per pulse".
But once I learned that DAQmx does buffer auto-sizing based on the sample rate, I realized that I should estimate more accurately or give a max expected rate.
-Kevin P