B&B Electronics 232DRIO Digital I/O Mask Values, Symbol, Opening a COM Port, Closing a COM Port

Page 21

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.1 - Digital I/O Mask Values

I/O Line #

Mask Values

Hexadecimal Decimal

Relay #1

 

 

1H (0x01)

 

1

Relay #2

 

 

2H (0x02)

 

2

Input #1

 

 

4H (0x04)

 

4

X

 

 

8H (0x08)

 

8

X

 

 

10H (0x10)

 

16

X

 

 

20H (0x20)

 

32

X

 

 

40H (0x40)

 

64

X

 

 

80H (0x80)

 

128

Symbol:

X Don’t cares (default setting should all be “0”)

Programming Techniques

232DRIO.LIB

Opening a COM Port

HComDev = initComPort(unsigned short addr, unsigned char irq, unsigned long baud, unsigned short PortIndex)

The last parameter, PortIndex will always be 0 for programming the 232DRIO module:

InitComPort() Æ Returns 0 on error

For example, the code to open COM port 1 and setting the baud rate to 9600 would be:

HComDev = initComPort(0x03F8,4,9600,0)

Closing a COM Port

DeinitComPort(hComDev) Æ No return value

232DRIO-0308 Manual

19

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

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

Image 21
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 GroundRS232 Connector Pinout 232DRIO Terminal BlocksSerial Port Connections Power Supply Connections 232DRIO To DTE Connections232DRIO To DCE Connections #0R 01FEComp = not x and &HFF Function Command Response 232DRIO CommandsEquivalent Values SyntaxData Bytes Bit Assignments for I/O LinesExample Set Output Lines Data Byte Relays Binary Decimal Relay #2 Relay #1Input #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