B&B Electronics 232OPSDA manual Software, Application Program Interface

Models: 232OPSDA

1 28
Download 28 pages 11.94 Kb
Page 20
Image 20
Chapter 5: Software

Chapter 5: Software

Application Program Interface

The application program interface (API) is a set of routines that makes it easy to communicate with the 232OPSDA module from a 16- bit DOS application. Example programs using the API are written in

Borland C++, Borland Pascal and Microsoft® QuickBASIC v4.5. The batch file, MAKEIT.BAT, in the directory for each language shows how to compile and link the demo program with the API routines.

B232OPSDA_ReadAnalog

Purpose: This function reads the A/D input channels.

Syntax:

C:

BOOL B232OPSDA_ReadAnalog (WORD hComDev,

 

 

 

 

 

 

BYTE modAddr, WORD channels, WORD* data);

 

Pascal:

function B232OPSDA_ReadAnalog (hComDev :

 

 

 

word; modAddr : byte; channels : word;

 

BASIC:

data : Pword);

 

 

 

 

FUNCTION B232OPSDAReadAnalog (BYVAL

 

 

 

hComDev AS INTEGER, BYVAL modAddr AS

 

 

 

INTEGER, BYVAL channels AS INTEGER, BYVAL

 

 

 

wdataseg AS INTEGER, BYVAL wdataoff AS

 

 

 

INTEGER)

 

 

 

Remarks:

hComDev is the handle to a serial port where the

 

module is connected. This is the value returned by

 

initComPort. modAddr is the module address, which

 

is always 30H (48 decimal) for the 232OPSDA module.

 

channels is a bit mask for the A/D input channels that

 

should be read. See the table below for the meaning of

 

each bit.

 

 

 

 

 

Bit

 

Channel

Value

Value

 

 

 

 

 

(hex)

(decimal)

 

 

 

 

 

 

 

 

Bit 7

 

(nothing)

80H

128

 

 

Bit 6

 

(nothing)

40H

64

 

 

Bit 5

 

A/D Channel 5

20H

32

 

 

Bit 4

 

A/D Channel 4

10H

16

 

 

Bit 3

 

A/D Channel 3

08H

8

 

 

Bit 2

 

A/D Channel 2

04H

4

 

 

Bit 1

 

A/D Channel 1

02H

2

 

 

Bit 0

 

A/D Channel 0

01H

1

 

data is that address of an array of 16-bit values where the results of the A/D conversion will be stored.

For QuickBASIC users: wdataseg and wdataoff are the

Documentation Number 232OPSDA1397 Manual

19

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

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

Page 20
Image 20
B&B Electronics 232OPSDA manual Software, Application Program Interface