EasyManua.ls Logo

VTI Instruments EX1000A - Page 105

VTI Instruments EX1000A
320 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
www.vtiinstruments.com
EX10xxA Programming 105
Example: This code block queries the state of the I/O port and reports the level of bits 7, 4, and 0.
ViInt32 dio_in;
vtex10xxA_get_dio_input(vi, &dio_in);
if (dio_in & 0x80)
printf(“Bit 7 is high”);
else printf(“Bit 7 is low”);
if (dio_in & 0x10)
printf(“Bit 4 is high”);
else printf(“Bit 4 is low”);
if (dio_in & 0x01)
printf(“Bit 0 is high”);
else printf(“Bit 0 is low”);
The vtex10xxA_set_dio_output function is used to set the static level that each channel of the
digital I/O port will assume if/when enabled as an output. Enabling, however, is done with the
vtex10xxA_set_dio_output_enable function (see below). This function accepts a value that
represents the desired state of the 8-bit port, specified in either decimal (0 through 255) or hex (0x00
through 0xFF). Within the 8-bit field, the MSB corresponds to DIO channel 7 and the LSB
corresponds to DIO channel 0.
The vtex10xxA_set_dio_output_enable function enables or disables the output functionality of
each channel of the digital I/O port. Once enabled, a channel will assume the level specified with
the vtex10xxA_set_dio_output function (see above). When not enabled as an output, a channel
becomes tri-stated. Input functionality on each channel is constant regardless of its output
functionality. This function accepts a value that represents the desired output enable state of the 8-
bit port, specified in either decimal (0 through 255) or hex (0x00 through 0xFF). Within the 8-bit
field, the MSB corresponds to DIO channel 7 and the LSB corresponds to DIO channel 0.
Example: This code block sets bit 7 (high) and bit 6 (low) of the I/O port and then enables them as
outputs.
vtex10xxA_set_dio_output(vi, 0x80);
vtex10xxA_set_dio_output_enable(vi, 0xC0);
The vtex10xxA_get_dio_output query is used to obtain the programmed output state of the DIO
channels. The response to this query is a decimal value from 0 to 255 that represents the programmed
output state of the 8-bit port. However, since the outputs must be enabled, it does not necessarily
represent the true output state. The vtex10xxA_get_dio_output_enable query is used to obtain the
output enable state of each channel. The response to this query is a decimal value from 0 to 255 that
represents the output enable state of the 8-bit port. Within the 8-bit field, the MSB corresponds to
DIO channel 7 and the LSB corresponds to DIO channel 0.
Example: This code block queries the output state and output enable state of the I/O port and reports
the states of bit 4.
ViInt32 dio_out;
ViInt32 dio_outen;
vtex10xxA_get_dio_output(vi, &dio_out);
vtex10xxA_get_dio_output_enable(vi, &dio_outen);
if (dio_out & 0x10)
printf(“Bit 4 is set high”);
else printf(“Bit 4 is set low”);
if (dio_outen & 0x10)
printf(“Bit 4 is enabled”);
else printf(“Bit 4 is not enabled”);

Table of Contents

Related product manuals