From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Binary Dump using DMA (Direct Memory Access)

Solved!
Go to solution

Hello all,

 

We are trying to do a short-term frequency measurement using the SR620 (Frequency Counter) via a GPIB-USB connector. We are trying to understand how the GPIB commands work, and it seems that normally you send a query and then ask it to read what the instrument is saying. However, since we are trying to do a short-term frequency stability measurement, we are using the Binary Dump (BDMP - explained in the manual, link below) command. To read this data, you do not use the standard read function, you use this process called Direct Memory Access (DMA). The maual talks about DMA, and the example code in the maual seems to use DMA to read the resulting data.

 

We have been able to trigger the "binary output" display on the instrument using both LabVIEW and the Interactive Control through NI-MAX. The question now is: How do we implement DMA using LabVIEW? More specifically, how do we implement DMA reading from the SR620. There does not seem to be anything close to it in the LabVEIW included code. There are examples that use DMA with IVIs, but we have had difficulties modifying them to work with the SR620 code.

 

 

Useful links:

Manual for SR620: http://www.thinksrs.com/downloads/PDFs/Manuals/SR620m.pdf

Possible DMA example??: https://decibel.ni.com/content/docs/DOC-9893

DMA explination: http://zone.ni.com/reference/en-XX/help/371599J-01/lvfpgaconcepts/fpga_dma_how_it_works/

Way to make DMA: http://www.ni.com/white-paper/4534/en/

       Note: When we haven't gotten past step 1 because we have issues adding a new FPBA Target because there are "<no items found>"

0 Kudos
Message 1 of 8
(3,033 Views)
Those links have nothing at all to do with GPIB communication. You do not have one of the FPGA devices from NI.
0 Kudos
Message 2 of 8
(3,028 Views)
Solution
Accepted by topic author Smurfing

Yeah, back in '89, you probably did need to use a DMA to store the data quick enough.  Things have gotten a lot faster in 25 years.  What I have done for somehting similar is save the data to a file as it is being read.  If you need further performance, use a Producer/Consumer.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 8
(2,971 Views)

Thank you both!

 

Crossrulz, that fixed the DMA issue nicely.

 

Now I just need to format and convince the freq counter that I wants to tell me everything it knows. 😛

0 Kudos
Message 4 of 8
(2,940 Views)

In further looking into this operation, I have found that (especially for larger dumps), there is a significant change in runtime that depends on the byte count you input to the VISA Read function. I am not entirely convinced that we are not missing data with this operation, but there is no good way to check. There is a 256 bit buffer that is present, even for binary dump. Here is the data I took.

 

Parameters, Same for all runs          
Timeout (ms) 180000        
Number dump points 65535        
Gate Time (s) 1.00E-06        
           
           
Byte count for VISA Read 4194240 50000 500    
Elapsed time (ms) 301,989 420,846 427,352    
Note: tick count was placed on the error wire directly before and after the while loop, and the elapsed time is the difference between the tick counter

 

I have attached code for my testing setup as well as a suggested alternative that involves calculating the number of bytes that need to be read exactly.

0 Kudos
Message 5 of 8
(2,908 Views)

One thing you should do to speed up your loop function is to preallocate your array.  Use Initialize Array with the data type a U8 and the number of elements set to the number of requested readings multiplied by 8 (64 bits per reading).  Then inside of the loop, use Replace Array Subset.  This will keep you from constantly allocating memory to expand your array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(2,898 Views)

Would looping and reading the data in smaller bits (assuming I preallocate the array) be faster than reading it with one command?

0 Kudos
Message 7 of 8
(2,895 Views)

If the buffer and timeout can handle it, go with the single call.  I'd be surprised if the buffer can handle it though.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(2,879 Views)