B&B Electronics 485SDD16 manual Cmnd$ = ! + CHR$Maddr + SO + CHR$MSstates + CHR$LSstates, Maddr =

Models: 485SDD16

1 28
Download 28 pages 11.04 Kb
Page 15
Image 15

Step 1b - Set appropriate outputs LOW

MSstates = MSstates AND (NOT(mask))

LSstates = LSstates AND (NOT(mask))

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

Step 1c - Completing the command string:

Cmnd$ = "!" + CHR$(Maddr) + "SO" + CHR$(MSstates) + CHR$(LSstates)

Step 2 - Transmitting the command string:

Print #1, Cmnd$;

Example 5.3 - Set Output #0 HIGH and Output #14 LOW of module #5.

'Set module address.

Maddr = 5

'Set bit 0 of LSstates to make Output #0 HIGH.

LSstates = LSstates OR &H1

'Clear bit 4 of MSstates to make Output #14 LOW.

MSstates = MSstates AND (NOT(&H40))

Cmnd$ = "!" + CHR$(Maddr) + "SO" + CHR$(MSstates) +

CHR$(LSstates)

PRINT #1, Cmnd$;

Output #0 will be set HIGH and output #14 will be set LOW of module #5. All other output settings of module #5 will not be changed.

Define I/O Lines Command

The Define I/O Lines command is used to define each of the module's I/O lines as either an input or an output. This command requires two data bytes. Refer to this command in Chapter 3 for more information.

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.

485SDD16-1005 Manual

25

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$ = "!" + CHR$(Maddr) + "SD" + 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) on module #4.

'Set module's address to 4.

Maddr = 4

'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$ = "!" + CHR$(Maddr) + "SD" + 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) of module #4. All other I/O definitions will not be changed.

Set Power-up States Command

The Set Power-up States command is used to set the states of the digital outputs at power-up. This command requires two data

bytes. Refer to this command in Chapter 3 for more information. 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).

26

485SDD16-1005 Manual

B&B Electronics -- 707 Dayton Road -- Ottawa, IL 61350

B&B Electronics -- 707 Dayton Road -- 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 485SDD16 Cmnd$ = ! + CHR$Maddr + SO + CHR$MSstates + CHR$LSstates, Maddr =, LSstates = LSstates or &H1