beautypg.com

B&B Electronics RS-232 Digital I/O Module 232SDD16 User Manual

Page 8

background image

232SDD16-1005 Manual

11

B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350

PH (815) 433-5100 -- FAX (815) 433-5104

A byte represents an eight-bit binary number (11111111),

therefore each byte can represent eight I/O lines. Each bit is
assigned a bit position and a weight (value). Refer to Table 3.3.

To set an output to a HIGH state the corresponding bit position

must be set to a "1". Conversely to set an output LOW the
corresponding bit position must be set to a "0". When reading I/O
lines, any bit set to a "0" indicates the corresponding I/O line is in
the LOW state and any bit set to a "1" indicates the corresponding
I/O line is in the HIGH state.

Table 3.3 - Bit Assignments for I/O Lines

MOST SIGNIFICANT I/O BYTE

I/O

Line

# 15 14 13 12 11 10 9 8

Bit

Position 7 6 5 4 3 2 1 0

Hex

Weight 80 40 20 10 8 4 2 1

Dec. Weight 128

64

32

16 8 4 2 1

LEAST SIGNIFICANT I/O BYTE

I/O

Line

# 7 6 5 4 3 2 1 0

Bit

Position 7 6 5 4 3 2 1 0

Hex

Weight 80 40 20 10 8 4 2 1

Dec. Weight 128

64

32

16 8 4 2 1

Example 3.1 - To set outputs 15, 8, 1, and 0 to a HIGH state, and all

other outputs to a LOW state (shown in bold face) -

MS Byte

LS Byte

Shown in binary -

10000001

00000011

Shown in decimal -

129

(128+1)

3

(2+1)

Shown in hexadecimal -

81

(80h+1h)

3

(2h+1h)

Example 3.2 - Reply from Read I/O command (shown in bold face) -

MS Byte

LS Byte

Shown in binary -

11001000

01010010

Shown in decimal -

200

(128+64+8)

82

(64+16+2)

Shown in hexadecimal -

C8

(80h+40h+8h)

52

(40h+10h+2h)

I/O lines #15, 14, 11, 6, 4, 1 are HIGH. All other I/O lines are LOW.

12 232SDD16-1005

Manual

B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350

PH (815) 433-5100 -- FAX (815) 433-5104

Read I/O Lines Command


The Read I/O Lines command returns two data bytes that reflect

the state of the I/O lines. The first data byte contains the most
significant I/O lines (15 - 8). The second data byte contains the
least significant I/O lines (7 - 0). If a bit is a "0" then the state of that
I/O line is LOW. If a bit is a "1" then the state of that I/O line is HIGH.

Command: !0RD
Argument: none
Response: the state of the 16 I/O lines in two 8 bit bytes (shown in
bold face)
ASCII Example: !0RDÈR
Dec. Example: !0RD<200><82>
Hex. Example: !0RD<C8><52>
Bin. Example: !0RD<11001000><01010010>
Description: the first byte indicates that I/O lines #15, 14, & 11 are
HIGH and I/O lines # 13, 12, 10, 9, & 8 are LOW; the second byte
indicates that I/O lines # 6, 4, & 1 are HIGH and I/O lines # 7, 5, 3, 2,
& 0 are LOW.

Set Output Lines Command


The Set Output Lines command is used to set the states of the

output lines. This command requires two data bytes. These data
bytes specify the output state of each output line. The first data byte
represents the most significant I/O lines (15 - 8). The second data
byte represents the least significant I/O lines (7 - 0). If a bit position
is set to a "0" then the state of that output line will be set LOW. If a
bit position is set to a "1" then the state of that output line will be set
HIGH.

NOTE: Refer to the "Define I/O Lines" command to define an I/O line
as an output.