User Guide

232DRIO-0308 Manual 19
B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350
PH (815) 433-5100 -- FAX (815) 433-5104
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.
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
Table 5.1 - Digital I/O Mask Values
Mask Values
I/O Line # 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