Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Use M-Series cards with DAQmx in Matlab!

Hello,

 

I am trying make a communication between Matlab and my NI-USB6221 card.

 

Here is my Matlab code :

 

loadlibrary('nicaiu.dll','nidaqmx.h','alias','myni')

taskh1=uint8(1);

[a,b,taskh1] = calllib('myni','DAQmxCreateTask','master',taskh1)

 

I precise that the files 'nicaiu.dll' and 'nidaqmx.h' are in the Matlab workspace (so I don't have to use addpath). And I don't have Data Acquisition Toolbox.

 

And this is what I get :

 

Warning: Warnings messages were produced while parsing.  Check the
functions you
intend to use for correctness.  Warning text can be viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 381
  In dll_nidacmx at 6
??? Error using ==> loadlibrary at 461
There was an error loading the library "C:\Documents and
Settings\uidt1982\Desktop\CARTE_NI\nicaiu.dll"
La procédure spécifiée est introuvable.

 

Error in ==> dll_nidacmx at 6
loadlibrary nicaiu.dll nidaqmx.h

Caused by:
    Error using ==> loaddefinedlibrary
    La procédure spécifiée est introuvable.

 

For the ones who doesn't speak french at all, the phrase in bold means : "the specified procedure cannot be found"

 

I don't understand this error and I am really stuck...

 

Some help would be welcome.

0 Kudos
Message 101 of 106
(1,470 Views)

OK, it works today...

 

In fact, it seems that my lib file was not recognized

0 Kudos
Message 102 of 106
(1,489 Views)

Hello, I want to generate an executable program using Matlab.

 

This executable will use DAQmx functions to acquire analog data for instance.

 

There is no problem with creating the executable. I build including "nicaiu.dll", "NIDAQmx.h", "NIDAQmx.lib", and all others functions needed.

 

But, when I want to run the executable, here is the response from Matlab :

 

There was an error loading the library
"C:\Users\...\Windows\System32\nicaiu.dll"
Undefined function or variable 'myni_proto'.

 

How can I fix it ??

0 Kudos
Message 103 of 106
(1,428 Views)

Nobody ??

0 Kudos
Message 104 of 106
(1,405 Views)

Hi,

 

I am having the same problem as you except I am not looking to create an excecutable progrma in matlab. When I try to run the folowing piece of code:

 

loadlibrary('nicaiu.dll','nidaqmx.h','alias','myni')

 

I get loads of errors such as :

 

Warning: Warnings messages were produced while parsing. Check the functions you intend to use for correctness. Warning text can be
viewed using:
[notfound,warnings]=loadlibrary(...)
> In loadlibrary at 344
Warning: The data type 'error' used by function DAQmxGetTaskAttribute does not exist.
> In loadlibrary at 403
Warning: The data type 'FcnPtr' used by function DAQmxRegisterEveryNSamplesEvent does not exist.
> In loadlibrary at 403
Warning: The data type 'FcnPtr' used by function DAQmxRegisterDoneEvent does not exist.
> In loadlibrary at 403
Warning: The data type 'FcnPtr' used by function DAQmxRegisterSignalEvent does not exist.
> In loadlibrary at 403
Warning: The data type 'error' used by function DAQmxGetChanAttribute does not exist.......

 

I'm not sure what I'm doing wrong I guess there is a fundamental problem with the nicaiu.dll? It's very unusual because yesterday I used the same line of code and got a different error which was the one you had in your first post. How did you get matlab to recognise your library?

 

thanks,

 

Alan

0 Kudos
Message 105 of 106
(1,345 Views)

64 bit Matlab (2015a or 212b) crashes every time I try to create a task with NI-DAQmx Base 14.0. Surprisingly, 32 bit Matlab (2010a) seems to work fine. Any ideas how to solve the problem with 64 bit Matlab?

 

Here is a simple way to replicate my error. Load nidaqmxbase from Ni-DAQmx Base 14.0 library. Then call DAQmxBaseCreateTask.

Example code:

loadlibrary('/Library/Frameworks/nidaqmxbase.framework/Versions/14/nidaqmxbase', ...
            '/Applications/National Instruments/NI-DAQmx Base/includes/NIDAQmxBase.h', ...
            'alias', 'nidaqbase');
task0 = libpointer('uint32PtrPtr',0);
calllib('nidaqbase','DAQmxBaseCreateTask','',task0);

 

Here is Matlab's crash dump:

 

Configuration:
  Crash Decoding      : Disabled
  Crash Mode          : continue (default)
  Current Graphics Driver: Unknown hardware
  Current Visual      : Quartz
  Default Encoding    : ISO-8859-1
  Host Name           : new-host-2.home
  MATLAB Architecture : maci64
  MATLAB Root         : /Applications/MATLAB8.5.app
  MATLAB Version      : 8.5.0.197613 (R2015a)
  OpenGL              : hardware
  Operating System    : Darwin 13.4.0 Darwin Kernel Version 13.4.0: Wed Mar 18 16:20:14 PDT 2015; root:xnu-2422.115.14~1/RELEASE_X86_64 x86_64
  Processor ID        : x86 Family 6 Model 70 Stepping 1, GenuineIntel
  Virtual Machine     : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  Window System       : Quartz

Fault Count: 1


Abnormal termination:
std::terminate()

Register State (captured):
  RAX = 0000000054b0786c  RBX = 0000000122255a50
  RCX = 00007fcb1fa180d0  RDX = 0000000054b07820
  RSP = 0000000122255300  RBP = 0000000122255620
  RSI = 00007fcb1dce1b00  RDI = 0000000132265000

   R8 = 00007fcb1dce7910   R9 = 0000000054a204e6
  R10 = 00000001322bb000  R11 = 00007fcb240253e0
  R12 = 0000000000000000  R13 = 0000000000000000
  R14 = 00000001136bd420  R15 = 0000000000000000

  RIP = 000000010ffad8ab  RFL = 00007fcb2406a370

   CS = 0000000054b07db0   FS = 0000000132687000   GS = 00007fcb2406a4a0

Stack Trace (captured):
[  0] 0x000000010ffa8964 /Applications/MATLAB8.5.app/bin/maci64/libmwfl.dylib+00031076 _ZN2fl4diag15stacktrace_base7captureERKNS0_14thread_contextEm+00000052
[  1] 0x000000010ffac02b /Applications/MATLAB8.5.app/bin/maci64/libmwfl.dylib+00045099 _ZN2fl4test17terminate_handledEv+00000763
[  2] 0x000000010ffabac7 /Applications/MATLAB8.5.app/bin/maci64/libmwfl.dylib+00043719 _ZN2fl4diag13terminate_logEPKcPK17__darwin_ucontext+00000119
[  3] 0x000000010fa17f9b /Applications/MATLAB8.5.app/bin/maci64/libmwmcr.dylib+00380827 _Z32mnRunPathDependentInitializationv+00002875
[  4] 0x000000010fa18217 /Applications/MATLAB8.5.app/bin/maci64/libmwmcr.dylib+00381463 _Z32mnRunPathDependentInitializationv+00003511
[  5] 0x000000010fa17908 /Applications/MATLAB8.5.app/bin/maci64/libmwmcr.dylib+00379144 _Z32mnRunPathDependentInitializationv+00001192
[  6] 0x000000010fa17384 /Applications/MATLAB8.5.app/bin/maci64/libmwmcr.dylib+00377732 _Z22mnInstallCrashHandlersv+00000420
[  7] 0x00000001134b41d1                           /usr/lib/libc++abi.dylib+00147921 _ZSt11__terminatePFvvE+00000008
[  8] 0x00000001134b3c5b                           /usr/lib/libc++abi.dylib+00146523 _ZN10__cxxabiv1L22exception_cleanup_funcE19_Unwind_Reason_CodeP17_Unwind_Exception+00000000
[  9] 0x00000001132c8fa1                           /usr/lib/libobjc.A.dylib+00057249 _ZL26_objc_exception_destructorPv+00000000
[ 10] 0x000000011204a12d /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+01380653 -[NSObject(NSObject) doesNotRecognizeSelector:]+00000205
[ 11] 0x0000000111fa5272 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00705138 ___forwarding___+00001010
[ 12] 0x0000000111fa4df8 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation+00703992 _CF_forwarding_prep_0+00000120
[ 13] 0x000000013b6ff6af /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+13133487 _ZN19MainLoop_MacCocoaUIC2Ev+00000095
[ 14] 0x000000013b6ff73c /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+13133628 _ZN19MainLoop_MacCocoaUI4InstEv+00000060
[ 15] 0x000000013b7e2dea /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+14065130 WSendEvent+00000250
[ 16] 0x000000013b7e3f8f /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+14069647 WCreateEx+00000543
[ 17] 0x000000013b7e420e /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+14070286 _ZN8WMgrCore10InitializeEv+00000254
[ 18] 0x000000013b793790 /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+13739920 _Z12InitManagersiPKPKcPiP14MGAppInterfaceP16MGUIAppInterfaceS0_+00000512
[ 19] 0x000000013aabbb53 /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+00273235 _Z10MGMainInitiPKPKcPb+00000179
[ 20] 0x000000013aabbf84 /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+00274308 _Z6MGMainiPKPKc+00000132
[ 21] 0x000000013aabcaed /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+00277229 _Z11SysUIThreadPv+00000013
[ 22] 0x000000013b854e9e /Library/Frameworks/LabVIEW 14.0 Runtime.framework/LabVIEW 14.0 Runtime+14532254 _Z15ThreadCoverProcPv+00000094
[ 23] 0x000000011385d899            /usr/lib/system/libsystem_pthread.dylib+00006297 _pthread_body+00000138
[ 24] 0x000000011385d72a            /usr/lib/system/libsystem_pthread.dylib+00005930 _pthread_struct_init+00000000
[ 25] 0x0000000113861fc9            /usr/lib/system/libsystem_pthread.dylib+00024521 thread_start+00000013

0 Kudos
Message 106 of 106
(1,069 Views)