Shop OBEX P1 Docs P2 Docs Learn Events
I need a "hint" with interfacing Thumbwheels. — Parallax Forums

I need a "hint" with interfacing Thumbwheels.

G McMurryG McMurry Posts: 134
edited 2015-05-13 23:21 in BASIC Stamp
I need to decode 30+ addresses with a Thumbwheel switch. I have a pair of BCD thumbwheels, 0-9 X 2. I want to use the least number of STAMP pins for the task.

Doing it with 8 bits is a no brainer --
Doing it with 6 is also easy. Each thumbwheel 1,2,4,8 through a diode, then a separate wire to each common. 4 + 2 = 6.

I have also been looking at building a resistor network and using RCTIME to decode the setting. Is this going to be reliable?

Does anyone have any other ideas?

On the system have, I easily have 4 bits on a connector. I don't mind building some external circuitry, itf I use the 6-bit technique above, I am already adding diodes.

I would love to get some ideas from this forum.

Greg

Comments

  • SapphireSapphire Posts: 496
    edited 2015-05-12 20:13
    If external circuitry are okay, I'd use a 74HC165 to take in all 8 lines and read them with a SHIFTIN command. You'll only need 3 pins, and if you have more inputs later, you can cascade them.
  • G McMurryG McMurry Posts: 134
    edited 2015-05-13 23:21
    I am looking at that. I think I can handle using 3 pins.

    I have been also looking at making a resistor ladder between all the switch contacts and decoding it with a single connection using RCTIME. Now the whole idea is sort of an adventure.

    If I use RCTIME, I might have to use quite a bit of memory for a lookup table. Maybe not worth the trouble.

    Greg
  • G McMurryG McMurry Posts: 134
    edited 2015-07-06 15:39
    If external circuitry are okay, I'd use a 74HC165 to take in all 8 lines and read them with a SHIFTIN command. You'll only need 3 pins, and if you have more inputs later, you can cascade them.

    OK -- This is how I am doing it.  Besides all the wiring mistakes I made (see picture) I now have a working BDC Thumbwheel interface. 

    So now I have two nibbles representing the two 0-9 thumbwheel switches.  How do i get them to come out as 0-99 in a byte? 

    I had a socket on my board for an EEPROM that I never needed.  It was easy to wire that socket to a 74hc165 and two decimal thumbwheel switches with pullups.  Now I need to take the two nibbles and turn them into a single decimal value I can use in my software.

    Greg
    3264 x 1836 - 1M
    3264 x 1836 - 2M
  • I am struggling with the new forum a bit and couldn't figure out how to attach another image to my original post using the edit function.  It would only let me provide an image as a link.

    I have attached my schematic for those who might want to do something like this.

    The code I used to acquire the data is right out of the "book" except that I used the /Q output of the 74HC165 to invert the Thumbwheel data.

    Get_Thumb:  'Use the EEPROM Socket to connect 74HC165 to read two Decimal Thumbwheels
      PULSOUT EEPromCS, 5                                                   ' grab the switch inputs
      SHIFTIN EEPromDataIO, IOClkPin, MSBPRE, [Thumbs]  ' shift them into variable Thumbs
    RETURN

    Works fine, I just would like to turn the 2 nibble byte into one bye that represents 0-99.  I could use some advice.

    Thanks

    2040 x 1540 - 218K
  • SapphireSapphire Posts: 496
    edited 2015-07-06 17:56
    Use this:
    Thumbs = 10*Thumbs.NIB1 + Thumbs.NIB0
    
  • That looks easy enough...  THANKS!
  • Here is what I ended up with...  Works great!

    Get_Thumb:  'Use the EEPROM Socket to connect to 74HC165 to read two Decimal Thumbwheels
      PULSOUT EEPromCS, 10                               ' grab the switch inputs
      SHIFTIN EEPromDataIO, IOClkPin, MSBPRE, [Thumbs]  ' shift them in

      Thumbs = (Thumbs.HIGHNIB * 10) + (Thumbs.LOWNIB)  'now combine the 2 thumbwheels to read 0-99
      Thumbs = Thumbs MAX 28                            'limit the Thumbs value to 28
    RETURN

    Thanks for all the help on this one.

    Greg
  • Great. You can even put the MAX 28 on the same line:


    [code]
  • Thanks for that...  I like things that combine commands on a single line.

    Greg
Sign In or Register to comment.