B&B Electronics 232OPSDA manual Read Digital I/O Command

Page 25

Step 5 - Repeat Step 3 and 4 until each channel has been completed.

Step 6 - The various A/D channels have signal conditioning, so mathematical manipulation of the voltage read will have to be performed. See Chapter 4 for the equations.

Example 5.1 - Read A/D channels 1 and 0

gain0 = 23.064 gain1 = 1!

channel = 1

Command$ = “!0RA” + CHR$(channel) Print #1, Command$;

Get the value of channel 1 MSB$ = INPUT$ (1, #1)

LSB$ = INPUT (1, #1)

ad1 = (ASC(MSB$) * 256) + ACS(LSB$) reading1 = 5! * ad1 / (gain1 * 4095!)

Get the value of channel 0

MSB$ = INPUT$ (1, #1)

LSB$ = INPUT$ (1, #1)

ad0 = (ASC(MSB$) * 256) + ACS(LSB$)

reading0 = (((ad0 * 1000!) / 4095!) * 5!) / (10!

*

gain0)

The value of reading1 is the result of the A/D conversion on channel

1.The value of reading0 is the result of the A/D conversion on channel 0.

Read Digital I/O Command

The Read Digital I/O command returns a byte which represents the states of the digital input and digital output. Bit 0 corresponds to the state of digital output. Bit 3 corresponds to the state of digital input. If a bit is a 0 then the digital state of that digital I/O is LOW. If a bit is a 1 then the digital state of the I/O is HIGH.

24Documentation Number 232OPSDA1397 Manual

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

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

Image 25
Contents Designed and Manufactured Ottawa, Illinois Electronics Mfg. Co. IncInternet Table of Contents Page Introduction 232OPSDA FeaturesPacking List General Block Diagram232OPSDA Specifications Software InstallationAnalog to Digital Converter Digital Input Power SupplyDigital Output CommunicationsTerminal Function Description Block Connections232OPSDA Serial Port Connections Digital I/O Connections232OPSDA Power Supply Connections Commands Syntax Reading A/D Channels Command Set Digital Output Command Reading Digital I/O Command0RD StatesConverter Range Sampling RateNon-buffered 0 to 5VDC A/D Inputs Buffered 0 to 5V A/D Inputs20mA Current Loop A/D Input To 10VDC A/D InputGain = Application Program Interface Syntax C B232OPSDAReadDigitalReturns B232OPSDASetDigitalOutputDeinitComPort Purpose See AlsoPort Address Low-Level CommunicationsReturns See Also DeinitComPortCommand$ = !0RA + CHR$channel Read A/D CommandPrint #1, Command$ MSB$ = INPUT$1, #1 LSB$ = INPUT$1, #1Read Digital I/O Command Reply$ = INPUT$ 1, #1 Command$ = !0RDStates = ASCReply$ Status = states and maskSet Digital Output State Command$ = !0SO + CHR$states‘ Set Output High states = states or mask States = states and NOTmaskDecimal to HEX to Ascii Conversion Table Appendix a Decimal to Hex to Ascii Conversion