Section 8: Triggering
2470 High Voltage SourceMeter Instrument Reference Manual
8-26
2470-901-01 Rev. A /
May
2019
Reading a bit pattern
The programming examples below illustrate how to read part or all of a bit pattern that has been
applied to the digital I/O port by an external instrument. The binary pattern is 111111 (63 decimal).
Line 1 (bit 1) is the least significant bit.
Using SCPI commands:
Configure all six lines as digital inputs:
DIGital:LINE1:MODE DIGital, IN
DIGital:LINE2:MODE DIGital, IN
DIGital:LINE3:MODE DIGital, IN
DIGital:LINE4:MODE DIGital, IN
DIGital:LINE5:MODE DIGital, IN
DIGital:LINE6:MODE DIGital, IN
Read the state of Line 2:
DIGital:LINE2:STATe?
Value returned is 1.
Read the state of Line
3
:
DIGital:LINE3:STATe?
Value returned is
1
.
Read the value applied to the entire port:
DIGital:READ?
Value returned is 63, which is the decimal equivalent of the binary bit pattern.
Using TSP commands:
-- Configure all six digital I/O lines as digital inputs.
-- You can also use a for loop.
digio.line[1].mode = digio.MODE_DIGITAL_IN
digio.line[2].mode = digio.MODE_DIGITAL_IN
digio.line[3].mode = digio.MODE_DIGITAL_IN
digio.line[4].mode = digio.MODE_DIGITAL_IN
digio.line[5].mode = digio.MODE_DIGITAL_IN
digio.line[6].mode = digio.MODE_DIGITAL_IN
-- Read and then print the state of Line 2 (bit 2).
b2 = digio.line[2].state
print(b2)
The value returned is
digio.STATE_HIGH
.
-- Print the state of Line 3 (bit 3).
print(digio.line[3].state)
The value returned is
digio.STATE_HIGH
.