Step 1 - Constructing the command string:

Command$ = “!0RD”

Step 2 - Transmitting the command string:

Print #1, Command$

Step 3 - Receiving the data:

Reply$ = INPUT$ (1, #1)

Step 4 - Manipulating the data:

states = ASC(Reply$)

Step 5 - Determining an I/O’s status

status = states AND mask

By “ANDing” the value of states with the appropriate mask of an I/O line, the status of can be determined. If status is equal to zero then the I/O line is LOW. If status is not equal to zero then the I/O line is HIGH. Table 5.1 shows the mask values for each I/O.

Table 5.1 - Digital I/O Mask Values

I/O Line

 

Mask Values

 

 

Hexadecimal

 

Decimal

 

 

 

Digital Output #0

 

1H

 

1

Digital Input #0

 

8H

 

8

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

Example 5.2 - Determining the status of Digital Input #0 of the module.

mask = &H8 Command$ = “!0RD” Print #1, Command$

Reply$ = INPUT$ (1, #1) states = ASC (Reply$) status = states AND mask

If status is equal to zero than Digital Input #0 is LOW. If status is not equal to zero than Digital Input #0 is HIGH.

Documentation Number 232OPSDA1397 Manual

25

B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350

PH (815) 433-5100 -- FAX (815) 433-5105

Page 26
Image 26
B&B Electronics 232OPSDA manual Command$ = !0RD, Reply$ = INPUT$ 1, #1, States = ASCReply$, Status = states and mask