Shop OBEX P1 Docs P2 Docs Learn Events
Active High Button with 5V — Parallax Forums

Active High Button with 5V

Duane DegnDuane Degn Posts: 10,588
edited 2014-08-17 16:15 in Propeller 1
Normally when I want to use a button with a Propeller it use this sort of circuit.
*************************************************
    Push Button Schematic 3.3V Active Low
*************************************************  


                 3.3V
                          button
                   10KΩ   ─┻─
  Prop Pin  ─────┻────────┘ └─┐
                               



I have some encoders which include a push button and when the button is pressed it shorts the button pin of the encoder to the 5V line to the encoder.

For this button, I figure I'll pull the line low and use a series resistor to protect the Prop from the 5V. But with both a pull-down resistor and a series resistor, I end up with a voltage divider. This isn't necessarily a bad thing since I'm starting with 5V.

Now I'm trying to figure out where the two resistors should be placed with respect to each other.

My first choice is to use this circuit.
*************************************************
    Push Button Schematic 5V Active High
    Version A
*************************************************  


                                   5V
                            button  
                      R1     ─┻─    │
  Prop Pin  ─────┳────────┘ └────┘
               R2             
                  



I'll probably just use 10k ohm resistors for both R1 and R2 since this should give 2.5V at the Prop and register as logic high.

As I was thinking about this I wondered if this sort of circuit would change much.
*************************************************
    Push Button Schematic 5V Active High
    Version B 
*************************************************  


                                 5V
                         button   
               R1         ─┻─     │
  Prop Pin  ─────┳─────┘ └─────┘
                     R2          
                    



The version B circuit pulls the line low through both R1 and R2 so I assume this would increase the recovery time between button presses (though I doubt this will be an issue).

My (frequently wrong) gut tells me version A is the better choice but is there a rule to this sort of thing?

Will the voltage at the Prop pin be closer to 5V with version B than with version A? It seems like voltage at the Prop pin will probably be 3.3V plus the clamping diode voltage drop.

I'm pretty sure either version would work but is one version more "correct"?

Am I correct in thinking as long as R1 is at least 3k ohm and R2 has the same or greater resistance as R1, then I'm okay with all sorts of resistor combinations?

I originally planned to use version A but version B would be a bit easier to solder with the way things are physically laid out. There's a ground connection on the encoder/button so I'm tempted to just add the pull-down resistor on the button itself and then add a series resistor between the button and the Propeller.

I'm curious if there's a reason to use one circuit rather than the other?

I'll hold off on the soldering until I get some feedback on this issue.

Comments

  • LA6WNALA6WNA Posts: 138
    edited 2014-08-17 13:43
    Hi Duane.
    I would definetly used version A to get sure about that the prop-pin mever got more than 3,3v. As you say, this is a voltage divider. If the R1 and R2 is equal, you`ll get about 2,5v into the prop pin.
    In version B, you will only get a current flow through R2. This because the high Z input of the pin. Said in another way; R1 will not cause any voltage drop because there`s no current flowing through it. That means the voltage is nearly 5v at the both side of it.
    So, Go for version A is my suggestion, even when the layout does it more tricky. Think thas the safest way..
  • Cluso99Cluso99 Posts: 18,069
    edited 2014-08-17 14:39
    A is the better circuit because...
    It uses no power when the switch is open (same for both)
    A will use less power than B (~0.5mA with 3K3)
    The internal protection diodes are not sinking current when switch activated as in circuit B.

    Use a ratio of 1:2 for R1:R2 as this will give 3v3 when switch is active eg 5K and 10K (4K7 or 4K99 are standard values)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-08-17 15:32
    I agree that circuit A would be "safer" and better but I ended up using version B.

    As the frida's link explains, as long as the current across the clamping diodes is less than 500uA, the Prop should be safe.

    Circuit B was a lot easier to solder with my no PCB free form circuit. I'm using a cardboard box as an enclosure so this really isn't a professional installation. In this case circuit B made more sense, since the version B design provides less opportunity for my tangle of wires to short circuit.

    Thanks for the input everyone.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-08-17 16:15
    Both will work absolutely fine and the B circuit is more like what you would get when the Prop is being driven by 5V logic signals in which case we just use a current limit resistor, no different. Circuit B allows you to adjust R2 to give the button some wetting current so it is actually better for the button and does no harm to the Prop pin although there is absolutely no reason why the current limit resistor can't be a much higher value, even 1M will work plenty fine (and that's only 1.4ua!).

    So circuit B is better (coz it's wetter) where R2 = 4K7 and R1 = 1M (or 100K).

    @LA6WNA - If you run 5V through a resistor into an LED does that mean that you measure 5V across the LED? Of course not, neither does the Prop see 5V when current limited.
Sign In or Register to comment.