Matlab API Front Panel version 4

When you install front panel version 4, the matlab api that it is installed with doesn’t work. Here you can download a zip file which contains modifications of the matlab api files which work with version 4:

www.sim.me.uk/temp/OkMatlabApiV4Win32.zip

It won’t stay there forever - I invite the forum adminstrator to move it into the downloads section. Instructions follow (this should work for XEM3010, for windows either XP or windows 7, and for matlab 2007-2010 - I don’t know about other devices, matlab versions or OSs; I have this working on 32-bit winXP and 64-bit windows 7, but to have it working on 64-bit windows I am using 32-bit matlab and the 32-bit front-panel drivers).

Once you have installed front panel version 4, under your installation directory (e.g. C:\Program Files\Opal Kelly\FrontPanelUsb) you have the API folder. Under API you have:

  • okFrontPanel.dll
  • okFrontPanelDLL.h
  • Matlab

In matlab I use these lines of code:

addpath([paths.opalKelly ‘\FrontPanelUSB\API’]); % The actual DLL is here
addpath([paths.opalKelly ‘\FrontPanelUSB\API\Matlab’]); % The DLL header file and all the matlab object definitions are here

But to use these lines of code, you have to rename or remove API\okFrontPanelDLL.h so that matlab doesn’t find it on it’s path (there are other ways of organising your files but this is what I do).

under API\Matlab, there is:

  • @okusbfrontpanel
  • okFrontPanelDLL.h

Replace this header file and this folder of matlab functions with those in the above zip file. Then you can use the matlab api as intended. Here is some example code which I use for starting up and programming the device:

loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);

xPointer = calllib(‘okFrontPanel’, ‘okFrontPanel_Construct’);
numDevices = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceCount’, xPointer);
if numDevices == 0
error(‘error: there are no devices connected’)
elseif numDevices > 1
error(‘error: there is more than one device connected’)
else
disp(‘There is one device connected’)
end

disp('Device model: ’ calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListModel’, xPointer, 0)])
serialNumber = calllib(‘okFrontPanel’, ‘okFrontPanel_GetDeviceListSerial’, xPointer, 0, ’ ', 10);
xem = okusbfrontpanel(xPointer);
if isopen(xem)
disp(‘The FPGA is already open.’)
else
disp(‘Attempting to open the FPGA.’)
resultOfAttemptingToOpenFpga = openbyserial(xem, serialNumber);
end
resultOfAttemptingToConfigureFpga = configurefpga(xem, ‘.bit’);
disp('Result of attempting to configure the FPGA: ’ resultOfAttemptingToConfigureFpga])

% Then you can use the IO functions, e.g.:

setwireinvalue(xem, 0, 1024, 65535);
updatewireins(xem);

Problems: contact me

Hello–

Thanks for posting this. We have retrieved it and can incorporate any changes you made to our existing FP library. We would also like to credit you (with or without contact information) in our README for the Matlab API. Could you please contact support@opalkelly.com and let us know if this is ok?

Thanks again, I’m sure other customers will find this helpful.

Are you sure this was written for FrontPanel 4? In FrontPanel 4, we have okCFrontPanel instead of okCUsbFrontPanel. In your modified DLL, you still refer to okCUsbFrontPanel and the version date is pretty old. Was this maybe FrontPanel 3.x?