B&B Electronics 232OPSDA manual Read A/D Command

Models: 232OPSDA

1 28
Download 28 pages 11.94 Kb
Page 24
Image 24
Read A/D Command

Open the serial port.

OPEN “COM1:9600,N,8,1,cd,ds” FOR RANDOM AS #1 PAUSE (.5)

Close the serial port when finished.

CLOSE #1

Read A/D Command

The read A/D channels command returns two bytes of data for each channel read. The two bytes represent the most significant byte (MSB) and least significant byte (LSB) of the reading. The MSB is received first, followed by the LSB. This command requires a data byte. The data byte is used to specify the number of the highest channel to be read. All channels less than this channel will be read as well.

Step 1 - Constructing the command string:

Command$ = “!0RA” + CHR$(channel)

The value of channel is equal to the highest channel to be read.

Step 2 - Transmitting the command string:

Print #1, Command$;

Step 3 - Receiving the data:

MSB$ = INPUT$(1, #1)

LSB$ = INPUT$(1, #1)

Step 4 - Manipulating the data:

reading = (ASC(MSB$) * 256) + ASC(LSB$)

The value of reading is the result of the A/D conversion.

Documentation Number 232OPSDA1397 Manual

23

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

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

Page 24
Image 24
B&B Electronics 232OPSDA manual Read A/D Command