Chapter 5 - Software; Programming Techniques; Read I/O States Command; Read Configuration Command - B&B Electronics RS-232 Digital I/O Module 232SDD16 User Manual

Rs-232 digital i/o module
Table of Contents

Advertisement

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
B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350
PH (815) 433-5100 -- FAX (815) 433-5104
Example 5.1 - Determining the status of I/O lines #2 & #10
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.

Read Configuration Command

Step 1 - Constructing the command string:
Step 2 - Transmitting the command string:
Step 3 - Receiving the data:
Step 4 - Manipulating the data:
21
22
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
Table 5.1 - Digital I/O Mask Values
Mask Values
I/O Line #
Hexadecimal
0 & 8
1H
1 & 9
2H
2 & 10
4H
3 & 11
8H
4 & 12
10H
5 & 13
20H
6 & 14
40H
7 & 15
80H
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$)
B&B Electronics -- PO Box 1040 -- Ottawa, IL 61350
PH (815) 433-5100 -- FAX (815) 433-5104
Decimal
1
2
4
8
16
32
64
128
232SDD16-1005 Manual

Advertisement

Table of Contents
loading

Table of Contents