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

Page 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

Image 15
Contents Sales@bb-elec.com Support@bb-elec.com Electronics Mfg. Co. IncDesigned and Manufactured Ottawa, Illinois InternetTable of Contents 485SDD16 Features 485SDD16 SpecificationsIntroduction Power Supply CommunicationsSize Serial Port Connections ConnectionsDigital I/O Connections 485SDD16 I/O Port PinoutExample of Multi-Node Network Syntax Commands485SDD16 Commands Equivalent ValuesRead I/O Lines Command Set Output Lines CommandBit Assignments for I/O Lines Command AddrSC Argument Set Module Address CommandSet Turn-around Delay Command Define I/O Lines CommandCommand AddrRC Argument None Response Set Power-up States CommandRead Configuration Command Read Configuration command returns the modules I/ODigital Inputs InterfacingDigital Outputs Isolated Solid State InputSoftware 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 maskMaddr = Define I/O Lines CommandSet Power-up States Command Cmnd$ = ! + CHR$Maddr + SO + CHR$MSstates + CHR$LSstatesLSpups = LSpups or &H20 Set Module Address CommandMSpups = MSpups and NOTmask LSpups = LSpups and NOTmask Cmnd$ = ! + CHR$Maddr + SS + CHR$MSpups + CHR$LSpupsRunning Demonstration Program Demonstration Program485SDD16-1005 Manual Appendix a Decimal485SDD16-1005 Manual Appendix a 119 120 121 122 123 124 125 126 127485SDD16-1005 Manual Appendix B Appendix B240 4th Hex digit Decimal equals 10FC hexadecimal Decimal to Hexadecimal Conversion252 3rd Hex digitAppendix C Table C.1 DTB25 Connections Table C.2 DBM16 I/O ConnectionsDBM16 Interfacing 485SDD16-1005 Manual Appendix C Figure C.4 Solid State InputConnections Size DBM16 Specifications LinesPower Supply Input Voltage TotalFigure C.10 DBM16 Schematic Comp = not x and &HFF #addrRDMsb~ I/O msbI/O lsb ~ I/O lsb 00FF01FE485SDD16-1005 Manual Appendix D Table D-1 Extended Commands