Contents

Working with VXI and PXI Interfaces

Understanding VISA-VXI

The VXI interface is associated with a VXI controller that you install in slot 0 of a VXI chassis. This interface, along with the other relevant hardware, is shown below.

The VXI interface is supported through a VISA-VXI object. Many of the features associated with a VISA-VXI object are similar to the features associated with other instrument objects. Therefore, only functions and properties that are unique to VISA's VXI interface are discussed in this section.

Refer to GPIB Overview to learn about general toolbox capabilities such as writing and reading text and binary data, using events and callbacks, and so on.

Understanding VISA-PXI

A PXI interface is supported through a VISA-PXI object. Features associated with a VISA-PXI object are identical to the features associated with a VISA-VXI object. Information provided for working with VISA-VXI in this section also works for VISA-PXI.

PXI devices may be supported by other toolboxes or come with higher level drivers that are easier to interact with than the raw PXI interface.

Creating a VISA-VXI Object

You create a VISA-VXI object with the visa function. Each object is associated with

  • A VXI chassis

  • A VXI controller in slot 0 of the VXI chassis

  • An instrument installed in the VXI chassis

visa requires the vendor name and the resource name as input arguments. The vendor name is either agilent or ni. The resource name consists of the VXI chassis index and the instrument logical address. You can find the VISA-VXI resource name for a given instrument with the configuration tool provided by your vendor, or with the instrhwinfo function. (In place of the resource name, you can use an alias as defined with your VISA vendor configuration tool.) As described in Connecting to the Instrument, you can also configure property values during object creation.

Before you create a VISA object, you must find the instrument in the appropriate vendor VISA explorer. When you find the instrument configured, note the resource string and create the object using that information. For example, to create a VISA-VXI object associated with a VXI chassis with index 0 and an Agilent® E1432A 16-channel digitizer with logical address 32,

vv = visa('agilent','VXI0::32::INSTR');

The VISA-VXI object vv now exists in the MATLAB® workspace.

To open a connection to the instrument, type:

fopen (vv);

You can then display the class of vv with the whos command.

whos vv
  Name      Size         Bytes  Class

  vv        1x1            882  visa object

Grand total is 15 elements using 882 bytes

After you create the VISA-VXI object, the following properties are automatically assigned values. These properties provide information about the object based on its class type and address information.

VISA-VXI Descriptive Properties

Property Name

Description

Name

Specify a descriptive name for the VISA-VXI object.

RsrcName

Indicate the resource name for a VISA instrument.

Type

Indicate the object type.

You can display the values of these properties for vv.

vg.Name
ans =

'VISA-VXI0-32' 
vg.RsrcName
ans =

'VXI0::32::INSTR'
vg.Type
ans =

'visa-vxi'

VISA-VXI Object Display

The VISA-VXI object provides you with a convenient display that summarizes important address and state information. You can invoke the display summary these three ways:

  • Type the VISA-VXI object at the command line.

  • Exclude the semicolon when creating a VISA-VXI object.

  • Exclude the semicolon when configuring properties using the dot notation.

You can also display summary information via the Workspace browser by right-clicking an instrument object and selecting Display Summary from the context menu.

The display summary for the VISA-VXI object vv is given below.

VISA-VXI Object Using AGILENT Adaptor : VISA-VXI0-32

Communication Address 
   ChassisIndex:       0
   LogicalAddress:     32

Communication State 
   Status:             closed
   RecordStatus:       off

Read/Write State  
   TransferStatus:     idle
   BytesAvailable:     0
   ValuesReceived:     0
   ValuesSent:         0

VISA-VXI Address

The VISA-VXI address consists of:

  • The chassis index of the VXI chassis

  • The logical address of the instrument installed in the VXI chassis

You must specify the logical address value via the resource name during VISA-VXI object creation. Additionally, you must include the chassis index value as part of the resource name if it differs from the default value of 0. The properties associated with the chassis and instrument address are as follows.

VISA-VXI Address Properties

Property Name

Description

ChassisIndex

Indicate the index number of the VXI chassis.

LogicalAddress

Specify the logical address of the VXI instrument.

Slot

Indicate the slot location of the VXI instrument.

The ChassisIndex and LogicalAddress properties are automatically updated with the specified resource name values when you create the VISA-VXI object. The Slot property is automatically updated after the object is connected to the instrument with the fopen function.

You can display the address property values for the VISA-VXI object vv created in Creating a VISA-VXI Object.

fopen(vv)
vv.ChassisIndex 
ans = 


0
vv.LogicalAddress
ans =

32
vv.Slot
ans =

2

Register-Based Communication

VXI instruments are either message-based or register-based. Generally, it is assumed that message-based instruments are easier to use, while register-based instruments are faster. A message-based instrument has its own processor that allows it to interpret high-level commands such as a SCPI command. Therefore, to communicate with a message-based instrument, you can use the read and write functions fscanf, fread, fprintf, and fwrite. For detailed information about these functions, refer to Communicating with Your Instrument.

If the message-based instrument also contains shared memory, then you can access the shared memory through register-based read and write operations. A register-based instrument usually does not have its own processor to interpret high-level commands. Therefore, to communicate with a register-based instrument, you need to use read and write functions that access the register.

There are two types of register-based write and read functions: low-level and high-level. The main advantage of the high-level functions is ease of use. Refer to Using High-Level Memory Functions for more information. The main advantage of the low-level functions is speed. Refer to Using Low-Level Memory Functions for more information.

The functions associated with register-based write and read operations are as follows.

VISA-VXI Register-Based Write and Read Functions

Function Name

Description

memmap

Map memory for low-level memory read and write operations.

mempeek

Low-level memory read from the VXI register.

mempoke

Low-level memory write to the VXI register.

memread

High-level memory read from the VXI register.

memunmap

Unmap memory for low-level memory read and write operations.

memwrite

High-level memory write to the VXI register.

The properties associated with register-based write and read operations are given below.

VISA-VXI Register-Based Write and Read Properties

Property Name

Description

MappedMemoryBase

Indicate the base memory address of the mapped memory.

MappedMemorySize

Indicate the size of the mapped memory for low-level read and write operations.

MemoryBase

Indicate the base address of the A24 or A32 space.

MemoryIncrement

Specify if the VXI register offset increments after data is transferred.

MemorySize

Indicate the size of the memory requested in the A24 or A32 address space.

MemorySpace

Define the address space used by the instrument.

Understanding Your Instrument's Register Characteristics

This example explores the register characteristics for an Agilent E1432A 16-channel 51.2 kSa/s digitizer with a DSP module.

All VXI instruments have an A16 memory space consisting of 64 bytes. It is known as an A16 space because the addresses are 16 bits wide. Register-based instruments provide a memory map of the address space that describes the information contained within the A16 space. Some VXI instruments also have an A24 or A32 space if the 64 bytes provided by the A16 space are not enough to perform the necessary tasks. A VXI instrument cannot use both the A24 and A32 space:

  1. Create an instrument object — Create the VISA-VXI object vv associated with a VXI chassis with index 0, and an Agilent E1432A digitizer with logical address 130.

    vv = visa('agilent','VXI0::130::INSTR');
  2. Connect to the instrument — Connect vv to the instrument.

    fopen(vv)
    

    The MemorySpace property indicates the type of memory space the instrument supports. By default, all instruments support A16 memory space. However, this property can be A16/A24 or A16/A32 if the instrument also supports A24 or A32 memory space, respectively.

    vv.MemorySpace
    ans =
    A16/A24

    If the VISA-VXI object is not connected to the instrument, MemorySpace always returns the default value of A16.

    The MemoryBase property indicates the base address of the A24 or A32 space, and is defined as a hexadecimal string. The MemorySize property indicates the size of the A24 or A32 space. If the VXI instrument supports only the A16 memory space, MemoryBase defaults to 0H and MemorySize defaults to 0.

    vv.MemoryBase
    ans = 
        200000H    
    vv.MemorySize
    ans = 
        262144
  3. Disconnect and clean up — When you no longer need vv, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.

    fclose(vv)
    delete(vv)
    clear vv

Using High-Level Memory Functions

This example uses the high-level memory functions, memread and memwrite, to access register information for an Agilent E1432A 16-channel 51.2 kSa/s digitizer with a DSP module. The main advantage of these high-level functions is ease of use — you can access multiple registers with one function call, and the memory that is to be accessed is automatically mapped for you. The main disadvantage is the lack of speed — they are slower than the low-level memory functions.

Each register contains 16 bits, and is associated with an offset value that you supply to memread or memwrite. The first four registers of the digitizer are accessed in this example, and are described below.

Agilent E1432A Register Information

Register

Offset

Description

ID

0

This register provides instrument configuration information and is always defined as CFFF. Bits 15 and 14 are 1, indicating that the instrument is register-based. Bits 13 and 12 are 0, indicating that the instrument supports the A24 memory space. The remaining bits are all 1, indicating the device ID.

Device Type

2

This register provides instrument configuration information. Bits 15-12 indicate the memory required by the A24 space. The remaining bits indicate the model code for the instrument.

Status

4

This register provides instrument status information. For example, bit 15 indicates whether you can access the A24 registers, and bit 6 indicates whether a DSP communication error occurred.

Offset

6

This register defines the base address of the instrument's A24 registers. Bits 15-12 map the VME Bus address lines A23-A20 for A24 register access. The remaining bits are all 0.

For more detailed information about these registers, refer to the HP E1432A User's Guide.

  1. Create an instrument object — Create the VISA-VXI object vv associated with a VXI chassis with index 0, and an Agilent E1432A digitizer with logical address is 130.

    vv = visa('agilent','VXI0::130::INSTR');
  2. Connect to the instrument — Connect vv to the instrument.

    fopen(vv)
  3. Write and read data — The following command performs a high-level read of the ID Register, which has an offset of 0.

    reg1 = memread(vv,0,'uint16','A16')
    reg1 =
           53247

    Convert reg1 to a hexadecimal value and a binary string. Note that the hex value is CFFF and the least significant 12 bits are all 1, as expected.

    dec2hex(reg1)
    ans =
    CFFF
    dec2bin(reg1)
    ans =
    1100111111111111

    You can read multiple registers with memread. The following command reads the next three registers. An offset of 2 indicates that the read operation begins with the Device Type Register.

    reg24 = memread(vv,2,'uint16','A16',3)
    reg24 =
           20993
           50012
           40960

    The following commands write to the Offset Register and then read the value back. Note that if you change the value of this register, you will not be able to access the A24 space.

    memwrite(vv,45056,6,'uint16','A16'); 
    reg4 = memread(vv,6,'uint16','A16')
    reg4 =
          45056

    Note that the least significant 12 bits are all 0, as expected.

    dec2bin(reg4,16)
    ans =
    1011000000000000

    Restore the original register value, which is stored in the reg24 variable.

    memwrite(vv,reg24(3),6,'uint16','A16');
  4. Disconnect and clean up — When you no longer need vv, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.

    fclose(vv)
    delete(vv)
    clear vv

Using Low-Level Memory Functions

This example uses the low-level memory functions mempeek and mempoke to access register information for an Agilent E1432A 16-channel 51.2 kSa/s digitizer with a DSP module. The main advantage of these low-level functions is speed — they are faster than the high-level memory functions. The main disadvantages include the inability to access multiple registers with one function call, errors are not reported, and you must map the memory that is to be accessed.

For information about the digitizer registers accessed in this example, refer to Using High-Level Memory Functions:

  1. Create an instrument object — Create the VISA-VXI object vv associated with a VXI chassis with index 0, and an Agilent E1432A digitizer with logical address 130.

    vv = visa('agilent','VXI0::130::INSTR');
  2. Connect to the instrument — Connect vv to the instrument.

    fopen(vv)
  3. Write and read data — Before you can use the low-level memory functions, you must first map the memory space with the memmap function. If the memory requested by memmap does not exist, an error is returned. The following command maps the first 16 registers of the A16 memory space.

    memmap(vv,'A16',0,16);

    The MappedMemoryBase and MappedMemorySize properties indicate if memory has been mapped. MappedMemoryBase is the base address of the mapped memory and is defined as a hexadecimal string. MappedMemorySize is the size of the mapped memory. These properties are similar to the MemoryBase and MemorySize properties that describe the A24 or A32 memory space.

    vv.MappedMemoryBase
    ans =
        16737610H
    vv.MappedMemorySize
    ans =
        16

    The following command performs a low-level read of the ID Register, which has an offset of 0.

    reg1 = mempeek(vv,0,'uint16')
    reg1 =
          53247

    The following command performs a low-level read of the Offset Register, which has an offset of 6.

    reg4 = mempeek(vv,6,'uint16')
    reg4 =
          40960

    The following commands write to the Offset Register and then read the value back. Note that if you change the value of this register, you will not be able to access the A24 space.

    mempoke(vv,45056,6,'uint16');
    mempeek(vv,6,'uint16')
    ans =
         45056

    Restore the original register value.

    mempoke(vv,reg4,6,'uint16');

    When you have finished accessing the registers, you should unmap the memory with the memunmap function.

    memunmap(vv)
    vv.MappedMemoryBase
    ans =
        0H
    vv.MappedMemorySize
    ans =
        0

    If memory is still mapped when the object is disconnected from the instrument, the memory is automatically unmapped for you.

  4. Disconnect and clean up — When you no longer need vv, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.

    fclose(vv)
    delete(vv)
    clear vv
Was this topic helpful?