Mathworks MATLAB partnerUsing MATLAB® with the Pickering VISA Driver

Return to MATLAB landing page

For information on using Pickering LXI drivers in MATLAB

In this document we will discuss how MATLAB® user can establish a connection using Pickering VISA drivers and operate switches using MATLAB instrument toolbox.The block diagram below shows the overview of the communication between USER and PXI cards using our Pickering VISA driver in MATLAB.

MATLAB interface diagram

The MATLAB instrument toolbox can be used to access the Pickering VISA driver. A system must have VISA installed in order for Pickering driver to work. Once the driver is installed, you can determine whether the configuration is visible to MATLAB software by using the Test & Measurement Tool to view the current driver installations.

Open the tool by typing the following command in MATLAB workspace:

>> tmtool

The following window will appear

Screenshot of MATLAB with tmtool command entered

Expand the Instrument Drivers node and click VXIplug&play Drivers. Click the Scan button to update the display installed will be listed. Pipx40 will be listed with its pathname

Screenshot of MATLAB after scanning - pipx40 visible 

Alternately on MATLAB workspace, if the user enters "instrhwinfo" command, it will give the the name and path of the installed driver.

instrhwinfo ('vxipnp')
 
ans =
 
    InstalledDrivers: {'Pipx40'}
      VXIPnPRootPath: 'C:\Program Files\IVI Foundation\VISA\WINNT'

MATLAB Instrument Driver Wrapper

The MATLAB instrument driver Wrapper can be created using the following command on MATLAB workspace

makemid ('Pipx40')

The MATLAB Instrument Driver Wrapper (Pipx40.mdd) will appear in MATLAB Instrument drivers node

Screenshot of MATLAB with makemid ('pipx40') command entered

Creating & connecting the Device Object

Using the MATLAB instrument driver, create the device object with the file name of the driver and a VISA resource name as arguments for icdevice. Execute the following command on MATLAB workspace, change the VISA resource name according to the card address:

obj = icdevice('Pipx40.mdd','PXI6::12::INSTR')

The following output will appear on the MATLAB workspace

Instrument Device Object Using Driver : pipx40
 
Instrument Information
Type: VXIPnPInstrument
Manufacturer: Pickering Interfaces
Model: Pickering Interfaces PXI VISA
 
Driver Information
DriverType: MATLAB VXIplug&play
DriverName: pipx40
DriverVersion: 1.0
 
Communication State
Status: closed

As we can see the communication state is still closed so use the following command

connect(obj);

In order to check the communication state, use the following command

get(obj, 'status')
 
ans =
 
open

Once the communication is established user can now use the set of functions in the driver to operate the card. In the instrument control toolbox, expand the instrument object node and the device object node. VXIPnPInstrument-Pipx40. Click on the device object and the following window will appear

Screenshot of MATLAB with VXIPnPInstrument-Pipx40 visible

As we can see all the driver functions are listed under the function tab. The user can now use different functions to operate card(s) by entering the input arguments. The output arguments are variables which will display the return value.

Lets take an example of some of our functions

Set channel State

Select the function clearcard in the function tab and press Execute. The response window will indicate if there are any errors. In this case the function executed successfully.

Screenshot of MATLAB demonstrating successful execution

Set channel State

The Set Channel state function is use to operate swtiches on a subunit. It takes the Input parameters of Subunit Number, Channel Number and the Action '0' OFF and '1' ON. In order to check the input/output parameters for each functions are displayed on the Test and measurement tool panel. The Function entries entered by user are being displayed in the table on the panel.

Setting channel state in MATLAB

Get channel State

The Get Channel state function is use to get the output state of a channel on a subunit. It takes the Input parameters of Subunit Number, Channel Number and the Output parameter is State. For the above example as we have set the channel state to 1. In the Response Window(see figure below) the Output on the function indicates the state =1

Getting channel state in MATLAB

Similarly other functions in the driver can be executed.

In order to edit the functions use midedit command

midedit('Pipx40')
Editing the functions using midedit command in MATLAB

To disconnect the card

disconnect(obj)
How did we do?
0 out of 0 people found this helpful.