Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Use M-Series cards with DAQmx in Matlab!

Jens,

Finally it works! I tested with MatLab 7.0 and now I can use all these call functions. yupeee!

There is one last thing I cant figure out:

     [a,b,c,d] = calllib('nicaiu','DAQmxCreateDOChan',get(taskh1,'Value'),...
        'Dev1/port0','',DAQmx_Val_ChanForAllLines)

gives

??? Error using ==> calllib
No method with matching signature.

Error in ==> DAQmx at 58
     [a,b,c,d] = calllib('nicaiu','DAQmxCreateDOChan',get(taskh1,'Value'),...

So analog in works, but not the digital out . I am using the PCI-6143 card with 8AI and DIO.

Ever tried to set tasks up in MAX and then call them via Matlab?

Regards

Wendelin

0 Kudos
Message 11 of 106
(6,945 Views)
Hi Wendelin!

Glad that it works for you!
The error message "No method with matching signature."
indicates that either the number of the input or output arguments is wrong.
Do a libfunctionsview to see what these should be.

> Ever tried to set tasks up in MAX and then call them via Matlab?
I remember thinking about that but I think I never tried.
It would probably be a nice way as long as you do not need full versatility from Matlab.
Worth a try 😉 Looking forward to your findings 🙂

Cya
Jens

0 Kudos
Message 12 of 106
(6,941 Views)

Hi Jens,

Ok, I am probably one of the worst Matlab programmers:

     [a,b,c,d] = calllib('nicaiu','DAQmxCreateDOChan',get(taskh1,'Value'),...
        'Dev1/port0','',DAQmx_Val_ChanForAllLine

 [a,b,c,d]  were the same types as already defined above by other function calls, this gave a mismatch, as I didnt clear them .

By any chance one last question:

reserved=libpointer('uint32Ptr',[]);
digidata=uint8([0,1,0,1,1,1,1,1]);
write = libpointer('uint8Ptr',digidata);

[aDset,bDset,cDset,dDset] = calllib('nicaiu','DAQmxWriteDigitalLines',get(taskh1,'Value'),...
        uint32(1),uint32(1),double(10.0),DAQmx_Val_GroupByChannel,write,reserved,reserved)
%[int32, uint8Ptr, int32Ptr, uint32Ptr] DAQmxWriteDigitalLines(uint32, int32, uint32, double, uint32, uint8Ptr, int32Ptr, uint32Ptr)
% int32 DAQmxWriteDigitalLines (TaskHandle taskHandle, int32 numSampsPerChan, bool32 autoStart, float64 timeout, bool32 dataLayout,
% uInt8 writeArray[], int32 *sampsPerChanWritten, bool32 *reserved);

 

gives me

??? Error using ==> calllib
Pointer types must match data type.

Error in ==> DAQmx at 99
[aDset,bDset,cDset,dDset] = calllib('nicaiu','DAQmxWriteDigitalLines',get(taskh1,'Value'),...

I had thought I had figured that out...but...

Any hint!

Thx again and sorry for bothering so often....

Wendelin

 

0 Kudos
Message 13 of 106
(6,937 Views)
Hi,
Could someone please explain what error -200230 (DAQmxErrorNULLPtrForC_Api) means. I am using the matlab DLL interface with the NI-DAQmx drivers on a PCI-6229 M-Series card.
 
I want to read counter values from a channel created with DAQmxCreateCICountEdgesChan however this error shows up and I cannot understand why.
 
I am calling the function using the method shown below, can anyone see any problems?
 
DataPtr = libpointer('uint32Ptr',[]);
reserved = libpointer('uint32Ptr',[]);
[status Data reserved] = calllib('DAQmxLib','DAQmxReadCounterScalarU32',TaskHandle,10,DataPtr,reserved);
 
There are no errors during task and channel creation, only when I try to read the value.
 
Thanks
Luke
0 Kudos
Message 14 of 106
(6,924 Views)
Hi
I think DataPtr = libpointer('uint32Ptr',[]);
should be
DataPtr = libpointer('uint32Ptr',0);
cause it is a pointer to data, not a char string as the NULL.
Thats my guess
Wendelin
0 Kudos
Message 15 of 106
(6,915 Views)

Hi,

is it  possible with R-serie in Matlab?

thanks

befaiz

0 Kudos
Message 16 of 106
(6,431 Views)
Hi Befaiz!

I am not familiar with the R-Series. I think these are pure FPGA cards that need to be programmed with the LabView FPGA module. I might be wrong, though.
The code I provided basically makes all NIdaqmx (traditional NIdaq similarly) functions available to a Matlab programmer. If the R-series uses NIdaqmx, then you can access them through Matlab as shown.

Best of luck
Jens

0 Kudos
Message 17 of 106
(6,418 Views)
Hi,
thanks for your answer, my problem is,  I want call the configuration of fpga from matlab,
is it possible?
danke
befaiz
0 Kudos
Message 18 of 106
(6,412 Views)
Excellent post.  I spent a good month getting my PCI-6221 to talk to matlab.  I think a lot of people are going to find this useful.
0 Kudos
Message 19 of 106
(6,387 Views)

Hi StimOr,

thanks for your interest ,my sytem is a PXI with FPGA ( R-series 7813R).
 More information about this topic are very auxiliary-rich for me
Ciao
befaiz
0 Kudos
Message 20 of 106
(6,370 Views)