B&B Electronics 232OPSDA Set Digital Output State, ‘ Set Output High states = states or mask

Page 27

Set Digital Output State

The Set Digital Output command is used to set the state of the digital output line. This command requires a data byte. The data byte is used to specify the output state. Bit 0 corresponds to the state of digital output. If a bit is a 0 then the output will be set LOW. If a bit is a 1 then the output will be set HIGH. Note: This command ignores Bits 1-7 of the data byte.

Step 1a - Constructing the command string:

Set Output HIGH states = states OR mask

By “ORing” the current states with the appropriate mask of the digital output (given in Table 5.1), the output’s data bit will be set to a “1” (which will be set HIGH).

Step 1b - Set Output LOW

states = states AND (NOT(mask))

By “ANDing” the current states with the complement of the appropriate mask of a digital output (given in Table 5.1), the output’s data bit will be set to a “0” (which will be set LOW).

Step 1c - Construct the string

Command$ = “!0SO” + CHR$(states)

Step 2 - Transmitting the command string:

Print #1, Command$

Example 5.3 - Set Digital Output #0 HIGH.

Set bit 0 to make Digital Output #0 HIGH states = states OR 1

Command$ = “!0SO” + CHR$(states) Print #1, Command$

Digital Output #0 will be set HIGH. Note that the variable states is assumed to be the value from Example 5.2.

26Documentation Number 232OPSDA1397 Manual

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

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

Image 27
Contents Electronics Mfg. Co. Inc Designed and Manufactured Ottawa, IllinoisInternet Table of Contents Page Introduction 232OPSDA FeaturesPacking List General Block DiagramSoftware Installation 232OPSDA SpecificationsAnalog to Digital Converter Communications Power SupplyDigital Input Digital OutputTerminal Function Description Block Connections232OPSDA Serial Port Connections Digital I/O Connections232OPSDA Power Supply Connections Commands Syntax Reading A/D Channels Command States Reading Digital I/O CommandSet Digital Output Command 0RDBuffered 0 to 5V A/D Inputs Sampling RateConverter Range Non-buffered 0 to 5VDC A/D Inputs20mA Current Loop A/D Input To 10VDC A/D InputGain = Application Program Interface Syntax C B232OPSDAReadDigitalSee Also B232OPSDASetDigitalOutputReturns DeinitComPort PurposeDeinitComPort Low-Level CommunicationsPort Address Returns See AlsoMSB$ = INPUT$1, #1 LSB$ = INPUT$1, #1 Read A/D CommandCommand$ = !0RA + CHR$channel Print #1, Command$Read Digital I/O Command Status = states and mask Command$ = !0RDReply$ = INPUT$ 1, #1 States = ASCReply$States = states and NOTmask Command$ = !0SO + CHR$statesSet Digital Output State ‘ Set Output High states = states or maskDecimal to HEX to Ascii Conversion Table Appendix a Decimal to Hex to Ascii Conversion