Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Mixing analog and digital channels

Hi!

I ran into what seems a similar problem.
I am programming a 6221-M under Matlab, using the C-libraries. So excuse the strange syntax.

I try to sample AI channels and one counter, using the BNC 2120 device.
I have two tasks at the moment, supposed to run on the same device. Task(h)1 is AI and task(h)ctr is the Counter.
for each analog sample, I want to read out the current counter.
The counter works, I was able to test it in MAX. It is connected to PFI8.

Both tasks should start when an external Trigger on PFI0 occurs.

Here's my code (declarations omitted for clarity - hopefully):
[a,b,taskh1] = calllib('myni','DAQmxCreateTask',taskname1,taskh1);
[a,b,taskhctr] = calllib('myni','DAQmxCreateTask',taskname4,taskhctr)
[a,b,c,d] = calllib('myni','DAQmxCreateAIVoltageChan',uint32(taskh1),taskchans1,'',-1,-10,10,DAQmx_Val_Volts,'');
[a,b,c]=calllib('myni','DAQmxCreateCICountEdgesChan',taskhctr,'Dev1/Ctr0','',DAQmx_Val_Rising , 0,DAQmx_Val_CountUp )
[a,b]=calllib('myni','DAQmxCfgSampClkTiming',taskh1,'',fsample,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,nsample)
[a,b]=calllib('myni','DAQmxCfgSampClkTiming',taskhctr,'/Dev1/ai/SampleClock',fsample,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,nsample)
[a,b]=calllib('myni','DAQmxCfgDigEdgeStartTrig',taskh1,'/Dev1/PFI0',DAQmx_Val_Rising );
[a,b]=calllib('myni','DAQmxCfgDigEdgeStartTrig',taskhctr,'/Dev1/ai/StartTrigger',DAQmx_Val_Rising )
This last line gives me an
-200452 = DAQmxErrorAttributeNotSupportedInTaskContext = Specified property is not supported by the device or is not applicable to the task.
It does not matter which terminal I specify, even 'nonsense' will give the same error.

I haven't tried this duplicate count prevention, because my problem seems to be more basic than duplicate counts - it does not count at all.

Any ideas? Do digital/counter channels need another set-up function?
I had a serious look at the "Finite Counter Input Programming Flowchart" in the C reference, but couldn't make much use of it 😕

Regards
Jens
0 Kudos
Message 11 of 15
(2,106 Views)
I think this is really an artifact of how the data is transferred in the driver. In order to optimize throughput across the PCI bus, the DAQmx driver will read 8 bit digital samples from the device until it can DMA 32 bits of data to host memory. While this does introduce some latency, it greatly increases overall throughput across the PCI bus for higher speed acquisitions.
0 Kudos
Message 12 of 15
(2,098 Views)
Sorry, that last post was in response to Daytona Ed's question (response 9).
0 Kudos
Message 13 of 15
(2,093 Views)
Hi Jens,
sorry for contacting you directly. But this seems to be the best way to get my matlab code running.
The only and pretty simple thing I have to do is acquiring analog data using BNC 2110.
Could you please send a piece of code containing the required steps (how to load which library etc.).
Your help will be appreciated.
Many thanks in advance
Andreas
0 Kudos
Message 14 of 15
(2,060 Views)
Hi Andreas!

Sorry for the delay!
I started a separate thread for using DAQmx with Matlab.
I hope I have a download ready by tomorrow!
So long:
http://forums.ni.com/ni/board/message?board.id=250&message.id=10167

Jens
0 Kudos
Message 15 of 15
(2,020 Views)