Picolog 1012 with Matlab

Post your MATLAB discussions here
SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Picolog 1012 with Matlab

Post by SE21733 »

Hello

I just recently acquired Picolog 1012 and would like to interface it with MATLAB 2012a.

I've followed the code provide by Hitesh in 'Writing MATLAB scripts using the PicoScope/Data Logger SDK' thread and here the code I wrote

Code: Select all

clc;
clear;

global data;
loadlibrary('pl1000.dll','pl1000Api.h');
if ~libisloaded('pl1000')
    error('Library pl1000.dll or pl1000Api.h not found') %Check if library file loaded 
end

data.unithandle = 0;
data.serial =[];

[status_open, data.unithandle, data.serial] = calllib('PL1000', 'pl1000OpenUnit', handle);
I run it, but 2 error occured.


Error using loadlibrary (line 254)
A 'Selected' compiler was not found. You may need to run mex
-setup.

Error in PicoLogMatlab (line 5)
loadlibrary('pl1000.dll','pl1000Api.h');


I wonder how to run mex-setup and how to overcome the other error.

Hitesh

Re: Picolog 1012 with Matlab

Post by Hitesh »

Hi,

You need to run mex -setup in the MATLAB command window to setup your compiler.

The loadlibrary line should then work - please make sure that within the pl1000Api.h you have added the line

Code: Select all

#include picoStatus.h
under the '#define __PL1000API_H__' line.

With regards to the line

Code: Select all

[status_open, data.unithandle, data.serial] = calllib('PL1000', 'pl1000OpenUnit', handle);
Please refer to the PL1000 Programmer's Guide - there is no serial number returned from the call to pl1000OpenUnit() function. One tip is to use the libfunctions view command in MATLAB to view the various functions in the library once you have loaded it.

I hope this helps,

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Hello Hitesh, thank you so much replying

Already setup the Mex and I have paste #include picoStatus inside pl1000Api.h. But now I got a new error :(

Error using loadlibrary (line 419)
Failed to preprocess the input file.
Output from preprocessor is:pl1000Api.h
C:\Documents and Settings\Administrator\My Documents\MATLAB\pl1000Api.h(3) : error C2006: '#include' : expected a filename, found 'identifier'
C:\Documents and Settings\Administrator\My Documents\MATLAB\pl1000Api.h(3) : fatal error C1083: Cannot open include file: '': No such file or
directory


I'm also puzzle to why it say 'No such file or directory' cause, my picoStatus.h is inside the same folder as pl1000Api.h

appreciate for your help

regards

Hitesh

Re: Picolog 1012 with Matlab

Post by Hitesh »

Hi,

Did you paste

#include "picoStatus"

or

#include "picoStatus.h" ? -> You need this line if you have used the one above.

The other thing you can try is:

Code: Select all

loadlibrary 'pl1000.dll' 'pl1000Api.h' -addheader 'picoStatus.h';

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

I wrote
#include picoStatus.h

I tried #include "picoStatus.h" as well but it came to an error

Error using loadlibrary (line 419)
Failed to preprocess the input file.
Output from preprocessor is:pl1000Api.h
C:\Documents and Settings\Administrator\My Documents\MATLAB\pl1000Api.h(6) : fatal error C1189: #error : Operating system not defined


by the way, I actually using Windows XP X64 and my Matlab are Win64 , is there anything different than Win32 system ?

Please help

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Hitesh wrote:
The other thing you can try is:

Code: Select all

loadlibrary 'pl1000.dll' 'pl1000Api.h' -addheader 'picoStatus.h';
I'm sorry for asking this...where should we paste this code ? is it inside pl1000Api.h or inside the m-file ?

Hitesh

Re: Picolog 1012 with Matlab

Post by Hitesh »

Hi SE21733,

Our Windows drivers are currently only 32-bit hence they will not be compatible with a 64-bit version of MATLAB - you will need a 32-bit version of MATLAB.

The loadlibrary line is a MATLAB command and so should be called either from your command line or m-file.

Regards,

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Hitesh wrote:Hi SE21733,

Our Windows drivers are currently only 32-bit hence they will not be compatible with a 64-bit version of MATLAB - you will need a 32-bit version of MATLAB.

The loadlibrary line is a MATLAB command and so should be called either from your command line or m-file.

Regards,

I have 32-bit version of Matlab installed in my Windows XP x64, it still giving the same Operating system not defined error..

Btw..Thanks for the reply Hitesh

Hitesh

Re: Picolog 1012 with Matlab

Post by Hitesh »

Hi,

When you ran mex -setup for the 32-bit MATLAB did you select a 32-bit compiler?

The error message is coming from the top portion of the header file:

Code: Select all

#ifndef __PL1000API_H__
#define  __PL1000API_H__

#include "picoStatus.h"

#ifndef WIN32
#error Operating system not defined
#endif


Try the following:

1. Run mex -setup and try selecting a 32-bit compiler, OR
2. Before the #ifndef WIN32 line add the line

Code: Select all

#define WIN32
If option 2 does not work try #define _WIN32

Hope this helps :)

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Hello Hitesh, thank you so much for you assistant :)

I've already done what you suggested by selecting 32-bit compiler and run again the program

No error occur but I just got this warning

Warning: Message from C preprocessor:
lcc preprocessor warning: C:\Documents and Settings\Administrator\My Documents\MATLAB\pl1000Api.h:143 No newline at end of file

> In loadlibrary at 318
In PicoLogMatlab at 5

What is exactly this warning means ? Does MATLAB could now read the device ?

My PicoLog 1012's I/O is currently not connected to anything yet (It supposed to be connected to a load cell sensor)

Hitesh

Re: Picolog 1012 with Matlab

Post by Hitesh »

Hi,

No problem :D

That's just a warning to do with the header file - you might just need to press the return key in the pl1000Api.h file after the #endif on the last line.

MATLAB should now be able to connect to the device.

Try typing the following command after loading the library:

Code: Select all

libfunctionsview 'pl1000'
This will show all the functions available to you.

Best wishes,

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Typed at the command windown
>> libfunctionsview 'pl1000'

but now this error occured :(


Error using methodsview (line 100)
No library lib.pl1000 can be located or no methods for library

Error in libfunctionsview (line 39)
methodsview(qcls, 'libfunctionsview');


I wonder what's wrong ?

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Ok nevermind...I've type again

libfunctionsview 'PL1000' with capital letter and the library pop up :D

thank you anyway...

SE21733
Newbie
Posts: 0
Joined: Fri Oct 05, 2012 12:42 am

Re: Picolog 1012 with Matlab

Post by SE21733 »

Dear Hitesh

sorry for asking again

I got this warning

Warning: The library class 'PL1000' already exists. Use a classname alias.
> In loadlibrary at 181
In PicoLogMatlab at 5


what is it mean ?

Hitesh

Re: Picolog 1012 with Matlab

Post by Hitesh »

Hi,

It looks as though you have already loaded the library and are trying to load it again.

Please check whether you are loading it from the script and the command line.

Perhaps after each run of the script you need to call the unloadlibrary function? Please refer to the MATLAB Help documentation for further information.

Regards,

Post Reply