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.
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 |
B&B Electronics | B&B Electronics |
PH (815) | PH (815) |