scanning BCD switches


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2003
    Posts
    98

    Default scanning BCD switches

    hi all
    I am looking for ideas for the most elegant way to read 3 BCD switches

    by elegant i mean less parts, less PIC pins

    currently i use the following 7 pin scheme (which works fine):
    the 1 2 4 8 pins of the 3 switches are diode combined to 4 PIC pins
    the 3 common legs of the switches are driven by 3 more pic pins
    if the port does not have pullups you need those too

    the part i dislike the most is the high part count of the 12 diodes
    ds

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Could put all 12 pins of the BCDs on 2 8-bit parallel in/serial out type latches (can't think of a decent part number off the top of my head).
    Trigger the load pin to grab the logic levels of all the pins, then shift in the 12 bits manually into a word, split the word up into the individual components and go.

    OR...could use a 2nd PIC. Connect the 4 bit outputs of each BCD switch to whatever pins you want on the 2nd PIC. Use a 13th pin on the 2nd PIC as a trigger from the 1st PIC and have the 2nd PIC send out a couple bytes serially to the 1st PIC, which is waiting for it. 2 lines used on the 1st PIC, trigger and serial in. Don't even need to use the serial module, just use SERIN/SERIN2/DEBUGIN/whatever.
    Parts count: 1 extra PIC (18 pins, simple firmware), add a 4Mhz resonator (if you use serial, you'd want a real oscillator, not the internal one for accuracy), pullups for the BCD switch lines (which you probably already have). That should be about it.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi D.

    You might try something like Tip#5 or #7 in this from microchip.

    Tips ‘n Tricks
    http://ww1.microchip.com/downloads/e...Doc/40040b.pdf
    <br>
    DT

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    1 I/O expander such as MCP23016 + 3 resistors should do.

    Tons of way to multiplex stuff on low pin count PIC, and then.. this bring this ol', but still good Microchip app note AN234.
    http://ww1.microchip.com/downloads/e...tes/00234a.pdf

    and
    http://techtrain.microchip.com/maste...ses/40040b.pdf

    <hr>
    OK Darrel

    ADC is one of my favorite choice...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default

    thanks all
    i like the single pin ADC approach, seems like the least stuff
    i am already doing pushbuttons this way

    too bad there are no res values in the MC app note #7, guess that would spoil the fun

    but on 3 bcd sws there would be 1000 combinations, strikes me as too touchy for a 10 bit AD, or am i missing something ?
    ds

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dsicon View Post
    but on 3 bcd sws there would be 1000 combinations
    But I'm sure you only need 512 of them.

    Yeah, I think reading all 3 BCD switches on 1 A/D might be a stretch.
    But with each digit on different pins, 3 pins would be better than 7.
    Then there's only 16 voltage possibilities per pin (10 used). Piece of cake for A/D.
    <br>
    DT

  7. #7


    Did you find this post helpful? Yes | No

    Default BCD switches

    ds,
    Do your switch readings need to be checked often, rearly, only once ?

    don
    amgen

  8. #8
    Join Date
    Nov 2003
    Posts
    98


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by amgen View Post
    ds,
    Do your switch readings need to be checked often, rearly, only once ?

    don
    amgen
    they will either be polled at the top of the main loop or in response to a button push, haven't started the program yet

    it looks like i will be using the 7 pin diode matrix approach after all since it seems to offer the best set of tradeoffs given other considerations in the design, i just really don't like stuffing the 12 diodes due to insertion cost
    oh well

Similar Threads

  1. DS1302 16F628 Woes
    By idtat in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th January 2009, 14:15
  2. Rotary BCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 03:04
  3. two BCD switches
    By Mugel in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st November 2006, 22:53
  4. switches & LEDs ... my first attempt
    By yankee in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 28th January 2006, 12:51
  5. Two switches per pin!!!
    By picnaut in forum General
    Replies: 4
    Last Post: - 18th June 2004, 19:02

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts