National Instruments PC-OPDIO-16 Telescope User Manual


 
Theory of Operation Chapter 5
PC-OPDIO-16 User Manual 5-4 © National Instruments Corporation
Using NI-DAQ Functions for Isolated Digital I/O
The C code block below illustrates the use of the NI-DAQ digital input and output calls
supported by the PC-OPDIO-16 board. The series of calls outputs the binary pattern 11110000
from port 0 and input a pattern from port 1. Next, line 4 is toggled to zero on port 0 and line 4 is
read by port 1. Be aware that calling Dig_Prt_Config for one port will effect the output of
the other port. Always configure both ports before inputting or outputting patterns. The
calls made and the order will be the same for Basic and Pascal users although the syntax will
differ. Refer to the function reference section for complete explanations of the parameters and
the functions.
/*--------------------------------------------\
Initializes support for PC-OPDIO-16
DOS users only can call this function
Note: The PC-OPDIO-16 is functionally similar
to the AT-DIO-24, so call USE_DIO_24
to initialize it
\--------------------------------------------*/
error = USE_DIO_24();
if (error < 0) exit (error);
/*---------------------------------------------\
output 11110000 from port 0
\---------------------------------------------*/
error = DIG_Out_Port(device, 0, 0xF0);
if (error < 0) exit (error);
/*------------------------------------------------\
read port 1
\------------------------------------------------*/
error = DIG_In_Port(device, 1, &pattern);
if (error < 0) exit (error);
/*---------------------------------------------\
ask port 0 to toggle line 4 to be 0
\---------------------------------------------*/
error = DIG_Out_Line(device, 0, 4, 0);
if (error < 0) exit (error);
/*---------------------------------------------\
ask port 1 to read line 4
\---------------------------------------------*/
error = DIG_In_Line(device, 1, 4, &state);
if (error < 0) exit (error);