B&B Electronics 232OPSDA manual Commands

Page 13

Chapter 3: Commands

Only three commands are required to operate the 232OPSDA: the read A/D command, read digital I/O command, and the set digital output command. The command string consists of four bytes. The read A/D and digital I/O commands require an additional data byte. See Table 3.1.

Table 3.1: 232OPSDA Commands

Function

Command

Response

Read A/D

!0RA{#}

{ch#msb}{ch#lsb}{ch(#-1)msb}…

Channels

 

{ch0msb}{ch0lsb}

Read

!0RD

{I/O states}

Digital I/O

 

 

Set Digital

!0SO{#}

no response

Output

 

 

NOTE: Each {…} represents one byte.

In addition to the commands mentioned above, an extended set of commands are provided that support bit-error identification. These commands use the “#” character in place of the “!” character, and the compliment of the data byte must be sent after the data byte. The extended commands are shown in table 3.2.

Table 3.1: 232OPSDA Commands

Function

Command

Response

Read A/D

#0RA{#}~{#}

{ch#msb}~{ch#msb}{ch#lsb}{ch#lsb}

Channels

 

{ch(#-1)msb}~{ch(#-1)msb}….{ch0msb}

 

 

~{ch0msb}{ch0lsb}~{ch0lsb}

Read

#0RD

{I/O states}~{I/O states}

Digital I/O

 

 

Set Digital

#0SO{#}~{#}

no response

Output

 

 

NOTE: ~{…} represents the complement of one byte.

Before going into the specifics of each command, it is important to understand that a byte has a value from 0 to 255 and can be represented in decimal (0 to 255), hexadecimal (00 to FF), or by an ASCII character. The commands in Table 3.1 are shown in ASCII, for example: “!0RD”. The decimal and hexadecimal equivalents of some ASCII characters are shown in Table 3.2. Notice that the ASCII representation of the character “0” does not have a value of 0. Refer to Appendix A for more ASCII, decimal, and hexadecimal equivalents.

Documentation Number 232OPSDA1397 Manual

11

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

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

Image 13
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