beautypg.com

4 programming, 1 direct i/o register programming – Measurement Computing CIO-RELAY08 User Manual

Page 9

background image

4 PROGRAMMING

The CIO-RELAY boards are easy to program. From one to four eight-bit registers
are written to control relays or can be read to determine the state of relays.

In addition to direct I/O programming, the boards are f ully supported by the
powerful Universal Library program as well as most third-party application
programs.

4.1 DIRECT I/O REGISTER PROGRAMMING

The CIO-RELAY family uses between one and four I/O addresses. Each address
controls eight relay s. Relays are co ntrolled by writing to these register(s). T he
address map of the CIO-RELAY boards is shown below.

BASE ADDRESS

Relays 0-7

Read/Write (All CIO-RELAY boards

BASE + 1

Relays 8-15

Read/Write (CIO-RELAY16, -24, -32)

BASE + 2

Relays 16-23

Read/Write (CIO-RELAY24, -32)

BASE + 3

Relays 24-31

Read/Write (CIO-RELAY32 only)

The registers are written to and read from as a single, 8-bit byte. Each bit controls an
output to a relay (write) or represents the state of a relay (read).

All registers are read left to right. The leftmost bit (the eighth bit) being the most
significant bit. Following this format, bit seven (OP7) of BASE + 0 corresponds to
relay number 7 and bit 0 to relay number 0.

To construct a control word, use Table 4.1 for bit weights.

Table 4-1. Bit Weights

80

128

7

40

64

6

20

32

5

10

16

4

8

8

3

4

4

2

2

2

1

1

1

0

HEX VALUE

DECIMAL VALUE

BIT POSITION

For example, to assemble the control byte that will turn on relays 0, 1, 3, 5, and 7,
we see in Table 4-2 that we need to write HEX AB or decimal 171.

5

This manual is related to the following products: