DEFIO (Statement)


Declare an I/O variable corresponding to the input/output port.


DEFIO <variablename> = <I/O variable type>,<port address>[,<mask data>]


This statement declares the variable specified by <variablename> as an I/O variable.
<I/O variable type> selects the type of I/O variable. I/O variable types include BIT, BYTE, WORD, INTEGER, and SINGLE. BIT, BYTE, WORD, INTEGER and SINGLE specify the range of a single bit, 8 bits, 16 bits, 32 bits and 32 bits, respectively. (SINGLE type is not available for versions lower than Ver.3.2)
<port address> is the starting I/O port number.
It can be specified as an integer constant or an expression for addition and subtraction composed of two integer constants.
For an input port, <mask data> is AND of input data and mask data.
For an output port, <mask data> is AND of output data and mask data; however, the output status of a bit with no mask assigned does not change.
Mask information is invalid for SINGLE. Writing mask information will result in a compile error.



  • In types WORD and INTEGER, a port corresponding to the MSB is used as a sign bit.
    SINGLE uses the IEEE 754 expression format.
    The table below lists the allowable range of numeric values and port numbers corresponding to various bits.
    WORD
    Allowable range of numeric values: -32768 to 32767
    MSB port number: "Starting port address + 15"
    INTEGER
    Allowable range of numeric values: -2147483648 to 2147483647
    MSB port number: "Starting port address + 31"
    SINGLE
    Allowable range of numeric values: -3.4E+38 to 3.4E+38
    Sign port number: "Starting port address + 31"
    Exponent port number: "Starting port address + 30" to "Starting port address + 23"
    Fraction port number: "Starting port address + 22" to "Starting port address"

  • In WINCAPSIII, display of SINGLE type values (such as watch) is not supported. Carry out comparison of SINGLE type values with the teach pendant.
  • The range of numeric values of WORD type is the range applied when getting values with IN command. If a value exceeding the range is specified when outputting with OUT command, then the lower 16 bits in the whole number will be output.


#DEFINE IO_OFFSET 256
'Define "IO_OFFSET" as 256
DEFIO samp1 = BIT, 1
'Declare samp1 as an I/O variable of type BIT, starting from
'port 1. The returned value of samp1 is a single-bit integer
'of 1 or 0 that expresses the status of port 1
DEFIO samp2 = BYTE, 10, &B00010000
'Declare samp2 with mask data as an I/O variable of type
'BYTE, starting from port 10. The returned value of samp2
'is an 8-bit integer of 0 or 16 that expresses the status
'of port 10
DEFIO samp3 = WORD, 15
'Declare samp3 as an I/O variable of type WORD, starting from
'port 15. The returned value of samp3 is a 16-bit integer of
'0 &Hffff which expresses the status of ports 15 to 30
DEFIO samp4 = INTEGER, 1
'Declare samp4 as an I/O variable of type INTEGER, starting
'from port 1. The returned value of samp4 is a 32-bit integer
'of 0 &Hffffffff which expresses the status of ports 1 to 32
DEFIO samp5 = BYTE, IO_OFFSET + 10
'Declare samp5 as an I/O variable of type BYTE, starting
'from the port number (266 in this example) resulting from
'calculation of 10 + IO_OFFSET. The returned value of
'samp5 is an 8-bit integer of 0 to &Hff that expresses the
'status of ports 266 to 273.
DEFIO samp6 = SINGLE, 128
'Declare samp6 as a SINGLE type I/O variable which starts
'from port 128. The return value of samp6 becomes a 32-bit
'single precision real number of -3.4E+38 to 3.4E+38 which
'expresses the status of the ports from 128 to 159.


Top