Decoding rotary switches


Closed Thread
Results 1 to 9 of 9

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    You can probably use 1 ADC line for each rotary switch (or mix all of them, then feed it to a single ADC input). Basically you convert BCD to voltage with R2R resistor ladder, then you feed this output to your PIC.

    Hardware technique
    http://ww1.microchip.com/downloads/e...tes/00234a.pdf

    8-pin PIC - Tips 'n Tricks
    http://ww1.microchip.com/downloads/e...doc/40040b.pdf
    Last edited by mister_e; - 28th March 2009 at 18:10.
    Steve

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

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    The rotary switch should have a common plus four outs (bits). If this is the case then connect all the bits of the three rotary in parallel, using diodes, (total 12) and feed four pic pins inputs (better Rb0; Rb1; Rb2 and Rb3). Activate the internal pullup and connect Rb4; Rb5 and Rb6 (outputs) to the commons of the rotary switches .

    Set high Rb4; Rb5; and Rb6. Scan the rotary setting to low Rb4 and read the first rotary switch, set high Rb4 and Low Rb5 and read the second rotary etc.

    Your true reading will be 15-x; where x is the pic reading. If you want a direct reading you have to pulldown the input pins, reverse the diodes and reverse the scanning outputs level.

    Al.
    Last edited by aratti; - 28th March 2009 at 19:02.
    All progress began with an idea

  3. #3
    timmers's Avatar
    timmers Guest


    Did you find this post helpful? Yes | No

    Default

    .... or use a parallel in serial out shift register. By cascading several registers you can have as many inputs/outputs as you like.

    Tim.

  4. #4
    Join Date
    Feb 2006
    Location
    Brussels, Belgium
    Posts
    104


    Did you find this post helpful? Yes | No

    Default

    Steve:

    Figure 3 illustrates a resistor network, which changes a
    4x4 keypad into a switchable resistor matrix. The
    resulting resistance is read by an ADC or a capacitor
    charge timer, which determines the key that is pressed.
    This is practical only when one key is pressed at a time.

    ... so that doesn't really work in this case, but those are good links from Microchip, thanks

    Al: I think the usual solution is to use diodes like you say.

    Tim: I'll have to think about that

    Thanks for the inputs

    Andrew

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


    Did you find this post helpful? Yes | No

    Default

    So I haven't explain it correctly then... and i wasn't refer to a 4x4 matrix directly but multiple switch with a single I/O and a single (or multiple) ADC channel. Food for thoughts
    Steve

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

  6. #6
    Join Date
    Feb 2006
    Location
    Brussels, Belgium
    Posts
    104


    Did you find this post helpful? Yes | No

    Default

    Actually this is really one of those situations where I'm trying to force a solution to a problem - I picked up a bag of these switches for a couple of dollars and now I'm looking for a use. The application is just to provide a knob to control the duty cycle of three different PWM module. The easiest solution is just using a pot and an ADC channel - three pins, some case commands and it's done.

    Sometimes one's head gets lost in a dark place !

    Andrew
    Last edited by AndrewC; - 29th March 2009 at 10:33.

Similar Threads

  1. scanning BCD switches
    By dsicon in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 8th June 2008, 17:57
  2. Rotary encoders
    By mister_e in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st February 2007, 16:57
  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 : 0

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