Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading and arraya thro DMA FIFO (PCI7813R)

Solved!
Go to solution

Hi,

 

Situation:

 

I am reading 5 encoder positions with PCI7813R. Format of encoder position data is I32. In continuation is each encoder position converted into U32 format and build into an array using "build array function". Finally is this array guided into for loop where I am writing it into DMA FIFO using "FIFO write function". FIFO depth is set to 16383 and Timeout to 0.

 

At the host side I am trying to read this array from DMA FIFO. Depth of the Host FIFO is set to 1000000. I am using "Invoke method with FIFO read" to read data from FIFO. I am reading 10000 elements each time.  Data output is in continuation converted into I32 format and guided to "decimate 1D array function". I am using 5 indicators to represent Encoder positions on the host side.

 

And now the problem:

Encoder Position 1 shell be displayed on Indicator 1. But every time I close my application and run it once again this position appears on other indicator. Sometimes is Encoder position 1 shown on Indicator 1, sometimes on Indicator 5, sometimes on Indicator 3... Although that Encoder position is shown each time on other indicator it has correct values. What shall I do that I will be receiving Encoder position1 always on Indicator 1, Encoder position 2 on indicator 2...

 

My application was build according to these instructions:

http://zone.ni.com/devzone/cda/tut/p/id/4534

 

Tnx,

Gregor

0 Kudos
Message 1 of 6
(4,696 Views)

Gregor,

 

the channel switching issue that you describe is also covered by the document that you have linked:

 

"The For Loop indexes through each element of the array and passes the data into a DMA FIFO sequentially with a timeout of 5 ticks. This means that if the DMA operation takes longer than 5 ticks, the data value will not be written. This would appear as data switching between channels. In this case, increase the timeout or add a while loop which tries to write as long as the value returned from Full is true. If Full is frequently true, then increasing the size of the DMA FIFO buffer will help."

 

Please  let me know, if increasing the timeout doesn't work for you.

 

Kind regards,

Jochen Klier

National Instruments

0 Kudos
Message 2 of 6
(4,693 Views)

Hi Jochen,

 

Yes, I have made that. I have done tests with timeouts from 1 to 1000 ticks, same situation. I have even tried to implement IRQ routine but it has not brought anything. Decreasing the size of host FIFO really causes channel overlapping which can be seen as blinking values at all five indicators. But in my situation are values clearly visible and correct. Indicators are not blinking.

 

I suppose that something is wrong with indexing?

 

Oh, I have forgotten to mention. My application is working fine if I use separate FIFO on separate DMA channel for separate encoder. But 7813 is only offering 3 DMA channels and I have to transfer Encoder data from five encoders, so I would need five channels.

 

 Tnx,

Gregor

0 Kudos
Message 3 of 6
(4,690 Views)

Gregor,

 

in this case there is probably old data in the FIFO when restarting the application. Please use the Reset method to flush the DMA FIFO.

 

Jochen

Message 4 of 6
(4,688 Views)

Hi Jochen,

 

I have tried that to. Once using "Invoke-stop" function and once with using "invoke reset". Same situation.  Every time I runt that *.vi is each encoder position shown under the other indicator.

 

Tnx,

Gregor

0 Kudos
Message 5 of 6
(4,684 Views)
Solution
Accepted by topic author gregor1980

Sorry Jochen, I have placed reset function at the end of my routine. L I have corrected it (put it on the start of the routine) and now it is functioning as it is supposed to be.

 

Thank you very much once again!

 

Regards,

Gregor

0 Kudos
Message 6 of 6
(4,682 Views)