Instrument Control Toolbox | ![]() ![]() |
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 Writing and Reading Data.
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 Example: Using High-Level Memory Functions for more information. The main advantage of the low-level functions is speed. Refer to Example: Using Low-Level Memory Functions for more information.
The functions associated with register-based write and read operations are given below.
Function Name |
Description |
memmap |
Map memory for low-level memory read and write operations. |
mempeek |
Low-level memory read from VXI register. |
mempoke |
Low-level memory write to VXI register. |
memread |
High-level memory read from VXI register. |
memunmap |
Unmap memory for low-level memory read and write operations. |
memwrite |
High-level memory write to VXI register. |
The properties associated with register-based write and read operations are given below.
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. |
Example: 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.
vv
associated with a VXI chassis with index 0, and an Agilent E1432A digitizer with logical address 130.
vv
to the instrument.
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.
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
, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
Example: 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.
For more detailed information about these registers, refer to the HP E1432A User's Guide.
vv
associated with a VXI chassis with index 0, and an Agilent E1432A digitizer with logical address is 130.
vv
to the instrument.
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.
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.
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.
Note that the least significant 12 bits are all 0, as expected.
Restore the original register value, which is stored in the reg24
variable.
vv
, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
Example: 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 Example: Using High-Level Memory Functions.
vv
associated with a VXI chassis with index 0, and an Agilent E1432A digitizer with logical address 130.
vv
to the instrument.
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.
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.
The following command performs a low-level read of the ID Register, which has an offset of 0.
The following command performs a low-level read of the Offset Register, which has an offset of 6.
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.
Restore the original register value.
When you have finished accessing the registers, you should unmap the memory with the memunmap
function.
If memory is still mapped when the object is disconnected from the instrument, the memory is automatically unmapped for you.
vv
, you should disconnect it from the instrument, and remove it from memory and from the MATLAB workspace.
![]() | The VISA-VXI Address | The GPIB-VXI Interface | ![]() |