Matlab API discussion

This thread is for Matlab API discussion.

When I load the library i got two warnings!!

loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
Warning: The function ‘okFrontPanelDLL_LoadLib’ was not found in the library
In loadlibrary at 225
Warning: The function ‘okFrontPanelDLL_FreeLib’ was not found in the library
In loadlibrary at 225

I don’t know if this is a problem!

When i run ok_getdevicelist i get

[sn, id] = ok_getdevicelist

sn =

libpointer

id =

libpointer

I use matlab:
MATLAB Version 7.0.1.24704 (R14) Service Pack 1
And frontpanel 1.3

Regards

Luc

Hi Luc-

Some changes have been made to the API that affect the Matlab version. I’ll post a new version today that is more in-line with 1.3.0 and should solve your problems.

The warnings you get are ok. Matlab is looking through the header file for any prototype it can find to build a function out of. It expects to find those functions within the DLL. In this case – they’re not there because they are used by C callers to load/unload the DLL.

Below are examples of problems I am having interfacing the XEM3010 to Matlab.

  1. Using Matlab, the following warning occurs when loading the library:

loadlibrary(‘okFrontPanel’, ‘okFrontPanelDLL.h’);
Warning: The function ‘okFrontPanelDLL_LoadLib’ was not found in the library
In loadlibrary at 225
Warning: The function ‘okFrontPanelDLL_FreeLib’ was not found in the library
In loadlibrary at 225
Warning: The function ‘okCPLL22393_GetReference’ was not found in the library
In loadlibrary at 225

  1. Also, using Matlab, when getting the device list, it returns the device model, but not the serial number:

ok_getdevicelist

ans =

brdXEM3010

  1. Also when trying the DES demo:

  2. Load the “destop-1000.bit” file to the XEM3010 board

  3. Type the following:

destester
??? Reference to non-existent field ‘ptr’.

Error in ==> okusbxem3010.setpllconfiguration at 17
calllib(‘okFrontPanel’, ‘okUsbXEM3010_SetPLLConfiguration’, xid.ptr, getobjptr(pllid));

Error in ==> des_setup at 16
setpllconfiguration(xem, pll);

Error in ==> destester at 13
xem = des_setup()

  1. My configuration is as follows:

XEM3010 Board: Firmware Version 1.2 (S/N: HfxaTtSgjZ)

MATLAB: Version 7.0.1.24704 (R14) Service Pack 1

FrontPanel: Version 1.3.1

okFrontPanelDLL.h: Rev: 237 Date: 2005-12-10 16:34:50 -0600 (Sat, 10 Dec 2005)

Is there available a matlab example file for the XEM3010 board that will:

  • load the ‘ok’ library
  • exercise wire in/out functions
  • exercise trigger in/out functions
  • exercise pipe in/out functions

Please check out this topic and see if the attachment helps.

http://forums.opalkelly.com/showthread.php?t=227

The following link:

http://forums.opalkelly.com/showthread.php?t=227

basically says to use a later version of :

    okFrontPanelDLL.h (dated: 12/10/2005)

After copying the above file into my working directory, and re-executing:

     loadlibrary('okFrontPanel', 'okFrontPanelDLL.h');

I still get the same problem in my post dated 03-24-2006, 05:56 PM.

Can someone please post an example of using the MatLab API with the following details:

  1. The XEM3010 firmware revision
  2. List of all the files required including:
    • required file date
    • required file location
  3. A MatLab script that:
    • loads library (include adding paths)
    • calls Wire In functions (update & read)
    • calls Wire Out functions (write & update)
  4. MatLab revision

Being able to reproduce a working setup would help me get up and running more quickly!

Best regards,

Borden.

I added thes two commands to the file for initialization:

mlist = ];
snlist = ];

to prevent to get an error such as

??? One or more output arguments not assigned during call to ‘C:\program files\Opal Kelly\FrontPanel\API\matlab\ok_getdevicelist.m (ok_getdevicelist)’.

if no OpalKelly boards are atteched to the computer.

I would like to contribute to this forum because I’ve found solution for my problem and I \ve found this forum whilst googling.

The problem was:
While loading library in Matlab:

loadlibrary(‘cmu_interface.dll’, ‘cmu_interface.h’)
I got:

Warning: The function ‘Get’ was not found in the library

In loadlibrary at 319

Solution is to set “Compile as C Code (/TC)” in project properties in Visual C++

Good luck writing dll’s for Matlab :slight_smile:

This script uses the Matlab API to load the First.v example, and to Set/Get WireIn/Outs. It was tested on Windows XP, with FrontPanel3 installed (default install path, and of course the latest firmware), and Matlab R14SP3. The board I have is the XEM3010-1500. The script lights the LEDs on the XEM in sequence, then displays the (decimal) value of the WireOuts as you push the two pushbuttons.

The script also does some silent status-checking, you can examine the returned values after you run the script.

To avoid device ownership conflicts, close the FrontPanel application before running this script. You must push and hold the buttons for > .5 seconds, a quick tap might not get read properly.

The Matlab screen display:

ok_test
Test 1: SetWireInValue
The red LEDs D2-D9 will light in sequence. D9 will stay on.

Test 2: GetWireOutValue
You will have twenty seconds to push and hold either/both pushbuttons.
You will see the decimal value of the bits in ep20.Ready?(hit enter)
0 0 0 0 0 0 0 0 1 1 1 1 1 1 3 3 3 3 3 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 …all done.

No Rocket Science here, but maybe I can save someone hours of jumping around the docs to unravel the calling syntax. I uploaded the file as .txt, just rename it to .m and place it in your Matlab path.
Joe


ok_test.m.txt (3022 Bytes)

I am very beginner about interfacing MATLAB between Opal Kelly FPGA board.
My questions are as followings.

  1. how to download the jmahan’s attached file, named ‘ok_test.m.txt’?
    When I clicked it, it shows an error message, ‘I have no previledge…’
    What I have to do?

  2. When I want to call a function like as follows
    calllib(‘okFrontPanel’, ‘okUsbFrontPanel_ReadFromPipeOut’,xem,int hex2dec(‘A1’),long 64,buff1);
    how can I defince buff1 in MATLAB?
    of course, the size of buff1 is 64 unsigned char.
    buff1=char([1:32*2]) is correct?

Thank you indeed.

[QUOTE=jmahan;1354]This script uses the Matlab API to load the First.v example, and to Set/Get WireIn/Outs. It was tested on Windows XP, with FrontPanel3 installed (default install path, and of course the latest firmware), and Matlab R14SP3. The board I have is the XEM3010-1500. The script lights the LEDs on the XEM in sequence, then displays the (decimal) value of the WireOuts as you push the two pushbuttons.

The script also does some silent status-checking, you can examine the returned values after you run the script.

To avoid device ownership conflicts, close the FrontPanel application before running this script. You must push and hold the buttons for > .5 seconds, a quick tap might not get read properly.

The Matlab screen display:

ok_test
Test 1: SetWireInValue
The red LEDs D2-D9 will light in sequence. D9 will stay on.

Test 2: GetWireOutValue
You will have twenty seconds to push and hold either/both pushbuttons.
You will see the decimal value of the bits in ep20.Ready?(hit enter)
0 0 0 0 0 0 0 0 1 1 1 1 1 1 3 3 3 3 3 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 …all done.

No Rocket Science here, but maybe I can save someone hours of jumping around the docs to unravel the calling syntax. I uploaded the file as .txt, just rename it to .m and place it in your Matlab path.
Joe[/QUOTE]

found that the matlab.m functions for setdiv1.m, setdiv2.m, setoutputsource.m etc have example strings in the M file that are missing the lead in characters ‘ok_’.

below is the supplied setdiv1.m file with example strings for input arg divsrc.

function obj = setdiv1(obj, divsrc, n)

%SETDIV1 Sets the divider 1 parameters.
% PLL=SETDIV1(OBJ, DIVSRC, N) Sets the divider 1 clock source
% to DIVSRC and the divider to N. DIVSRC is one of the following
% strings:
% ‘DivSrc_Ref’
% ‘DivSrc_VCO’
%
% Copyright © 2005 Opal Kelly Incorporated
% Rev: 209 Date: 2005-10-13 19:40:13 -0700 (Thu, 13 Oct 2005)

calllib(‘okFrontPanel’, ‘okPLL22150_SetDiv1’, obj.ptr, divsrc, n);

The below M file provides example divsrc strings that actually work.

function obj = setdiv1(obj, divsrc, n)

%SETDIV1 Sets the divider 1 parameters.
% PLL=SETDIV1(OBJ, DIVSRC, N) Sets the divider 1 clock source
% to DIVSRC and the divider to N. DIVSRC is one of the following
% strings:
% ‘ok_DivSrc_Ref’
% ‘ok_DivSrc_VCO’
%
% Copyright © 2005 Opal Kelly Incorporated
% Rev: 209 Date: 2005-10-13 19:40:13 -0700 (Thu, 13 Oct 2005)

calllib(‘okFrontPanel’, ‘okPLL22150_SetDiv1’, obj.ptr, divsrc, n);

Cheers

Hi,
I am new to MATLAB and need a sample file for OpalKelly FPGA. can you send me your sample file. Can not download your sample file “ok_test.m.txt” from OplaKelly.
thanks for the help.
regards,
-ali