From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-13-2021 03:49 AM
Hello,
I am setting up a USB-6212 for a teststand we are creating.
The teststand should be able to:
- measure analog inputs on 3 channels
- measure the frequency of a PWM signal
- generate an analog output between 0 and 10 volts
- record the data we are logging.
The VI that we have created so far works fine when running up to 500 Hz. At higher speeds, it has trouble keeping up. We can see this from the recorded data where the time is also logged.
I am relatively new to Labview - can anyone tell me what can be done to make this program run faster? We need a speed around 2 kHz. The program is attached
Thanks in advance
Solved! Go to Solution.
01-13-2021 04:57 AM
1. Very generally, interacting with multiple tasks 1 sample at a time over a USB connection is definitely going to be limiting. Honestly, I would have bet against achieving even 500 Hz.
2. in particular, your AI task should be reading multiple samples at a time. A typical rule of thumb is to aim for a loop iteration rate of 10 Hz. Reading 200 samples while sampling at 2000 Hz will help accomplish that.
3. Your counter freq measurement task is unbuffered, so each call to DAQmx read will wait for the next *future* interval. That can limit loop iteration speed as well.
4. Your single-sample output signals get their values from the GUI. You don't need to write those values at 2 kHz or even 500 Hz. More typically, one would have those in a separate loop with an event structure where you'd only update the output signals when the GUI value changes.
5. Helpful tip: take a step or two back to do some investigation. You're gonna learn some things. Make 4 separate vi's for this investigation, one for each of the tasks. Explore each one on its own.
See how fast you can run an AI Read loop when you read 1 sample at a time. Then try setting the sample rate to 20 kHz and read 2k samples at a time -- notice how much more data bandwidth can be delivered when you do it more efficiently in larger block sizes.
See how fast the Freq measurement task runs in its own loop. Then lower the frequency of the signal being measured -- bring it down to the 1-10 Hz range. Notice how the loop rate depends on the signal because your task is always asking for the *next future* interval.
For inspiration, you can have a look at a variety of shipping examples. At first, you can ignore & cut out all the stuff related to TDMS logging and triggering. That'll help you focus on some of the bare fundamentals first.
-Kevin P
01-13-2021 07:48 AM
Kevin,
Thanks for the quick reply!
I have implemented some of your suggested changes and it solved my problem 🙂
Thanks again,
Jacob