Home

IBM 5150  -  Test of SW1 and SW2 via BASIC


SW1 and SW2 are the two switch blocks on an IBM 5150 motherboard.

Although there will be DOS based diagnostic programs that test SW1 and SW2, sometimes 5150 users are in the situation of being able to boot to BASIC, but not DOS.
The tests below will allow such users to determine, via BASIC, if faulty SW1/SW2 circuitry is the possible reason why they can't boot to DOS.

Failure of a test below indicates either a faulty switch block or failure of the associated circuitry that selects/reads the switch blocks.

These tests are not applicable to the IBM 5160:
   * SW1 is wired up differently on a 5160 motherboard.
   * SW2 is not present on a 5160 motherboard.


--------------------------------------------------------------------------------------------------------
TEST 1 of 2  -  switch block SW1 (closest to board centre)
--------------------------------------------------------------------------------------------------------

1. Boot to BASIC

2. Enter the following 3 lines of program:

10 out &h61,&hcc
20 print inp(&h60)
30 out &h61,&h4c

Note: Line 30 is required to re-enable the keyboard (keyboard reading and SW1 reading can't be done at the same time).


3. Set all switches on SW1 to OFF.
4. Run the program. You should see "255" displayed.

5. Set all switches on SW1 to ON.
6. Run the program. You should see "0" displayed.

7. Set SW1 so that switch 1 is the only switch OFF.
8. Run the program. You should see "1" displayed.

9. Repeat steps 7 and 8 for each of the remaining 7 switches:
        switch 2 is only one OFF - should see "2"
        switch 3 is only one OFF - should see "4"
        switch 4 is only one OFF - should see "8"
        switch 5 is only one OFF - should see "16"
        switch 6 is only one OFF - should see "32"
        switch 7 is only one OFF - should see "64"
        switch 8 is only one OFF - should see "128"

10. Set SW1 so that switches 1,3,5,7 are ON and switches 2,4,6,8 are OFF.
11. Run the program. You should see "170" displayed.                [ 170 decimal = 10101010 binary ]

12. Set SW1 so that switches 1,3,5,7 are OFF and switches 2,4,6,8 are ON.
13. Run the program. You should see "85" displayed.                [ 85 decimal = 01010101 binary ]

14. Set SW1 to normal setting.

15. Reboot computer.



--------------------------------------------------------------------------------------------------------
TEST 2 of 2  -  switch block SW2 (block closest to board edge)
--------------------------------------------------------------------------------------------------------

INFO: Only the first 5 switches in SW2 are connected.
          Not all 5 can be read at once - you can read the first 4 in one operation and the 5th in another.


1. Boot to BASIC

2. Enter the following 5 lines of program:

10 out &h61,&h4c
20 lower4% = inp(&h62) and &h0f
30 out &h61,&h48
40 bit5% = inp(&h62) and &h01
50 print lower4% " / " bit5%

3. Set switches 1 to 5 on SW2 to OFF (remaining switches on SW2 do nothing).
4. Run the program. You should see "15 / 1" displayed.

INFO: The first figure displayed is for switches 1 to 4 and the next figure is for switch 5

5. Set switches 1 to 5 on SW2 to ON.
6. Run the program. You should see "0 / 0" displayed.

7. Set SW1 so that switch 1 is OFF and switches 2 to 5 are ON.
8. Run the program. You should see "1 / 0" displayed.

9. Repeat steps 7 and 8 for each of the remaining 3 switches:
        switch 2 is only one OFF - should see "2 / 0"
        switch 3 is only one OFF - should see "4 / 0"
        switch 4 is only one OFF - should see "8 / 0"
        switch 5 is only one OFF - should see "0 / 1"

10. Set SW2 so that switches 1,3,5 are ON and switches 2 and 4 are OFF.
11. Run the program. You should see "10 / 0" displayed.

12. Set SW2 so that switches 1,3,5 are OFF and switches 2 and 4 are ON.
13. Run the program. You should see "5 / 1" displayed.

14. Set SW2 to normal setting.

15. Reboot computer.