Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading ADC channels using matlab and DAQmx functions

Solved!
Go to solution

Dear users (I and matlab),

I use the attached matlab script to read one channel of a 6009 ADC card. The script runs fine since the status of the various command are returned as "0" (means a success).

Nevertheless I get only null values of the samples read from the ADC.

It seems some configuration parameter is missing.

I have read the poor documentation available on the subject (DAQmx help) but I can't see any flaw.

Somebody have the experience of programming ADC using matlab and its DAQ toolbox?

(I guess the b is the same with any other language as long as you use DAQmx librairies)

May thanks for your help

Regards

Frederic

 

 

0 Kudos
Message 1 of 2
(765 Views)
Solution
Accepted by topic author FredCl

I found the solution which was that I should have used ' ' instead of 'null' in the cmd line:

 

[status_Cre] = daq.ni.NIDAQmx.DAQmxCreateAIVoltageChan(TaskHandle,'Dev1/ai0',' ',daq.ni.NIDAQmx.DAQmx_Val_Diff,-5,5,daq.ni.NIDAQmx.DAQmx_Val_Volts,'null')

 

should be:

 

[status_Cre] = daq.ni.NIDAQmx.DAQmxCreateAIVoltageChan(TaskHandle,'Dev1/ai0',' ',daq.ni.NIDAQmx.DAQmx_Val_Diff,-5,5,daq.ni.NIDAQmx.DAQmx_Val_Volts,' ')

 

What is a bit misleading is the fact the "status_Cre " is 0 which menas the success of the command.

 

For information I have listed the links which have been helpfull for my own understanding, it might help others :


https://fr.mathworks.com/matlabcentral/fileexchange/27609-daqmx-examples?s_tid=srchtitle_DAQmx_8
https://www.jensroesner.com/work/matlab/index.html
https://scipy-cookbook.readthedocs.io/items/Data_Acquisition_with_NIDAQmx.html
https://github.com/sppmg/matlab-ni-daqmx/blob/master/DAQmxMidLib/DAQmx_const.m
https://web.mst.edu/~cottrell/ME240/Resources/NI-DAQmx%20Driver%20Error%20Codes.htm

Message 2 of 2
(714 Views)