beautypg.com

Writeio (pslot, mask, source) – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 382

background image

Section 9. Program Control Instructions

WriteIO (PSlot, Mask, Source)

Used to set the status of the digital control ports on the CR9060, CR9070, or
CR9071E modules.

Syntax

WriteIO(

PSlot, Mask, Source

)

There are 16 ports on the CR9070/CR9071E and 8 Control ports on the
CR9060 Excitation module . The status of these ports is considered to be a
binary number with a high port (+5 V) signifying 1 and a low port (0 V)
signifying 0. For example, just looking at the first 8 ports, if ports 1 and 3 are
to be set high and the rest low, the binary representation is 00000101, or 5
decimal. The Source value is interpreted as a binary number and the ports set
accordingly.

See the PortSet Topic in Section 9.2 DataLogger Status/Control for setting
the ports on the CR9060.

The Mask parameter is used to select which of the ports to set. It too is a
binary representation of the ports, a 1 signifies to set the port according to the
source, a 0 means do not change the status of the port.

CRBasic allows the entry of numbers in binary format by preceding the
number with "&B". For example if the mask is entered as &B110 (leading
zeros can be omitted in binary format just as in decimal) and the source is 5
decimal (binary 101) port 3 will be set high and port 2 will be set low. The
mask indicates that only 3 and 2 should be set. While the value of the source
also has a 1 for port 1, it is ignored because the mask indicates 1 should not be
changed.

WriteIO must not be placed inside a conditional statement,
SubScan, or Slow Sequence Scan (WriteIO can be used with
CR9060 ports in SubScans).

NOTE

Example:

WriteIO

(5, &B100, &B100)

'Set port 3 on the 9070 in slot 5 high.

WriteIO

(5, 4, 4)

'Set port 3 on the 9070 in slot 5 high.

WriteIO

(5, &Hff00, Y*256)

' Write Y to upper 8 ports (9-16)

Parameter
& Data Type

Enter

WRITEIO PARAMETERS

PSlot

Constant

The number of the slot that holds the CR9060, CR9070, or CR9071E module whose
port(s) are to be set.

Mask

Constant

The Mask allows the write to only act on certain ports. The Mask is ANDed with the
source before writing.

Source

Constant Variable

The Source parameter is a constant or the variable that holds the value for setting the
control ports. The Source value is interpreted as a binary number and the ports are set
accordingly.

9-52