The following commands seemed to work for me in 32-bit Matlab 184.108.40.2062 (R2007b), with no compilers installed other than Lcc-win32:
>> % cd to LIBEC_PATH, defined below
>> loadlibrary('libec.dll', 'labview.h');
>> calllib('libec', 'CHI_About'); % displays libec dialog box
- contains libec.dll
- contains "Microsoft.VC90.CRT" folder
- contains Qt*.dll runtime files
- contains labview.h from "testsdk.zip"
- 64-bit Matlab is just not supported for our 32-bit libec.dll?
- How do you use Matlab's calllib() to pass pointers to void CHI_getExperimentData(float x, float y, int n) ?
- When I try to run the same commands from an M-File, however, I get an error message
Mex file entry point is missing...
??? Invalid MEX-file 'C:\libec\libec.dll'
I am not sure why it doesn't work the same in a .m file and in command line but it should, preventing that you are in the right directory of course.
In my experience, "Mex file entry point is missing." is usually when you try to compile a mex file for matlab and you forgot the equivalent of the "void main" for a C program that is "void mexFunction" for a matlab mex. That does not seems to be relevant here.
As loadlibrary use the compiler you set in matlab, you may try to use the same compiler you used to create the dll instead of the matlab compiler. To do so just type "mex -setup" and it should find all the compatible compilers you have on your computer, which depend on the version of Matlab you have. For 2007b you can use VC2005 for instance. You may need an earlier version of matlab if you are using a more recent version of VC.
Regarding the calllib issue with your "CHI_getExperimentData" function, since you have arguments to pass to the function, you should use:
a, b ,and c being the values you want to pass as arguments.
The following Matlab code works for me, using the new functions rolled out in libec 0.0.8.2:
% make sure current directory contains
% Microsoft.VC90.CRT folder
% Q_PROPERTY IDs: run plotoptions.exe and hover with mouse
% 2014-08-20: or testsdk.exe, but you may have to compile it
calllib('libec', 'CHI_setParameter', 'm_ei', 0.01);
calllib('libec', 'CHI_setParameter', 'm_eh', 0.01);
calllib('libec', 'CHI_setParameter', 'm_el', -0.01);
calllib('libec', 'CHI_runExperiment'); % non-blocking
disp 'Waiting for experiment to end'
while calllib('libec', 'CHI_experimentIsRunning')
disp '...' % <- call CHI_getExperimentData() in real time
n = 50;
x = zeros(n, 1);
y = zeros(n, 1);
px= libpointer('singlePtr', x);
py= libpointer('singlePtr', y);
calllib('libec', 'CHI_getExperimentData', px, py, n)
plot(px.value, py.value) % has extra points at the origin...
Note (2014-07-30): The calls to "CHI_setParameter" are not optional, because default CV voltages are all 0 and thus cannot be run (give it a try on our standard Windows software).
Log in to post a comment.