Mathworks MATLAB partnerUsing Mathworks MATLAB with Pickering PXI Direct IO drivers

An introduction into how to use the MATLAB programming platform to control Pickering Interfaces' PXI and LXI devices

Return to MATLAB landing page

As the Pickering drivers are standard Windows dll's, they can be accessed from most programming languages and MATLAB like other programming languages have capability to load and run Pickering drivers to control PXI cards. Functions such as) opening/closing cards(s) and operating switches can be performed using a set of instruction (listed below).

The functions can either be executed directly on MATLAB workspace or in function (*.m) files.


Loading Libraries

To access the library, please use the "loadlibrary" function, here is an example to access the PXI driver PILPXI

loadlibrary('Pilpxi','<PATH_NAME>\Pilpxi.h');
%% Enter appropriate pathname for dll.

Once the libraries are loaded, in order to check the functions in the library use "libfunctionsview" command followed by the dll's name.

Lets take an example of PILPXI

libfunctionsview('Pilpxi');

The following window will appear displaying information on functions in external library


Open Specified Card

Once the library is loaded, user can now use PIL_OpenSpecifiedCard function to open a specific PXI card in the chassis. This can be achieve by using the "calllib" function as shown in the example below

%% Create a uint32Ptr to get a return value on logical card number
cardnum=libpointer('uint32Ptr', 0);
%% Enter the input parameters for PIPLX_connect
%% Enter the SessionId obtained when connected to PXI card
%% Set the BUS and SLOT to the address of the card.
calllib('Pilpxi', 'PIL_OpenSpecifiedCard', BUS, SLOT, cardnum);

%% If the ans = 0 (No error returned) the card is successfully opened
CardNum=cardnum.Value;
%% Return the value of card number

Operating Switches

Once the card is open, user can now able to operate switches. PIL_OpBit allows user to operate switch one at a time. If it's a matrix, please use PIL_OpCrosspoint. Here is an example

%% Enter the input parameters for PIL_OpBit
%% OutSub - Output Sub Unit number
%% BitNum - Output Bit number
%% state - "1" ON , "0" OFF
    
calllib('Pilpxi', 'PIL_OpBit', CardNum, OutSub, BitNum, State); 

Close Specified Card

To close a specific card, please use PIL_CloseSpecifiedCard function

%% Enter the current session ID and card number in the input parameters
calllib('Pilpxi','PIL_CloseSpecifiedCard', CardNum);

Unload Libraries

To unload library use the following command

unloadlibrary('Pilpxi');
How did we do?
0 out of 0 people found this helpful.