LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2x USB 6002 all channel read, display, and write to TDMS Causing Front Panel Lag

Solved!
Go to solution

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. 

Data logger.JPG

UI2.JPG

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.

Download All
0 Kudos
Message 1 of 11
(1,807 Views)

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.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 11
(1,800 Views)

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?

0 Kudos
Message 3 of 11
(1,794 Views)
Solution
Accepted by topic author Kulani93

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).

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 11
(1,779 Views)

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.

0 Kudos
Message 5 of 11
(1,773 Views)

@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.

Message 6 of 11
(1,765 Views)

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.  

0 Kudos
Message 7 of 11
(1,758 Views)

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?

0 Kudos
Message 8 of 11
(1,744 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 11
(1,742 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 11
(1,738 Views)