B&B Electronics 232SDD16 manual Define I/O Lines Command, LSdefs = LSdefs or &H80

Page 15

Define I/O Lines Command

Step 1a - Construct the command string:

Define an I/O line as Output

MSdefs = MSdefs OR mask

LSdefs = LSdefs OR mask

By "ORing" the current definitions with the appropriate I/O line mask, the I/O line's data bit will be set to a "1" (HIGH) and the I/O line will be defined as an Output.

Step 1b - Define an I/O line as an Input

MSdefs = MSdefs AND (NOT(mask))

LSdefs = LSdefs AND (NOT(mask))

By "ANDing" the current definitions with the complement of the appropriate I/O line mask the I/O line's data bit will be set to a "0" (LOW) and the I/O line will be defined as an Input.

Step 1c - Completing the command string:

Cmnd$ = "!0SD" + CHR$(MSdefs) + CHR$(LSdefs) Step 2 - Transmitting the command string:

Print #1, Cmnd$;

Example 5.4 - Define I/O line #7 as an Output (HIGH) and I/O line #8 as an input (LOW).

'Set bit 7 of LSdefs to make I/O line #7 an Output (HIGH).

LSdefs = LSdefs OR &H80

'Clear bit 0 of MSdefs to make I/O line #8 an Input (LOW).

MSdefs = MSdefs AND (NOT(&H1))

Cmnd$ = "!0SD" + CHR$(MSdefs) + CHR$(LSdefs)

Print #1, Cmnd$;

MSIO$ = INPUT$(1,#1)

I/O #7 will be defined as an Output (HIGH) and I/O line #8 will be defined as an Input (LOW). All other I/O definitions will not be changed.

Set Power-up States Command

Step 1a - Construct the command string:

Set appropriate outputs power-up states HIGH

MSpups = MSpups OR mask

LSpups = LSpups OR mask

By "ORing" the current power-up states with the appropriate mask of a digital output line, the power-up state's data bit will be set to a "1" (HIGH).

232SDD16-1005 Manual

25

Step 1b - Set appropriate outputs power-up states LOW

MSpups = MSpups AND (NOT(mask))

LSpups = LSpups AND (NOT(mask))

By "ANDing" the current power-up states with the complement of the appropriate mask of a digital output line, the power-up state's data bit will be set to a "0" (LOW).

Step 1c - Completing the command string:

Cmnd$ = "!0SS" + CHR$(MSpups) + CHR$(LSpups) Step 2 - Transmitting the command string:

Print #1, Cmnd$;

Example 5.5 - Set Output line #5's power-up state HIGH and Output line #13's power-up state LOW.

'Set bit 0 of LSpups to make Output #5's power-up state HIGH.

LSpups = LSpups OR &H20

'Clear bit 4 of MSpups to make Output #13's power-up state LOW.

MSpups = MSpups AND (NOT(&H20))

Cmnd$ = "!0SS" + CHR$(MSpups) + CHR$(LSpups)

Print #1, Cmnd$;

MSIO$ = INPUT$(1,#1)

Output #5's power-up state will be set HIGH and output #13's power-up state will be set LOW. All other output power-up states will not be changed.

26

232SDD16-1005 Manual

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

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

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

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

Image 15
Contents Electronics Mfg. Co. Inc Designed and Manufactured Ottawa, IllinoisInternet Table of Contents 232SDD16 Features Introduction232SDD16-1005 Manual 232SDD16 Specifications CommunicationsSize Serial Port Connections ConnectionsDigital I/O Connections 232SDD16 I/O Port Pinout232SDD16 To DCE Connections RS-232 Connector PinoutPower Supply Connections 232SDD16 To DTE ConnectionsSyntax Commands232SDD16 Commands Equivalent ValuesRead I/O Lines Command Set Output Lines CommandBit Assignments for I/O Lines Define I/O Lines Command Set Power-up States CommandRead Configuration Command Bin. Example !0RC01010101010000010101000001000000 Digital Inputs InterfacingIsolated Solid State Input Software Programming TechniquesDigital I/O Mask Values MSstates = MSstates or mask LSstates = LSstates or mask Set Output States CommandMSdefs = MSdefs and mask LSdefs = LSdefs and mask MSpups = MSpups and mask LSpups = LSpups and maskMSdefs = MSdefs and NOTmask LSdefs = LSdefs and NOTmask Define I/O Lines CommandSet Power-up States Command MSdefs = MSdefs or mask LSdefs = LSdefs or maskRunning Demonstration Program Demonstration ProgramAppendix a Appendix B Decimal to Hexadecimal Conversion 232SDD16-1005 Manual Appendix C Figure C.1 DTB25 Outline DrawingTable C.2 DBM16 I/O Connections Table C.1 DTB25 ConnectionsDBM16 Interfacing Figure C.2 DBM16 Outline DrawingFigure C.6 Isolated Solid State Input DBM16 Specifications Lines InputsOutputs 232SDD16-1005 Manual Appendix C Comp = not x and &HFF #0RDMsb~ I/O msbI/O lsb ~ I/O lsb 00FF01FE232SDD16-1005 Manual Appendix D Table D-1 Extended Commands