Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you use DMA with mbSession.ReadByteArray to improve data capture speed?

Hello,

 

I am working on a C# program that captures data from a Spectrum Analyer via GPIB.  We use a NI GPIB-USB-HS adapter with NationalInstruments.Common Ver 8.5.20.149 and NationalInstruments.VisaNS ver 8.5.20.310.  We use mbSession.ReadByteArray to capture the trace data directly into an array, but need to reduce the capture time.  Can someone direct me to documentation detailing the necessary steps that I should take in order to use DMA for this data transfer, or even detail them here if that would be easier.

 

Thanks,

-David

0 Kudos
Message 1 of 7
(5,493 Views)

Hi David,

 

Does the NI-VISA Programmer Reference Manual help you out? There is a VI_ATTR_DMA_ALLOW_EN attribute that specifies whether I/O accesses should use DMA or not. Do ctrl+F to find "dma" in the manual and it should bring you to the right spot. The manual is below for your reference:

 

http://www.ni.com/pdf/manuals/370132c.pdf

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 7
(5,451 Views)

Hi Kelsey,

 

When I set the DmaAllowEn attribue to true immediately before the mbSession.ReadByteArray command my program runs without any errors, but there is no difference in speed compared to either not setting the attribute, or to specifically clearing the attribue to false is is how I have implemented it in the program:

 

     mbSession.SetAttributeBoolean(AttributeType.DmaAllowEn, true);

     tmpByteArray = mbSession.ReadByteArray(1002);

 

The shown code is within a loop, and hence is repeated many times.  Can you tell if I am using the proper methodology

 

Thank you,

-David

0 Kudos
Message 3 of 7
(5,445 Views)

Hi David,

 

I don't think you should be setting this feature in each loop iteration. It makes more sense to me to have it declared once before the loop. What kind of memory access speeds are you seeing and what are you hoping to achieve?

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 7
(5,433 Views)

Hi Kelsey,

 

I tried setting the DMA attribute inside the loop, and outside the loop without a noticable difference.  Each data capture is taking about 159.6 mS without DMA and about 162 mS with the enable command placed just before the loop begins.  I was hoping to see the 10x improvement in speed that I have noticed in different write-ups.

 

Thanks,

-David

0 Kudos
Message 5 of 7
(5,427 Views)

Hi David,

 

Because you're using the USB-GPIB-HS controller, you cannot actually use DMA. In order to get I/O to the USB port, it must go through the CPU first. In order to do DMA and increase the speed at which you're reading, you would need a PCI-GPIB card (something that could bypass the CPU). Below is a link that shows the NI PCI-GPIB card:

 

http://sine.ni.com/nips/cds/view/p/lang/en/nid/203786

 

I apologize for not realizing that you were using USB communication sooner. I hope this helps.

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 6 of 7
(5,420 Views)

Hi Kelsey,

 

I was wondering about that, but was confussed by the way it is presented at the following webpage: http://digital.ni.com/public.nsf/allkb/D4558757DD9F190B862575E500549BE7.

 

Thank you for taking the time to help,

-David

0 Kudos
Message 7 of 7
(5,416 Views)