06-20-2014 11:07 PM - edited 06-20-2014 11:12 PM
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
06-24-2014 09:00 AM
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
06-24-2014 04:48 PM
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
06-25-2014 07:09 PM
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?
06-26-2014 02:03 AM
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
06-26-2014 07:10 PM
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.
06-26-2014 08:02 PM
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