05-07-2024 05:50 AM
I am writing code that receives analog input voltage from a sixteen-channel system. The sampling clock is set to a frequency of 40 kHz, continuously sampling one sample per channel. The trigger settings include an analog trigger signal of 1.0 volts at a frequency of 100.0 Hz. I've also attached a copy of the code with this message as an attachment.
Solved! Go to Solution.
05-07-2024 07:59 AM
Please upload the code. We can't test or debug an image.
05-08-2024 07:41 AM
Hi,
Thanks for your reply. I've attached the VI code to this message. My code is taking twice as long to run, and I'd like to reduce the execution time. The retrigger function is working well, as seen in the waveform and Excel data. Could you guide me on how to reduce the time? I tried using a timed loop but need help managing its parameters. I also tried adding the DAQ Task Assistant and DAQ task.
Once again thanking you
05-08-2024 06:19 PM
You are not using the correct way for the analog retriggerable task. Every time you start and stop the task, it creates overhead and delays.
Refer to Retriggerable Data Acquisition with NI DAQ Devices for a shipping example of M Series USB DAQ device.
05-09-2024 01:54 AM
Thanks for your reply. In my current code, I am using the committed state VI, which has improved my code optimization.
If you don't mind, could you please guide me on why the minimum number of samples per channel is 2 when I select the finite samples option in the sample clock? I need to set it to 1, but doing so results in an error.
05-13-2024 08:24 AM
A sample clock defines the interval between samples. It takes at least 2 samples to define any such interval. With just 1 sample, a sample "rate" isn't really meaningful because there's no longer any defined interval. You could probably just run in "on-demand" mode, which would be the default if you never called DAQmx Timing at all.
That said, there's also really no *harm* in defining a task for multiple samples and a sample clock, then stopping the task prematurely after reading only 1 sample, the way you do in the code you posted.
Is there still an actual problem or are you just looking for understanding?
-Kevin P