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

Page 15
Image 15
B&B Electronics 232SDD16 manual Define I/O Lines Command, MSdefs = MSdefs or mask LSdefs = LSdefs or mask