B&B Electronics 232SDD16 manual Software, Programming Techniques, Digital I/O Mask Values

Page 13

Chapter 5 - Software

This chapter will be divided into two sections. The first section covers programming techniques for constructing a command string, receiving data and manipulating data in QuickBASIC. The second section discusses how to install and run the demonstration program on an IBM PC or compatible.

Programming Techniques

This section shows steps and examples of programming the 232SDD16 in QuickBasic. If you are programming in another language, this section can be helpful as a guideline for programming the 232SDD16.

Read I/O States Command

Step 1 - Constructing the command string:

Cmnd$ = "!0RD"

Step 2 - Transmitting the command string:

PRINT #1, Cmnd$;

Step 3 - Receiving the data:

MSIO$ = INPUT$(1,#1)

LSIO$ = INPUT$(1,#1)

Step 4 - Manipulating the data:

MSIO = ASC(MSIO$)

LSIO = ASC(LSIO$)

Step 5 - Determining an I/O's status:

MSstatus = MSIO AND mask

LSstatus = LSIO AND mask

By "ANDing" the value of MSIO or LSIO with the appropriate mask of an I/O line, the status of the I/O line can be determined. If the status is equal to zero the I/O line is LOW. If the status is not equal to zero the I/O line is HIGH. 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.

232SDD16-1005 Manual

21

Example 5.1 - Determining the status of I/O lines #2 & #10 mask = &H4

Cmnd$ = "!0RD"

PRINT #1, Cmnd$;

MSIO$ = INPUT$(1,#1)

LSIO$ = INPUT$(1,#1)

MSIO = ASC(MSIO$)

LSIO = ASC(LSIO$)

MSstatus = MSIO AND mask

LSstatus = LSIO AND mask

If LSstatus equals zero then I/O line #2 is LOW. If LSstatus is not equal to zero then I/O line #2 is HIGH. If MSstatus equals zero then I/O line #10 is LOW. If MSstatus is not equal to zero then I/O line #10 is HIGH.

Table 5.1 - Digital I/O Mask Values

 

 

Mask Values

I/O Line #

 

Hexadecimal

Decimal

 

 

 

 

 

 

0 & 8

 

1H

1

 

1 & 9

 

2H

2

 

2 & 10

 

4H

4

 

3 & 11

 

8H

8

 

4 & 12

 

10H

16

 

5 & 13

 

20H

32

 

6 & 14

 

40H

64

 

7 & 15

 

80H

128

 

Read Configuration Command

Step 1 - Constructing the command string:

Cmnd$ = "!0RC"

Step 2 - Transmitting the command string:

PRINT #1, Cmnd$;

Step 3 - Receiving the data:

MSdefs$ = INPUT$(1,#1)

LSdefs$ = INPUT$(1,#1)

MSpups$ = INPUT$(1,#1)

LSpups$ = INPUT$(1,#1)

Step 4 - Manipulating the data:

MSdefs = ASC(MSdefs$)

LSdefs = ASC(LSdefs$)

MSpups = ASC(MSpups$)

LSpups = ASC(LSpups$)

22

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 13
Contents Designed and Manufactured Ottawa, Illinois Electronics Mfg. Co. IncInternet Table of Contents Introduction 232SDD16 Features232SDD16-1005 Manual Communications 232SDD16 SpecificationsSize Digital I/O Connections Connections232SDD16 I/O Port Pinout Serial Port ConnectionsPower Supply Connections RS-232 Connector Pinout232SDD16 To DTE Connections 232SDD16 To DCE Connections232SDD16 Commands CommandsEquivalent Values SyntaxSet Output Lines Command Read I/O Lines CommandBit Assignments for I/O Lines Set Power-up States Command Define I/O Lines CommandRead Configuration Command Bin. Example !0RC01010101010000010101000001000000 Digital Inputs InterfacingIsolated Solid State Input Programming Techniques SoftwareDigital I/O Mask Values MSdefs = MSdefs and mask LSdefs = LSdefs and mask Set Output States CommandMSpups = MSpups and mask LSpups = LSpups and mask MSstates = MSstates or mask LSstates = LSstates or maskSet Power-up States Command Define I/O Lines CommandMSdefs = MSdefs or mask LSdefs = LSdefs or mask MSdefs = MSdefs and NOTmask LSdefs = LSdefs and NOTmaskRunning 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 Inputs DBM16 Specifications LinesOutputs 232SDD16-1005 Manual Appendix C Msb~ I/O msbI/O lsb ~ I/O lsb #0RD00FF01FE Comp = not x and &HFF232SDD16-1005 Manual Appendix D Table D-1 Extended Commands