Author Topic: SBC65EC + PT24E + DIP switches: code/algorithm to read switches  (Read 4418 times)

Rick314

  • Hero Member
  • *****
  • Posts: 55
  • SBC65EC/66EC, PT24E, LCD2S-204FHB, PICkit 3, MPLAB
    • View Profile
SBC65EC + PT24E + DIP switches: code/algorithm to read switches
« on: November 03, 2011, 09:15:27 AM »
http://www.modtronix.com/products/pt32e/pt24er1.pdf is the 4-page schematic/layout of the PT24E.  On the first page there are parts labeled "8 Way DIP Switch - NOT ASSEMBLED".  I am using that board with the SBC65EC mounted on it, and want to read the 8 DIP switches through the indicated 74HC165 shift register.

Can anyone provide example code (any language, or detailed pseudo-code) to read the 8 DIP switches from a computer connected to the SBC65EC via the Internet?

I hope to get something like the example Java code I provided for the SBC65EC/PT24E combination to set its 8 LEDs, posted here:
http://forum.modtronix.com/index.php?topic=1409.msg4471

Rick314

  • Hero Member
  • *****
  • Posts: 55
  • SBC65EC/66EC, PT24E, LCD2S-204FHB, PICkit 3, MPLAB
    • View Profile
Re: SBC65EC + PT24E + DIP switches: code/algorithm to read switches
« Reply #1 on: November 05, 2011, 07:40:18 PM »
I just ordered the 4 required parts shown on the PT24E-ASM schematic (8 x 47 kohm 9-pin SIP resistor array; 47 kohm leaded resistor; 74HC165N parallel-in/serial-out shift register; 8 switches, side-actuated, in a single DIP package) from Digi-Key (http://www.digikey.com) for US$2.50 parts plus US$2.50 shipping to Liberty Lake, WA, USA.  I think I understand how to read the switches now, and will post a Java program to do so if I can get it working.

Update 3 days later: I missed a 5th required part on page 2 of the PT24E-ASM data sheet, "C2", an 0.1 uf capacitor located near U2/74HC165N for power supply filtering.  There is a related minor mistake on the data sheet too -- On page 2, "C1", a similar power supply filtering capacitor for U1/74HC595, is shown in the "Not Assembled!" box and it is actually already loaded (along with U1/74HC595, that drives the LEDs).
« Last Edit: November 08, 2011, 02:33:52 PM by Rick314 »

Rick314

  • Hero Member
  • *****
  • Posts: 55
  • SBC65EC/66EC, PT24E, LCD2S-204FHB, PICkit 3, MPLAB
    • View Profile
Re: SBC65EC + PT24E + DIP switches: code/algorithm to read switches
« Reply #2 on: November 15, 2011, 10:09:24 PM »
My PT24E switch parts are installed, as per the attached picture.  For reference, here are the Digi-Key (http://www.digikey.com/) part numbers of the parts I used:

568-1410-5-ND   U2, 74HC165N IC, parallel-in/serial-out shift register
CT1958MST-ND   S1, switch, side actuated, 8 sections, DIP package
CSC47KW-ND     RN4, resistor array, 8 x 47 kOhm, 9-pin, SIP package
OD473JE-ND       R1, resistor, 47 kOhm, .25W, carbon comp
478-5218-ND      C2, capacitor, 0.1 uF, ceramic, 0.1-inch lead spacing
WM4201-ND       CON3, 3-pin Molex connector for PT24E RS-232 I/O

The last part isn't needed for switch read-back, but is useful for RS-232 control of the SBC65EC when it is mounted on the PT24E.  There is a problem with mounting the switch S1 given above on the PT24E, with details given at: http://forum.modtronix.com/index.php?topic=1506.0

In the example below, the switches are set left-to-right (switch number 1 to 8) up down up down up up down down.  Down is on, and up is off.  Do the following using the SBC65EC web interface.  Port Values page; log in (user admin, password pw are default); Port Settings page; Port C bits 2 and 1 should be outputs (checked) and bit 0 should be an input (unchecked); Submit; Port Values page; C2 = 1 (click Port C bit 2 until the value is 1); C1 = 1.  This is the starting state.  Now proceed to read the 8 switch values as shown below.  "C2n" means "C2 negative pulse" or change the value of C2 from 1 to 0, let the web page indicate the change, then change the value of C2 from 0 to 1.

C2n      Latch the 8 switch values into the shift register.
            Read C0 (switch 8) = 0 (down, or on, or C0 level is low).
C1n      Read C0 (switch 7) = 0.
C1n      Read C0 (switch 6) = 1.
C1n      Read C0 (switch 5) = 1.
C1n      Read C0 (switch 4) = 0.
C1n      Read C0 (switch 3) = 1.
C1n      Read C0 (switch 2) = 0.
C1n      Read C0 (switch 1) = 1.

Kongress

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: SBC65EC + PT24E + DIP switches: code/algorithm to read switches
« Reply #3 on: January 22, 2012, 02:00:03 PM »
Hey Rick,

Thanks for the info. I also have a SBC65EC and PT24E on order and the part numbers you provided saved me a lot of time trying to track down accessories to order. Thanks!