07-13-2022 12:56 PM - edited 07-13-2022 01:02 PM
Hello All,
Please help me improve the performance and efficiency of my code and UI.
I have 2x USB 6002, 1000Hz Rate, Single sample waveform output, All Analog Channel Reading and some digital - Writing to a Single TDMS file.
It took forever to get this to all work as it does and the code runs. The issue is during running, the program, all seems to work well until the Graphs start trailing behind by some milliseconds which increases in time to a full blown 4 seconds within 2 minutes of running. This effectively means that the data being read gets delayed in being displayed.
Please note that everything is hardware to run the Dev1 and Dev2 USB 6002 device, and all analog channels reading and displaying. I used custom scales on MAX as well, which might cause the code not to run on your side.
I tried implementing a state flow machine to allow users to configure data logging before running. There are 4 states - initialise, setup, run, and stop.
See attached VI with its' subIV.
Thank you.
Solved! Go to Solution.
07-13-2022 01:11 PM
IMO, you will benefit a lot in terms of performance if you rewrite this code with a proper architecture instead of flat VI with a while loop.
07-13-2022 01:24 PM
That would really be great but I am no programmer and I think I am out of my depths here, this is as far as I could get this code.
Any particular ideas?
07-13-2022 01:48 PM - edited 07-13-2022 01:50 PM
Hi Kulan,
@Kulani93 wrote:
I have 2x USB 6002, 1000Hz Rate, Single sample waveform output, …
Simplest solution: change to "N channels, N samples" mode for DAQmxRead and set the number of samples to read to (about) 100!
You should NEVER use the "1 sample" mode for anything faster than 10 S/s…
You already use the "1D array of waveforms" output mode for DAQmxRead (which is fine!), so your data handling doesn't change (a lot).
07-13-2022 02:02 PM
Thanks for the input @GerdW. The only reason I went to N Chanel 1 sample was that it arranges my data on the TDMS quite nicely (Tabular format with each N channel reading on a row, with separated by 0.001 s increments.)
I shy'd away from N samples because they stacked up in vertical lines and per reading but will definitely look into them again.
07-13-2022 02:32 PM - edited 07-13-2022 02:32 PM
@Kulani93 wrote:
Thanks for the input @GerdW. The only reason I went to N Chanel 1 sample was that it arranges my data on the TDMS quite nicely (Tabular format with each N channel reading on a row, with separated by 0.001 s increments.)
I shy'd away from N samples because they stacked up in vertical lines and per reading but will definitely look into them again.
I don't understand what you mean here. Are you talking rows versus columns? When you write a 2D array of data to a TDMS file you tell it to decimate or interleave the data. But you can also read it as a 1D array of waveforms, which should write just fine to a TDMS file, and it will retail all the attributes of the graph data like T0 and the delta between samples. My advice is to also read N channels and N samples. Let the hardware do the timing for you, not your non-deterministic operating system.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-13-2022 02:43 PM
Okay understood.
I have my DAQmx read set to N channel, N sample and 1D waveform. It aligns the row and column well.
The only issue is the actual timing values.. I need a 1000 Hz reading rate, setting the samples to 100 slows the graphs a lot (expected).
And setting the rate to 10Hz and the N of samples to 100 makes my increments 0.1s, and slows the graphs movements as well.
I have also noticed that my Gauges just flicker trying to display the pulse of incoming data all at once since samples are buffered.
07-13-2022 03:02 PM
Okay, so as soon as I turn on the Synchronous display, then the gauges respond to the incoming data. But I head that this setting is taxsome.
What's the relationship between reading rate and sampling rate?
07-13-2022 03:03 PM
Hi Kulani,
@Kulani93 wrote:
The only issue is the actual timing values.. I need a 1000 Hz reading rate, setting the samples to 100 slows the graphs a lot (expected).
And setting the rate to 10Hz and the N of samples to 100 makes my increments 0.1s, and slows the graphs movements as well.
Why do those graphs "slow down" when they update at 10Hz (for 1000S/s and reading 100 samples)?
@Kulani93 wrote:
I have also noticed that my Gauges just flicker trying to display the pulse of incoming data all at once since samples are buffered.
Why do you want to update those gauges that fast?
In your first approach you even tried to update them at 1000Hz, which is ridiculous!
You can only watch at ~25Hz…
The problem is: now you read 100 samples per iteration: which of those samples do you want to display on your gauge? The first, the last or everything? (Mmmh, Barry White?) Or maybe just the average of each 100 samples?
07-13-2022 03:06 PM
Hi Kulani,
@Kulani93 wrote:
What's the relationship between reading rate and sampling rate?
Sampling rate is "samples per seconds".
Reading rate is "per second".
Relation is number of samples!
Simple math: sampling rate / number of samples = reading rate…