Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

issue with NI_DAQmxReadAnalogF64

Solved!
Go to solution

Bonjour,

j'utilise la fonction NI_DAQmxReadAnalogF64(TaskHandle,ADC.NumberOfScans,3) sous matlab (toolbox DAQ) pour piloter une carte USB 6229 (par exemple).

Je voudrais lire les canaux en mode entrelacé pour minimiser le delai entre 2 canaux d'acquisition.

La doc de la fonction NI_DAQmxReadAnalogF64 dit ceci:

 

int32 DAQmxReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);

 

Mais quand je rajoute le paramètre associé à "fillmode" Matlab me dit qu'il y a trop d'arguments...

 

Avez vous des suggestions?

Merci d'avance pour votre aide

Frederic

 

0 Kudos
Message 1 of 8
(1,327 Views)

Is this a duplicate post  - https://forums.ni.com/t5/Multifunction-DAQ/Simultaneous-data-taking/td-p/4179876

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 8
(1,289 Views)

Indeed Santo,

we work on the same project and face the same issue.

I apologize to load the forum with double request, but I have guessed that since I got nice feedback in my previous request (speaking in french) it would be as efficient.

Let me know whether we should merge the both request

Cheers

Frederic

 

0 Kudos
Message 3 of 8
(1,282 Views)

Hi dear matab users,

Here are some news,

I have fund that the function "NI_DAQmxWriteAnalogF64.m" I was using has been defined with only 3 parameters (see attached file). By adding the "FillMode" parameter, in the parameter of the function, makes it work fine.

Still I have some questions left if you don't mind:

- running an acquisition with NI_DAQmxReadAnalogF64 gives me always 1000 samples properly acquired. The data above 1000 samples are set to zero whatever the parameters I use (I have attached the matlab script: Debug.m ).

 

- Last issue: I can't find from where the matlab functions which makes use of the C functions described in the "NI-DAQmx C reference Help" are avaialble. Some of them were present on the computer I use but I can't find any trace of them in the matlab DAQ toolbox, nor on the NI website.

 

I have the same issue with the "C" functions described in the "NI-DAQmx C reference Help" themselves. Where are they stored?

 

Many thanks for your help

Cheers

Frederic

 

Download All
0 Kudos
Message 4 of 8
(1,277 Views)

I don't know details about the text API's for DAQmx, but the functions appear pretty similar to the ones I use in LabVIEW.  Here's what I think the problems are:

 

1. You don't set values for ADC.Rate and ADC.NumberofSamples until *after* you pass those variables into your "...CfgSampClockTiming" function.  Be sure to set them *before* making that call.

 

2. In LabVIEW, there's a parameter to choose between Finite or Continuous sampling when configuring the sample clock.  When unspecified, the default is Finite.  When the # of finite samples is unspecified, the default is 1000.

 

3. Your "...ReadAnalogF64" function looks quite a bit different than LabVIEW Read functions.  Dunno what the values 1,0,1e4,1e4 are supposed to represent.

 

4. If indeed your task is set for Finite sampling with 1000 samples (due to things mentioned up in #1 & #2), then the 0's you see after the 1000th sample are probably just initial values of the array.  The Read function would only fill in the 1000 samples you ask for at the beginning of the array.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 5 of 8
(1,266 Views)
Solution
Accepted by topic author FredCl

Many thanks Kevin,

- I guess you point to the solution. Indeed the function NI_DAQmxCfgSampClkTiming proposes the finite/infinite acquisition mode. I will test this ASAP and let ou know.

- Regarding your remark #1, I need to put the ADC.sample after the call otherwise matlab puts an error.

- from where did you get the info, that, by default, the buffer size is 1000? I would have be glad that the Help file mentions that.

 

Cheers

Frederic

 

0 Kudos
Message 6 of 8
(1,262 Views)
Solution
Accepted by topic author FredCl

As to remark #1 and your error, perhaps you can introduce a couple simple temporary variables instead of assigning directly to the special ADC session object?  I don't understand why a direct assignment would be ok *after* configuring sample timing but not *before*, but whatever the reason, the temp variables could help work around the issue.

rate=50000;
numsamp = 5000;
NI_DAQmxCfgSampClkTiming(TaskHandle, rate, numsamp); %%Configures the  acquisition
ADC.rate = rate;
ADC.NumberOfScans=numsamp;

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 7 of 8
(1,257 Views)

Thanks for the advice Kevin.

 

0 Kudos
Message 8 of 8
(1,241 Views)