Quantcast
Channel: Measurement Studio for VC++ topics
Viewing all articles
Browse latest Browse all 656

6361 PCIe

$
0
0

Hello

 

I am trying to get a real-time read out of 2 analogue channels on a NI 6361 using Linux, with a sample rate of 500KHz.

I have successfully installed the Linux DAQmx drivers.

 

I have the following C++ driver calls (simplified and excuse any typos I have typed it manually from dev PC):

 

- DAQmxResetDevice("Dev1") // reset settings on device to start clean

- DAQmxCreateTask("task", taskhandle) // create task

- DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai0", "0", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, NULL) // create channel 0

- DAQmxCreateAIVoltageChan(taskHandle, "Dev1/ai1", "0", DAQmx_Val_Diff, -10.0, 10.0, DAQmx_Val_Volts, NULL) // create channel 1

- DAQmxSetSampTimingType(taskHandle, DAQmx_Val_SampClk) // sample using onboard sample clock

- DAQmxSetSampClkRate(taskHandle, 2000000) // onboard clock rate to 2MHz

- DAQmxCfgSampClkTiming(taskHandle, NULL, 500000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 5000) // 500KHz SR, 5k buffer (I have tried buffer sizes all the way from 100 samples to a full 50K read)

- DAQmxStartTask(taskHandle) // start the task

 

This fails with the following error:

DAQmx Error: A hardware failure has occurred. The operation could not be completed as specified.

Status code: -50152

 

The only way I can get it to work, is to add the following call (for both channels):

DAQSetAIDataXferMech(taskHandle, "dev/ai0", DAQmx_Val_ProgrammedIO). However, I can only get up to 250KHz before getting the following error:

DAQmx Error: Onboard device memory overflow. Because of system and/or bus-bandwidth limitations, the driver could not read data from the device fast enough to keep up with the device throughput. Reduce your sample rate. If your data transfer method is interrupts, try using DMA or USB Bulk. Status code: -2000361.

 

Trying to set DMA (e.g. changing DAQmx_Val_ProgrammedIO to DAQmx_Val_DMA) gives me the same error above when I try to start the task:

DAQmx Error: A hardware failure has occurred. The operation could not be completed as specified.

Status code: -50152

 

I have also tried setting up a read call back using DAQmxRegisterEveryNSamplesEvent, but that gives me the same error. The same also happens when I try to set the input buffer sizes (using DAQmxCfgInputBuffer).

 

I've also tried lower sample rates, removing some of the calls (sample clock rate stuff), only using 1 channel, and I am running out of things to try.

I have checked that DAQmxGetAIDataXferMech confirms that DMA mode is set (when the task does not run).

DAQmxGetDevNumDMAChans returns 8

 

Is there anything else I need to add in order to change the transfer type to DMA?

Why do I need to force it to ProgrammedIO to get it to work at all?

Do I need to do something different to use the callback functionality?

Or does my board have some fault?

 

Many thanks

Matt


Viewing all articles
Browse latest Browse all 656


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>