RS-232 Digital Relay I/O Model 232DRIO Documentation Number 232DRIO1005 pn#4520-r2 This product Designed and Manufactured In Ottawa, Illinois USA of domestic and imported parts by B&B Electronics Mfg. Co. Inc. 707 Dayton Road -- P.O. Box 1040 -- Ottawa, IL 61350 PH (815) 433-5100 -- FAX (815) 433-5104 Internet: http://www.bb-elec.com sales@bb-elec.com support@bb.elec.
Table of Contents Chapter 1- Introduction ........................................... 3 232DRIO Features .................................................. 3 Packing List ............................................................. 2 232DRIO Specifications........................................... 3 Opto-Isolated Input................................................................ 3 Relay Outputs ....................................................................... 3 Power Supply ......................
Demonstration Program ........................................ 22 Hard Drive Installation ......................................................... 22 Running Demonstration Program ....................................... 22 APPENDIX A.......................................................... A-1 ASCII Character Codes ........................................ A-1 APPENDIX B.......................................................... B-1 Hexadecimal/Decimal Conversions ......................
Chapter 1- Introduction 232DRIO Features The 232DRIO is a general purpose data acquistion controller that is connected to your computer’s RS-232 serial port. The 232DRIO offers 1 opto-isolated input and 2 relay outputs. With these features, the controller can be used to sense external ON/OFF conditions and to control a variety of devices. The relay outputs are CMOS/TTL compatible. The optically isolated AC/DC input are also CMOS/TTL compatible.
Figure 1.1 – 232DRIO Module POWER RS-232 Transceiver +5V 5-30 Vdc/Vac Input Microcontroller R Opto Isolator SPDT RD RELAY SPDT TD RELAY Serial Port DB-9S GND +12Vdc #2 N/O #2 N/C #2 Com #1 N/O #1 N/C #1 Com Figure 1.2 – Simplified Block Diagram Packing List Examine the shipping carton and contents for physical damage. The following items should be in the shipping carton: 1. 232DRIO unit 2. Software 3.
Number of Channels: 1 Indication Mode Logic “0”: LED on, digital voltage input high Logic “1”: LED off, digital voltage input low Input Electrical Characteristic Voltage input low: <1.5 VAC/VDC Voltage input high: 5-30 VAC/VDC @ 1mA to 30mA Isolation Voltage: 2500 V Leakage Current: 10 µA max.
Chapter 2 - Connections Do not make any connections to the 232DRIO until you have read this chapter. Remember to power down the unit and any other connected devices before making any kinds of connections. Also be sure that the wires connected to the terminal blocks will support the voltage and current requirements of your external devices. This chapter will cover the connections for the 232DRIO. There are four sets of connections: opto-isolated input (optional), relay outputs, serial port, and power supply.
Table 2.1 - 232DRIO Terminal Blocks Blue Pin # Function 1 2 3 4 5 6 7 8 - Ground Input Power +12Vdc Input Power #2 N/C-Normally Closed #2 N/O-Normally Opened #2 C-Common #1 C-Common #1 N/C-Normally Closed #1 N/O-Normally Opened Black Pin # 1 2 Function Opto-Isolated Input Opto-Isolated Input Non-polarized 0-30 Vdc/Vac Serial Port Connections In order to communicate to the 232DRIO module it must be connected to an RS-232 serial port.
Table 2.3 – 232DRIO To DTE Connections 232DRIO Pin # 2 3 5 9 Signal Receive Data (RD) Transmit Data (TD) Signal Ground (SG) Ring Indicator DTE DB-25 Connection 3 2 7 22 DTE DB-9 Connection 2 3 5 9 Table 2.4 – 232DRIO To DCE Connections 232DRIO Pin # 2 3 5 9 Signal Receive Data (RD) Transmit Data (TD) Signal Ground (SG) Ring Indicator DCE DB-25 Connection 2 3 7 22 DCE DB-9 Connection 3 2 5 9 Power Supply Connections The power requirement is 12VDC at 100mA.
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.
Table 3.1 – 232DRIO Commands Function Command Response Set Output Lines !0S{…} No response Read I/O Lines !0R {…} Set Output Lines #0S{…}{~…} No response Read I/O Lines #0R {…}{~…} Symbol: {…} represents one byte <…> represents a numeric value ~ complement of the specified data byte Before going into the specifics of each command, it is important to understand that a byte has a numeric value from 0 to 255.
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.
Example 3.1 Set Output Lines Data Byte Relays Decimal Hex Relay #2 Binary XXXXXX00 0 0 de-energized XXXXXX01 1 1 de-energized XXXXXX10 2 2 energized XXXXXX11 3 3 energized Relay #1 de-energized energized de-energized energized Symbol: X don’t cares (default setting should all be “0”) To energize the relays, the corresponding bit of the data byte must be set high. Conversely, to de-energize the relays the corresponding bit of the data byte must be set low.
Read I/O Lines Command The Read I/O Lines command returns one data byte (with the “!”) and two data bytes (data and its complement with the “#”) that reflects the state of the I/O lines. Bit 2 is Input #1, Bit 1 is Relay #2, and finally Bit 0 corresponds to Relay #1. 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: !0R Argument: none Response: the state of input and 2 relays (shown in bold face) ASCII Example: !0R Dec.
Command: !0S Argument: {…} (shown in bold face) Response: none ASCII Example: !0S Dec. Example: !0S<3> Hex. Example: !0S<03> Bin. Example: !0S<00000011> Description: Relay #2 is energized (“1”), and Relay #1 is energized (“1”). Command: #0S Argument: {…}{~…} (shown in bold face) Response: none ASCII Example: #0S Dec. Example: #0S<3><252> Hex. Example: #0S<03> Bin. Example: #0S<00000011><11111100> Description: Relay #2 is energized (“1”), and Relay #1 is energized (“1”).
This chapter will explain "HIGH" and "LOW" states and show some general examples of how to interface to the I/O lines. Caution must be taken not to exceed 232DRIO specifications listed in Chapter 1 when interfacing to external devices. Failure to stay within these specifications could result in damage to the unit and will void warranty. Figure 4.1 – Board Layout Opto-isolated Input As stated earlier, the opto-isolated input line is CMOS/TTL compatible and can also handle voltages from 0 to +30 Vdc or Vac.
Figures 4.2 - 4.4 show examples of some typical input interfaces. 232DRIO EXTERNAL CIRCUIT Opto Isolated Input 5-30 Vdc/Vac Figure 4.2 - Switch Input 232DRIO EXTERNAL CIRCUIT Opto Isolated Input 5-30 Vdc/Vac Figure 4.
232DRIO EXTERNAL CIRCUIT Opto Isolated Input 5-30 Vdc/Vac Figure 4.4 - Isolated Mechanical Input Relay Outputs Relay outputs are used to turn external devices on or off. Relay outputs are CMOS/TTL compatible and can also operate between 024Vdc and 0-115Vac. Outputs can be used to control solid state output modules, CMOS and TTL logic circuits. Caution must be taken not to exceed the power capability of the outputs. Refer to the output specifications in Chapter 1.
Figures 4.5 - 4.6 show examples of some typical output interfaces. 232DRIO +12 Vdc EXTERNAL CIRCUIT +5 Vdc N/C 0-30 Vdc @ 8A max. 0-120 Vac @ 10A max. N/O Common 1K Figure 4.5 – Isolated Connection to External Circuit 232DRIO +12 Vdc EXTERNAL CIRCUIT N/C N/O Common Common 0-30 Vdc @ 8A max. 0-120 Vac @ 10A max. Figure 4.
Chapter 5 - Software This chapter will be divided into two sections. The first section covers programming techniques for opening/closing a com port, receiving data, and manipulating data in QuickBasic and C/C++. The second section discusses how to install and run the demonstration program on an IBM PC or compatible. Table 5.
QuickBasic (DEMO232.EXE and DEMO232.BAS) This section shows steps and examples of programming the 232DRIO in QuickBasic. If you are programming in another language, this section can be helpful as a guideline for programming the 232DRIO. Using the 232DRIO.LIB with QuickBasic: Using this library will make it easier to program the 232DRIO module and allows greater flexibility in choosing serial ports. At the DOS prompt, start QuickBasic with the 232DRIO Quick Library by typing: QB program.bas /L 232DRIO.
C/C++ (DEMO232.EXE and DEMO232.CPP) DEMO232.CPP is a demonstration program for use with B&B Electronics model 232DRIO module. Much of the work associated with using COM ports in C/C++ has been made easier by including the 232DRIO.LIB with this program. Including “232DRIO.H” in the pre-processor directive and compiling your .cpp file as a project along with the 232DRIO.LIB file will enable you to use the following functions in your program.
Demonstration Program The Demonstration Programs (IBM PC or Compatible) provide the user with examples of how to receive and transmit commands to the 232DRIO. The DEMO232.EXE is the executable program and the DEMO232.BAS file is the source code in QuickBasic. The DEMO232.EXE is the executable program and the DEMO232.CPP file is the source code in C/C++. The source codes provide an illustration of how to send and receive commands from the 232DRIO.
APPENDIX A ASCII Character Codes 232DRIO-0308 Manual Appendix A B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350 PH (815) 433-5100 -- FAX (815) 433-5104 A-1
DECIMAL to HEX to ASCII CONVERSION TABLE DEC HEX ASCII KEY DEC HEX ASCII DEC HEX ASCII DEC HEX ASCII 0 0 NUL ctrl @ 32 20 SP 64 40 @ 96 60 ` 1 1 SOH ctrl A 33 21 ! 65 41 A 97 61 a 2 2 STX ctrl B 34 22 “ 66 42 B 98 62 b 3 3 ETX ctrl C 35 23 # 67 43 C 99 63 c 4 4 EOT ctrl D 36 24 $ 68 44 D 100 64 d 5 5 ENQ ctrl E 37 25 % 69 45 E 101 65 e 6 6 ACK ctrl F 38 26 & 70 46 F 102 66 f 7 7 BEL ctrl G 39 27 ' 71 47 G 10
APPENDIX B Hexadecimal/Decimal Conversions The decimal (base 10) numbering system represents each position in successive powers of 10, with each decimal symbol having a value from 0 to 9. The hexadecimal (base 16) numbering system represents each position in successive powers of 16 with each hex symbol having a value of 0 to 15. Since each hex position must have a single symbol, the symbols "A" through "F" are assigned to values 10 through 15 respectively. Refer to Table 1.
Hexadecimal to Decimal Conversion: Decimal = (1st Hex digit x 4096) + (2nd Hex digit x 256) + (3rd Hex digit x 16) + (4th Hex digit) Each "Hex digit" is the decimal equivalent value of the hexadecimal symbol. Example: Convert 10FC hexadecimal to decimal. 1 x 4096 = 4096 0 x 256 = 0 15 x 16 = 240 12 x 1 = 12 4348 10FC hex equals 4348 decimal. Decimal to Hexadecimal Conversion: Example: Convert 4348 decimal to hexadecimal.