03-20-2024 11:29 AM
I have an NI-6351-USB and I want to write a program that does the following:
1. Generates two sinewave outputs at two different amplitudes and frequencies (about 1V at 250 Hz and about 0.1V at 950 Hz). The amplitude and frequency need to be adjusted periodically with new amplitude/frequency values passed into the program while running.
2. If new amplitude/frequency values are passed in, the program will ramp the outputs smoothly to the new amplitude/frequency values without interruption, and then continue outputting the new sinewaves until any new values are passed in.
3. While the output section is continuously working, the input section needs to take analog inputs periodically when triggered to do so, and store that data into a file (this data will be taken for about 1 minute on several channels, stored into a file, and then wait for the next "take-data" event.
I have programs written that can do all of the above tasks individually but not simultaneously. So my question is:
Can these tasks be done simultaneously using the NI-6351-USB, or do I need to use two separate devices?
Thanks in advance for any input.
03-20-2024 12:49 PM
Yes, your device can do these things simultaneously. But you'll also need to structure your code to manage things properly. This will almost certainly mean having 2 or more loops running in parallel. One will be responsible for the AI task, capturing & saving data, getting armed again for the next trigger. Another will be responsible for the AO task, perhaps including the "smooth ramp" you describe.
The smoothing algorithm could be a challenge. I'd probably start by using built-in functions for a chirp signal of amplitude 1 that spans your frequency range & a reasonable total # of samples for "smoothness". Then I'd generate a ramp pattern with the same # samples that ramps between your 2 amplitudes and multiply it by the chirp signal. Have a look at whether a simple approach like that can be used before doing it all from scratch.
-Kevin P