B&B Electronics 232SDD16 manual MSdefs = MSdefs and mask LSdefs = LSdefs and mask

Page 14

Step 5 - Determining the I/O line definitions:

MSdefs = MSdefs AND mask

LSdefs = LSdefs AND mask

By "ANDing" the value of MSdefs or LSdefs with the appropriate mask of an I/O line, the I/O line definition can be determined. If the status is equal to zero the I/O line is an INPUT. If the status is not equal to zero the I/O line is an OUTPUT. Table 5.1 shows the mask values for each I/O line.

Step 6 - Repeat Step 5 until the status of each I/O line has been determined.

Step 7 - Determining an OUTPUT's Power-up state:

MSpups = MSpups AND mask

LSpups = LSpups AND mask

By "ANDing" the value of MSpups or LSpups with the appropriate mask of an Output line, the Output line definition can be determined. If the status is equal to zero the Output power-up state will be LOW. If the status is not equal to zero the Output power-up state will be HIGH. Table 5.1 shows the mask values for each I/O line.

Step 8 - Repeat Step 7 until the power-up state of each Output line has been determined.

Example 5.2 - Determining the definition and power-up state of I/O lines #2 & #10

mask = &H4 Cmnd$ = "!0RC" PRINT #1, Cmnd$; MSdefs$ = INPUT$(1,#1) LSdefs$ = INPUT$(1,#1) MSpups$ = INPUT$(1,#1) LSpups$ = INPUT$(1,#1) MSdefs = ASC(MSdefs$) LSdefs = ASC(LSdefs$) MSpups = ASC(MSpups$) LSpups = ASC(LSpups$) MSdefs = MSdefs AND mask LSdefs = LSdefs AND mask MSpups = MSpups AND mask LSpups = LSpups AND mask

232SDD16-1005 Manual

23

If LSdefs equals zero then I/O line #2 is an INPUT and if not equal to zero then I/O line #2 is an OUTPUT. If MSdefs equals zero then I/O line #10 is an INPUT and if not equal to zero then I/O line #10 is an OUTPUT. If LSpups equals zero then Output line #2's power-up state is LOW and if not equal to zero then Output line #2's power-up state is HIGH. If MSpups equals zero then Output line #10's power- up state is LOW and if not equal to zero then Output line #10's power-up state is HIGH.

Set Output States Command

Step 1a - Construct the command string:

Set appropriate outputs HIGH

MSstates = MSstates OR mask

LSstates = LSstates OR mask

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

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$ = "!0SO" + CHR$(MSstates) + CHR$(LSstates) Step 2 - Transmitting the command string:

Print #1, Cmnd$;

Example 5.3 - Set Output #0 HIGH and Output #14 LOW. '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$ = "!0SO" + CHR$(MSstates) + CHR$(LSstates)

PRINT #1, Cmnd$;

MSIO$ = INPUT$(1,#1)

Output #0 will be set HIGH and output #14 will be set LOW. All other output setting will not be changed.

24

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 14
Contents Internet Electronics Mfg. Co. IncDesigned and Manufactured Ottawa, Illinois Table of Contents 232SDD16-1005 Manual 232SDD16 FeaturesIntroduction Size 232SDD16 SpecificationsCommunications 232SDD16 I/O Port Pinout ConnectionsDigital I/O Connections Serial Port Connections232SDD16 To DTE Connections RS-232 Connector PinoutPower Supply Connections 232SDD16 To DCE ConnectionsEquivalent Values Commands232SDD16 Commands SyntaxBit Assignments for I/O Lines Read I/O Lines CommandSet Output Lines Command Read Configuration Command Define I/O Lines CommandSet Power-up States Command Bin. Example !0RC01010101010000010101000001000000 Interfacing Digital InputsIsolated Solid State Input Digital I/O Mask Values SoftwareProgramming Techniques MSpups = MSpups and mask LSpups = LSpups and mask Set Output States CommandMSdefs = MSdefs and mask LSdefs = LSdefs and mask MSstates = MSstates or mask LSstates = LSstates or maskMSdefs = MSdefs or mask LSdefs = LSdefs or mask Define I/O Lines CommandSet Power-up States Command MSdefs = MSdefs and NOTmask LSdefs = LSdefs and NOTmaskDemonstration Program Running Demonstration ProgramAppendix a Appendix B Decimal to Hexadecimal Conversion Figure C.1 DTB25 Outline Drawing 232SDD16-1005 Manual Appendix CTable C.1 DTB25 Connections Table C.2 DBM16 I/O ConnectionsFigure C.2 DBM16 Outline Drawing DBM16 InterfacingFigure C.6 Isolated Solid State Input Outputs DBM16 Specifications LinesInputs 232SDD16-1005 Manual Appendix C 00FF01FE #0RDMsb~ I/O msbI/O lsb ~ I/O lsb Comp = not x and &HFFTable D-1 Extended Commands 232SDD16-1005 Manual Appendix D