Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab NI 5112

Solved!
Go to solution
Hello;
 
I decided to write a mex file for using NI 5112 with Matlab. I wrote my mex file but I could not run it any way. When I was running my mex code there is an error message on the matlab command window, like as the bottom.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
 
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\mex_1B92711B-AD13-4568-C29A-44BC1FF98570\GettingStarted.obj 
   Creating library C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\mex_1B92711B-AD13-4568-C29A-44BC1FF98570\templib.x and object C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\mex_1B92711B-AD13-4568-C29A-44BC1FF98570\templib.exp
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_close@4
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_errorHandler@16
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_Read@28
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_SampleRate@8
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_ActualRecordLength@8
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_AutoSetup@4
GettingStarted.obj : error LNK2001: unresolved external symbol _niScope_init@16
GettingStarted.mexw32 : fatal error LNK1120: 7 unresolved externals
 
  C:\MATLAB\BIN\MEX.PL: Error: Link of 'GettingStarted.mexw32' failed.
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
Something is wrong but what.....I could not understant....The blue parts of the error messages (like niScope_init@16 )  are the C/C++ (function) code routines of the NI 5112...(may be Matlab cannot link NI5112 *.dll files. Is it possible... )
 
Could you help me about this problem.  THANKS FOR EVERTHING....
0 Kudos
Message 1 of 9
(5,125 Views)
Solution
Accepted by topic author murat fidan

murat,

 

Thank you for posting on the NI Forums. The reason that you are getting these errors when you try to run your program is that there is not an API for the NI scopes with Matlab®. You have a couple of options. You can use the C API to write code in C and interface with the 5112, you could program in LabVIEW, I also found a forum post where a couple of individuals used the  "Matlab® Node" to make calls to Matlab® from LabVIEW. That forum can be found here. Hope this helps.

Aaron W.
National Instruments
CLA, CTA and CPI
Message 2 of 9
(5,112 Views)

Dear Aaron;

 

Thanks for your suggestions. But I could not understant what you mean: "The reason that you are getting these errors when you try to run your program is that there is not an API for the NI scopes with Matlab®".

 

I must use Matlab m file for my Ph.D thesis. I could not use LabVIEW (because I don't have a licence for LabVIEW). Is it possible to use my NI 5112 with Matlab®. Can you help me How can I solve this problem and compile my mex files urgently.... Please......

 

0 Kudos
Message 3 of 9
(5,101 Views)

Murat,

 

When I mention that there is not an API for the NI Scopes with Matlab®. I mean that our driver for our NI-Scope devices has not been designed specifically to work with Matlab® without first using LabVIEW. I do not have any idea how to about how to get the mex files to compile correctly as I have not used Matlab® with any of our devices. It sounds like you are at a university, and most universities have a site license for LabVIEW, so that would be my best suggestion for getting the scope acquiring data. The other option is to use Visual Studio or other C Compiler to write the code in C, as the NI-Scope driver will support development with C. If you could make a dll file from the C code you might be able to call that dll from within Matlab®. Once again, I am not familiar with Matlab® and am not sure if this will work or not. Those are a couple of suggestions that I would suggest looking into. Another option is to talk to MathWorks, Inc. who makes Matlab® and see if they have any suggestions for interfacing their software with the 5112. 

 

You might also look into look into the NI LabVIEW Math Interface Toolkit, which allows you to call LabVIEW applications in Matlab®. It requires you to build the program with LabVIEW, but it might be an option. You can find the link to the toolkit here

 

 

 MATLAB is a registered trademark of The MathWorks, Inc.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 4 of 9
(5,093 Views)

Aaron W.

 

Thanks for your suggestions again. I want to explain why  persisting on the Matlab mex file:

 

 I am able to run my NI 5112  with C, Visual C++, Visual Basic and Visual C#. I dont have any problem with these languages related with NI 5112 . But I must use Matlab Wavelet Transform tool kits for my subjetc. I wrote a gui application on Matlab using with Matlab GUI interface (this application uses  Matlab Wavelet Transform tool kits to process data). But I need a code to acquire data from NI 5112  . This code must be base on Matlab codes. I want to take data in my Gui application via this code  and process this data with Matlab Wavelet Transform tool kits synchronously. So I decided to  use mex file (for converting C routines to Matlab routines). There is an C application may be you know which name is GettingStarted. I used this first, but could not and I wrote you....

 

 

I want to ask  last  a question. If I have been understood true , Is it  possible to compile a mex file for NI 5112 with LabVIEW and this mex file can be call from Matlab m files.???. 

0 Kudos
Message 5 of 9
(5,079 Views)

Murat,

 

If you use the LabVIEW Math Interface Toolkit it appears that you will be able to create a MEX-file. On this page here, it mentions "The Math Interface Toolkit connects the two systems by compiling fully-developed LabVIEW applications into MEX-files." My suggestion would be to look into the Math Interface toolkit and see if it will work for your application.

 

 MATLAB® is a registered trademark of The MathWorks, Inc.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 6 of 9
(5,068 Views)

Hello;

 

I downloaded evaluation version of the LabVIEW 8.6v. But I could not find LabVIEW Math Interface Toolkit in it. I think the toolkits must be download separately. But There is no link for evaluation version of  LabVIEW Math Interface Toolkit. Could you help me how can evaluate LabVIEW Math Interface Toolkit free. Is there a way. Thanks for your help...

0 Kudos
Message 7 of 9
(5,031 Views)

Murat,

 

Sorry for the delay in reply, but I have done some research into what exactly is included in the Evaluation DVD. I thought that the Math Interface Toolkit might be included, but I found out that the toolkit is NOT included in the DVD. I was unsure as to why, but I found out that our Math Interface Toolkit is not one of our toolkits where we offer for trial version. We offer only some of our toolkits for trial version, but unfortunately this is not one of them. The only way to use the toolkit would be to purchase it. I apologize for the inconvenience. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 8 of 9
(5,015 Views)

Murat, hopefully this doesn't reach you too late..

 

You have two options to use NI hardware with Matlab.

1) You can either use the Matlab Instrument Control Toolbox (which is what you would usually use to communicate with instruments) and use the NI IVIScope driver to interface with the 5112.

http://www.mathworks.com/products/instrument/supportedio13785.html

The 5112 IVI driver is here: http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=E3B19B3E950B659CE034080020E748...

2) Or, you can use the C DLL interface in Matlab to talk to the NI created driver DLLs.

Further, NI provides you with example code to have most if not all of the functionality of a traditional boxed instrument for free.

 

Best of luck with your thesis if you're not yet finished with it.

 

Regards,

 

Tolga Cengiz

Field Sales Engineer

National Instruments

Message Edited by TMC-NI on 12-18-2009 06:43 PM
0 Kudos
Message 9 of 9
(4,578 Views)