B&B Electronics 232OPSDA manual Command$ = !0RD, Reply$ = INPUT$ 1, #1, States = ASCReply$

Page 26

Step 1 - Constructing the command string:

Command$ = “!0RD”

Step 2 - Transmitting the command string:

Print #1, Command$

Step 3 - Receiving the data:

Reply$ = INPUT$ (1, #1)

Step 4 - Manipulating the data:

states = ASC(Reply$)

Step 5 - Determining an I/O’s status

status = states AND mask

By “ANDing” the value of states with the appropriate mask of an I/O line, the status of can be determined. If status is equal to zero then the I/O line is LOW. If status is not equal to zero then the I/O line is HIGH. Table 5.1 shows the mask values for each I/O.

Table 5.1 - Digital I/O Mask Values

I/O Line

 

Mask Values

 

 

Hexadecimal

 

Decimal

 

 

 

Digital Output #0

 

1H

 

1

Digital Input #0

 

8H

 

8

Step 6 - Repeat Step 5 until the status of each I/O has been determined.

Example 5.2 - Determining the status of Digital Input #0 of the module.

mask = &H8 Command$ = “!0RD” Print #1, Command$

Reply$ = INPUT$ (1, #1) states = ASC (Reply$) status = states AND mask

If status is equal to zero than Digital Input #0 is LOW. If status is not equal to zero than Digital Input #0 is HIGH.

Documentation Number 232OPSDA1397 Manual

25

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

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

Image 26
Contents Internet Electronics Mfg. Co. IncDesigned and Manufactured Ottawa, Illinois Table of Contents Page 232OPSDA Features IntroductionGeneral Block Diagram Packing ListAnalog to Digital Converter Software Installation232OPSDA Specifications Digital Output Power SupplyDigital Input CommunicationsConnections Terminal Function Description Block232OPSDA Digital I/O Connections Serial Port Connections232OPSDA Power Supply Connections Commands Syntax Reading A/D Channels Command 0RD Reading Digital I/O CommandSet Digital Output Command StatesNon-buffered 0 to 5VDC A/D Inputs Sampling RateConverter Range Buffered 0 to 5V A/D InputsTo 10VDC A/D Input 20mA Current Loop A/D InputGain = Application Program Interface B232OPSDAReadDigital Syntax CDeinitComPort Purpose B232OPSDASetDigitalOutputReturns See AlsoReturns See Also Low-Level CommunicationsPort Address DeinitComPortPrint #1, Command$ Read A/D CommandCommand$ = !0RA + CHR$channel MSB$ = INPUT$1, #1 LSB$ = INPUT$1, #1Read Digital I/O Command States = ASCReply$ Command$ = !0RDReply$ = INPUT$ 1, #1 Status = states and mask‘ Set Output High states = states or mask Command$ = !0SO + CHR$statesSet Digital Output State States = states and NOTmaskAppendix a Decimal to Hex to Ascii Conversion Decimal to HEX to Ascii Conversion Table