B&B Electronics 232OPSDA Low-Level Communications, Port Address, Returns See Also, DeinitComPort

Page 23

Syntax: C:

Pascal:

BASIC:

WORD initComPort (WORD portAddr, BYTE irq, LONG baudRate);

function initComPort (portAddr : word; irq

: byte; baudRate : longint) as integer;

FUNCTION initComPort% (BYVAL portAddr AS INTEGER, BYVAL irq AS INTEGER, BYVAL baudRate AS INTEGER)

Remarks: portAddr is the address of the serial port. irq is the interrupt request number that the serial port uses. baudRate is the speed at which the API talkes to the 232OPSDA module. Common port addresses and irq numbers are are:

Port

Address

IRQ

 

 

 

COM1

3F8H

4

COM2

2F8H

3

COM3

3E8H

4

COM4

2E8H

3

Returns: See Also:

deinitComPort must be called to remove the interrupt service routine installed by initComPort. The results are unpredictable if you terminate your application without calling deinitComPort.

A handle that uniquely identifies the installed serial port.

deinitComPort

Low-Level Communications

This section covers the low-level commands that are sent to the module through a serial communications port and the responses from the module. Detailed discussion of the command and responses are covered in Chapter 3. The examples shown here are in Microsoft® QuickBASIC. If you are programming in another language, this information can be used as a guideline for programming for the 232OPSDA module. To open and close a serial communications port in QuickBASIC use:

22Documentation Number 232OPSDA1397 Manual

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

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

Image 23
Contents Internet Electronics Mfg. Co. IncDesigned and Manufactured Ottawa, Illinois Table of Contents Page Introduction 232OPSDA FeaturesPacking List General Block DiagramAnalog to Digital Converter Software Installation232OPSDA Specifications Communications Power SupplyDigital Input Digital OutputTerminal Function Description Block Connections232OPSDA Serial Port Connections Digital I/O Connections232OPSDA Power Supply Connections Commands Syntax Reading A/D Channels Command States Reading Digital I/O CommandSet Digital Output Command 0RDBuffered 0 to 5V A/D Inputs Sampling RateConverter Range Non-buffered 0 to 5VDC A/D Inputs20mA Current Loop A/D Input To 10VDC A/D InputGain = Application Program Interface Syntax C B232OPSDAReadDigitalSee Also B232OPSDASetDigitalOutputReturns DeinitComPort PurposeDeinitComPort Low-Level CommunicationsPort Address Returns See AlsoMSB$ = INPUT$1, #1 LSB$ = INPUT$1, #1 Read A/D CommandCommand$ = !0RA + CHR$channel Print #1, Command$Read Digital I/O Command Status = states and mask Command$ = !0RDReply$ = INPUT$ 1, #1 States = ASCReply$States = states and NOTmask Command$ = !0SO + CHR$statesSet Digital Output State ‘ Set Output High states = states or maskDecimal to HEX to Ascii Conversion Table Appendix a Decimal to Hex to Ascii Conversion