Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I optimise my code to allow for smallest possible output buffer sizes?

I am using an NI-USB-6361 with C# .net, on a variety of Windows XP computers.

 

I am simultaneously outputting an analogue waveform at 1MHz and analyzing 2 analogue input channels, each at 500KHz.

 

My output waveform changes depending on the input, so I have DoNotAllowRegeneration selected.

 

I can make this stable by increasing the output buffer size.  But, in practice, I want to use as small an output buffer as possible to reduce lag time between input readings and changes being seen in the output.

 

So, and I suspect this question is of general use, what tips does everyone have on how to improve performance, and reduce those annoying buffer overflow / no data for analog output errors?  This is of relevance to anyone streaming data to / from an NI USB device.

 

Things I have seen elsewhere (and am already using)

 

1) Disconnect all other USB devices from your PC

 

2) Put your analysis code in a separate thread to your data gathering code

 

3) Streamline the code as much as possible (!)

 

Ideas I have and have not yet implemented (that may not be feasible - feedback on them very much desired)

 

1) Play with thread priority - put the analogue output waveform generation on a high priority thread and put the analogue input data analysis on a low priority thread (I don't mind if I miss a few data points, and the analysis can be in a different thread to the data gathering)

 

2) Somehow increase the USB data transfer speed (is there some kind of USB priority I could set?)

 

Please, put forward any ideas you have / solutions you have seen working - it would be great if we could gather some tips here.

0 Kudos
Message 1 of 4
(4,072 Views)

Hi Tom,

 

Sorry for my late response regarding this issue you are having. As I am sure you are aware the device features onboard memory which is designed to allow a buffer and overcome the limited data transfer rates inherited from the USB bus.

 

Regarding the USB transfer rate, this will be dependent on your system as you know. It is likely that all your PCs USB ports are working from the same hub so removing additional USB devices would increase the transfer speed. 

 

Also, there is an option within device manager to optimise the USB port for performance or removal. Details of this can be found here.

 

If the transfer rate really isn't up to the performance your require, then you will need to look at a different data transfer bus which allows higher transfer speeds. If this is the case I would recommend speaking to your local NI branch regarding hardware that meets your performance requirements.

 

Many Thanks and please do ask any other questions you may have,

Aaron. E
Product Performance Engineer
Dyson
0 Kudos
Message 2 of 4
(4,039 Views)

Hi Aaron,

 

Thanks for the reply.

 

I tried to use the tip about optimising the USB port, however I can't find such an option when I select the NI card in Device Manager.  It seems to only apply to items Windows regards as hard disks.  Is this correct, or am I doing it wrong?  I'm using Windows XP by the way.

 

We're quite happy with performance so far, but would always like to improve it!  I was looking to see if there were any common issues or tips people had come across for improving performance - your USB port optimising tip is exactly the kind of thing we're after.

 

Many thanks,

 

Tom

0 Kudos
Message 3 of 4
(4,036 Views)

Hi Tom,

 

Ah sorry about that, please find the following link for optimising the device in Windows XP.

 

Hopefully this will allow you to see faster transfer rates. I have read a couple articles online that said it can improve by up to 30%.

 

Many thanks,

Aaron. E
Product Performance Engineer
Dyson
0 Kudos
Message 4 of 4
(4,015 Views)