7526 DCT Reference


Reference&mdash.DI/DO Port

reference&mdash.DI/DO port

DiCtrRead

This function reads the selected low or high speed DI counter (there is one for each of the 8 bits on the DI port).

One of eight software counters is incremented with each digital input event, thus allowing control of other events when reaching a specific count in any one of the digital input counters. The high speed DI counters can be read by setting di_point to 100&mdash.107.

The high speed DI counters can sample up to 1000 inputs per second. The low speed DI counters can sample up to 25 counts per second. To use the high speed DI counters, V2.00 or higher is required.

The DI counters can be cleared or written with a selected value with the companion API, DiCtrWrite function. The counters are cleared on a cold start only.

C Format

     #include   "cfrapi26.h"           // Defined values
 
     USHORT     DiCtrRead(di_point, value)
 
     UCHAR      di_point              // DI point 0-7, or 100-107
     ULONG      *value                // Returned value
 
     Returns:   E_OK                  // If no error occurred
                E_PARAM               // If parameter values invalid
                E_CONTEXT             // Port is configured for printer

Masm Format

     Input:     ah = 0
                al = di_point
 
     Call:      INT 40h
 
     Returns:   ax = 0      If no error occurred
                ax = 1      If parameter values invalid
                ax = 3      Port is configured for printer
                dx = High order word of value
                cx = Low order word of value

Example

int far main (int funct,char far *params)

DiCtrWrite

This function writes a value in the selected low or high speed DI counter (there is one for each of the 8 bits on the DI port).

This allows one of the eight DI counters to be written with a selected value or cleared to zero.

To set or clear a high speed DI counter, add 100 to di_point. The valid range is 100-107. The high speed DI counters are available in V2.00 and higher only.

C Format

     #include   "cfrapi26.h"          // Defined values
 
     USHORT     DiCtrWrite(di_point, value)
 
     UCHAR      di_point              // DI point 0-7, or 100-107
     ULONG      value                 // Value to be loaded in ctr
 
     Returns:   E_OK                  // If no error occurred
                E_PARAM               // If parameter values invalid
                E_CONTEXT             // Port is configured for printer

Masm Format

     Input:     ah = 1
                al = di_point
                dx = High order word of value
                cx = Low order word of value
 
     Call:      INT 40h
 
     Returns:   ax = 0      If no error occurred
                     1      If parameter values invalid
                     3      Port is configured for printer

Example

int far main (int funct,char far *params)

DidoRead

This function reads a character from the DI/DO port, with each bit in the character representing a point on the DI/DO port. This allows reading back digital input or output information your program may have written. .

C Format

     #include   "cfrapi26.h"          // Defined values
 
     USHORT     DidoRead(character)
 
     UCHAR      *character            // Returned DI/DO character read
 
     Returns:   E_OK                  // If no error occurred
                E_CONTEXT             // Port is configured for printer

Masm Format

     Input:     ah =  2
 
     Call:      INT  40h
 
     Returns:   bl = character
                ax = 0      If no error occurred
                ax = 3      Port is configured for printer

Example

int far main (int funct,char far *params)

DidoWrite

This function writes a character to the DO port, with each bit of the character corresponding to points 0-7 on the DO port.

C Format

     #include   "cfrapi26.h"          // Defined values
 
     USHORT     DidoWrite(character)
 
     Returns:   E_OK                  // If no error occurred
                E_CONTEXT             // If port is set for 8 DI or printer

Masm Format

     Input:     ah = 3
                al = character
 
     Call:      INT 40h
 
     Returns:   ax = 0      If no error occurred
                     3      If port is set for 8 DI or printer

Comments:

When writing to a DO Point, a value of 0  sets the output to 0 volts;
a value of 1 sets the output to +5 volts.

If the port is set to 4 in/4 out, then the 4 low order bits are ignored.

Note:

This output voltage is opposite of the DoWritePoint API.

Example

int far main (int funct,char far *params)

DoWritePoint

This function writes one selected DO point 0&mdash.7

C Format

     #include   "cfrapi26.h"             // For defined values
 
     USHORT     DoWritePoint(do_point, value, time)
 
     UCHAR      do_point                 // DO point 0-7
     UCHAR      value                    // DO point level
     UCHAR      time                     // Duration in seconds
 
     Returns:   E_OK                     // If no error occurred
                E_PARAM                  // If parameter values are incorrect
                E_CONTEXT                // If port is set for 8 DI or printer

Masm Format

     Input:     ah = 4
                al = do_point
                cl = time
                bl = value
 
     Call:      INT 40h
 
     Returns:   ax = 0      If no error occurred
                     1      If parameter values are incorrect
                     3      Port is configured for printer or 8 DI

Comments:


Example

int far main (int funct,char far *params)