B&B Electronics 232DRIO manual #0R, 01FE, Comp = not x and &HFF

Page 11

There are only two basic commands required to control the 232DRIO: set output lines and read I/O lines. For normal environments, command strings are from three to four bytes in length; the “!” character, the “0” (zero) character, one command character, and one data byte (if required).

With serial communications in a laboratory environment, the possibility of a communication error occurring is minimal. However, in a harsh or an industrial environment the possibility increases. A communication error occurs when a bit transmitted as a “1” is received as a “0” or vice versa. If the 232DRIO receives a error in one or more of the first three command characters (“!0X”), the unit will not execute the command. However, if the 232DRIO receives a communication error on a data byte (I/O byte for Read Digital command or state byte for Set Output State command), the command will be executed since the unit has no way of knowing that there was an error.

To provide the 232DRIO with a way of detecting errors in the data fields, an additional set of commands can be used. This set of commands begins with the “#” (23h) character, instead of the “!” (21h) character. Refer to Table 3.1. With these commands every data byte that is transmitted or received is followed by it’s complement. For example, to read I/O lines:

Command syntax:

#0R

Response syntax:

{DATA}{~DATA}

Where “~” is used to indicate the “complement of.” If DATA has a reading of 1, the following would be received:

{01}{FE}

Where FEh is the complement of 1. The complement of number “x” can be calculated in QuickBasic as follows:

comp = (NOT x) AND &HFF

232DRIO-0308 Manual

9

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

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

Image 11
Contents Internet Model 232DRIOElectronics Mfg. Co. Inc Designed and Manufactured Ottawa, IllinoisPage Table of Contents Appendix B Table of Contents 232DRIO-0308 ManualIntroduction 232DRIO FeaturesNon-polarized, Optically Isolated Input 232DRIO-0308 Manual 232DRIO SpecificationsEnvironment Power SupplyRelay Outputs CommunicationsGround ConnectionsOpto-isolated Input black terminal blocks Relay Outputs blue terminal blocksSerial Port Connections RS232 Connector Pinout232DRIO Terminal Blocks 232DRIO To DCE Connections Power Supply Connections232DRIO To DTE Connections Comp = not x and &HFF #0R01FE Syntax 232DRIO CommandsFunction Command Response Equivalent ValuesData Bytes Bit Assignments for I/O LinesInput #1 Relay #2 Relay #1 Example Set Output Lines Data Byte Relays Binary DecimalRelay #2 Relay #1 Shown in bold face Read I/O Lines CommandSet Output Lines Command 0R00000000…~… shown in bold face Argument … shown in bold face0S03 0S00000011Board Layout Opto-isolated Input Switch Input Isolated Mechanical Input Relay Outputs 232DRIO External Circuit Closing a COM Port SymbolDigital I/O Mask Values Opening a COM PortQuickBasic DEMO232.EXE and DEMO232.BAS Using the 232DRIO.LIB with QuickBasicRead I/O States Command Set Output States Command#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