Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I finish reading a buffer that is smaller than the DMA block size using interrupt transfers

Hello,
I'm doing a continuous read from my DAQ 6354 on both channels using DIO READ in a While Loop, then stopping the data source and continuing to run the while loop until the Scan Backlog has reached zero, however there is some data remaining in the buffer of a size less than the DMA block size. I then want to switch to interrupt driven tranfers to finish reading out that remaining data.

I've tried placing a SET DAQ DEVICE INFORMATION after the first read loop to set the device to interrupt transfers, then initiating a second DIO READ loop in hopes of reading out the buffer completely. I can't do the whole transfer via IRQ as I need to keep speed up but I also don
't want to lose the last bit of data. How do I change the method of reading the data from DMA to interrupt using the same buffer and not trashing the last data? Right now I get a 10003 error when I try to switch modes as outlined above.

Thanks in advance,
M Erickson
0 Kudos
Message 1 of 2
(3,166 Views)
Hi,

Usually, the best way to read data when the data source has stopped is to monitor the scan backlog (which you are doing) and then create a shift-register on your loop. The scan backlog should write to the shift-register on the right edge of your loop. The "number of scans to read" port of your DIO Read.vi should read the shift-register value coming from the left side of your loop (contains the previous iterations scan backlog). Make sure that you input a different value then the scan backlog on your first iteration otherwise there won't be anything read since you have obtained the scan backlog yet. This can be done by initializing the shift-register with an initial "number of scans to read" value. The shipping example Cont Pattern Input.vi, which you
can find by selecting Help >> Find Examples >> Hardware Input and Output >> DAQ >> Digital I/O >> 653x, has the general structure for performing this.

However, if you want to change one of your data acquisition parameters while you are acquiring (DMA vs Interrupts), you will have to stop your acquisition, change the parameter you want and then start it again. You can do this by using Digital Buffer Control.vi in your code and using the control code "Reserved" to temporarily stop your VI. Then you can use Set DAQ Device Info.vi to change from DMA to Interrupts. Then finally, you can use the Digital Buffer Control.vi to "Start" you acquisition again. Although I haven't tested this, it should work.

The first method I described is definitely the preferred method. Hope that helps.

Ron
0 Kudos
Message 2 of 2
(3,166 Views)