4
Agilent 34950A 64-Bit Digital I/O and Counter Module User’s Guide
Basic Digital I/O Operations
Reading Digital Data
The simplest way to read a digital channel is using the
MEASure:DIGital?
query. This query sets the channel to be an input channel and sets all
other channel parameters to the default settings.
For example, sending the following SCPI command to a Digital I/O module
installed in slot 1 of the mainframe will read the value of the 8- bit
channel 102. An unsigned integer value is returned that represents the
state of the 8 bits on channel 102.
MEAS:DIG? BYTE, (@1102)
By adding parameters to the command, you can set the channel width,
polarity, and threshold for read. For example, sending the following SCPI
command you can read the 32- bit channel 201.
MEAS:DIG? LWOR, (@1201)
To read digital data with more control over the channel parameters,
use the SCPI
CONFigure
and
SENSe
commands. The
CONFigure
commands
set up the digital I/O channel parameters. For example, sending the
following SCPI command to a Digital I/O module installed in slot 1 of the
mainframe, sets a 16- bit input channel (103) to use a 2.5 V input
threshold, and normal polarity.
CONF:DIG WORD, 2.5, NORM, (@1103)
Once configured, the data is read using the following command.
SENS:DIG:DATA:WORD? (@1103)
You may also read an individual bit using the
SENSe
commands.
This allows you to check the state of an individual bit in a channel
without having to create an input mask. For example, the following
command returns the state of bit 3 in the channel 101 byte.
SENS:DIG:DATA:BIT? 3, (@1101)
The acceptable range for the bit parameter is based on the channel width
as shown below:
•
BYTE (8- bit): <bit> can range from ‘0’ to ‘7’
•
WORD (16- bit): <bit> can range from ‘0’ to ‘15’
•
LWORd (32- bit): <bit> can range from ‘0’ to ‘31’
The
SENSe
command differs from the
MEASure
command in that it will not
change the direction (input or output) of the channel. If the channel is
configured as an output, the
SENSe
command will return the value being
driven.