From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

M-Series: DMA Values mixed up?

Hi,

 

I'm currently developing a DLL Device-Driver for a Windows XP / RTX Environment. This DLL-File is used by a Measurement-Application to access a PCI-6250 Card for analog measurement.

 

The PCI-6250 will perform a continuous measurement at a fixed Sample Rate (currently 250000 Samples / second, but this can be changed). The application will then call a GetValue() Function in my DLL, which is supposed to return the current ADC-Value for all analog channels.

 

This is where my problem is: It seems to me, there is no way to retrieve the current AI-Value from a M-Series Device, is this correct?

 

Since the Application cannot be changed, i tried used the following workaround for this problem:

 

I set up a DMA-Memory with double the size of all channels measured (e.g. 16 byte for 4 AI-Channels). In theory, i would expect that the memory is continuously overwritten, so whenever i read the x-Channels, i would get the latest value written to the DMA-Buffer. For this to work I removed the buffer overflow check from the tDMAChannel::read function.

 

However, this does not work as expected. The data in the DMA-memory is completely mixed up.

 

When I read data, it looks like this:

 

Read 0 --- 

CH0: 5V

CH1: 5V

CH2: 1V

CH3: 5V

 

Read 1 ---

CH0: 5V

CH1: 1V

CH2: 5V

CH3: 5V

 

Read 2 ---

CH0: 1V

CH1: 5V

CH2: 5V

CH3: 5V

 

It's a little difficult to explain, but I hope you get the idea ... the values in the DMA-Buffer are correct, but the data is simply not at the location where it is supposed to be.

 

Is anyone able to help me with this?

0 Kudos
Message 1 of 3
(7,731 Views)

I did some more debugging yesterday to find out what the problem is.

 

By monitoring the memory of the DMA, i can verify that the problem is not in my DMA-Read operation ... the data mixup definitly happens while writing.

 

The first few data blocks are correct, but at some point the data for the last channel has the value of the first channel. It's like the DMA suddenly "forgets" the last channel.

 

Since we really need this to work in some way, is it possible to get some more documentation about how DMA-Writing in Hardware is done? Could there be a miscalculation in the DMA-Write Address or something like this?

 

In case this is not possible, is there any other way to retrieve the current ADC-Channel value from the Cards?

0 Kudos
Message 2 of 3
(7,711 Views)

Hello,

 

Does anything happen to make the data start appearing in the wrong memory location?  What happens if you perform a straight-forward continuous acquisition on the four channels into a reasonably sized buffer?

 

What are the number of samples you are configuring in the AI_SC_Load registers?

 

Please see aiex1 in the M Series DDK.  It shows you how to get the current value out of the ADCs.  However, there are multiple register accesses involved with starting the scan, making sure it is finished, and finally retrieving the data.  This may not meet your timing requirements, but it is a well documented way of getting the current value of the ADCs.

 

Thanks,

Steven T.

0 Kudos
Message 3 of 3
(7,687 Views)