B&B Electronics 232DRIO manual Bit Assignments for I/O Lines, Data Bytes

Page 13

used to specify which command will be executed by the controller,either the “R” or “S” character. The set output command requires one argument field (for normal environments) or two argument fields (data and its complement for harsh environments). This field contains the fourth and/or fifth data byte.

Command Syntax: ! or #

0

_

_

_

~Data Byte

Data Byte

Command Byte

Address Byte

 

Start of Message Byte

 

I/O Data Bytes

When constructing commands to manipulate output lines or when reading the state of the I/O lines it is necessary to know how to select and interpret the I/O data byte. The three I/O lines are represented by one data byte.

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.

Table 3.3 – Bit Assignments for I/O Lines

Input I #

 

 

 

 

 

I

R

R

Relay R #

X

X

X

X

X

#1

#2

#1

Bit Position

7

6

5

4

3

2

1

0

Hex Weight

80

40

20

10

8

4

2

1

Decimal Weight

128

64

32

16

8

4

2

1

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.

232DRIO-0308 Manual

11

B&B Electronics --

PO Box 1040 -- Ottawa, IL 61350

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

Image 13
Contents Electronics Mfg. Co. Inc Model 232DRIODesigned and Manufactured Ottawa, Illinois InternetPage Table of Contents Appendix B Table of Contents 232DRIO-0308 ManualIntroduction 232DRIO FeaturesNon-polarized, Optically Isolated Input 232DRIO-0308 Manual 232DRIO SpecificationsRelay Outputs Power SupplyCommunications EnvironmentOpto-isolated Input black terminal blocks ConnectionsRelay Outputs blue terminal blocks Ground232DRIO Terminal Blocks RS232 Connector PinoutSerial Port Connections 232DRIO To DTE Connections Power Supply Connections232DRIO To DCE Connections 01FE #0RComp = not x and &HFF Function Command Response 232DRIO CommandsEquivalent Values SyntaxData Bytes Bit Assignments for I/O LinesRelay #2 Relay #1 Example Set Output Lines Data Byte Relays Binary DecimalInput #1 Relay #2 Relay #1 Set Output Lines Command Read I/O Lines Command0R00000000 Shown in bold face0S03 Argument … shown in bold face0S00000011 …~… shown in bold faceBoard Layout Opto-isolated Input Switch Input Isolated Mechanical Input Relay Outputs 232DRIO External Circuit Digital I/O Mask Values SymbolOpening a COM Port Closing a COM PortRead I/O States Command Using the 232DRIO.LIB with QuickBasicSet Output States Command QuickBasic DEMO232.EXE and DEMO232.BAS#include232DRIO.H void main ++ DEMO232.EXE and DEMO232.CPPQuickBasic Running Demonstration ProgramAppendix a Decimal to HEX to Ascii Conversion Table Appendix a 232DRIO-0308 ManualAppendix B Appendix B 232DRIO-0308 Manual Decimal to Hexadecimal Conversion