Shop OBEX P1 Docs P2 Docs Learn Events
External switch to Prop — Parallax Forums

External switch to Prop

DavidMDavidM Posts: 630
edited 2008-11-27 02:26 in Propeller 1
HI,

I have an external switch about 2 - 5 metres away from my prop device.

I wish to read the switch as an input to a prop pin.

Q1) Will the following circuit do this?
I am using a resister divider to minimise the current ( I calculate about 3.2 volts when the switch is pressed)
I am supplying 5v to the switch.

I will use some kind of timing to detect a "PROPER" switch press ( i.e say >100ms) I am not concerned with de-bouncing. just need to know if this circuit will provided enough "VOLTAGE" to the prop input pin.

Thanks

Dave M

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-25 02:10
    Your circuit should work. The 1K resistor will limit the input current to something the input stage clamp diode can handle and the resistor to ground will provide a default logic zero state. You could increase the value of the 1K resistor to maybe 4.7K or 10K to reduce the current through the clamp diode, but 1K will certainly work.· A typical value for the resistor to ground would be 100K.· Don't worry about the voltage divider effect.· Once the clamp diode conducts (at around 3.9V), that predominates.

    Post Edited (Mike Green) : 11/25/2008 2:16:31 AM GMT
  • DavidMDavidM Posts: 630
    edited 2008-11-25 02:24
    HI Mike,

    Thanks for responding.

    According to my calculations this should make about 0.0018 AMPS ( 1.8ma ) through the circuit when the switch is closed.

    I used this calculator here

    http://ourworld.compuserve.com/homepages/Bill_Bowden/r2.htm

    I used..

    VOLTAGE = 5
    R1 = 1000
    R2= 1800
    VOUT = 3.2143
    AMPS = 0.0018

    Q1) what is the maximum current the inputs for the prop can handle?


    Thanks

    Dave M
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-25 03:59
    I think it's around 20mA, but that's an absolute maximum sort of value. 2mA is very reasonable.
  • DavidMDavidM Posts: 630
    edited 2008-11-25 04:49
    Thanks Mike.


    Dave M
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-11-25 18:06
    According to the data sheet (see exerpt), you should not drive more than 500 microamps through the protection diodes.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
    900 x 436 - 137K
  • DavidMDavidM Posts: 630
    edited 2008-11-26 06:19
    Hi Ken,

    Would these resistor values be SAFER?

    VIN = 5V
    R1 = 5K1 1%
    R2 = 10K 1%
    VOUT = 3.3V
    AMPS = ABOUT 1ma ( i think? )

    regards

    Dave M
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-26 06:38
    Remember, you don't really have a voltage divider here because the substrate diode is conducting. The voltage drop across R1 with the switch closed is 5V - 3.3V - 0.6V (for the substrate diode) = 1.1V. Anything greater than 2.2K will limit the current to 500uA or less. R2 just has to hold the I/O pin low when the switch is open and the I/O pin is a high impedance. 100K would be fine and wouldn't significantly affect the voltage at the I/O pin when the switch is closed.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-11-26 13:23
    Is it well known what the failure mode is as a result of too much current in the protection diodes?· Is it related to PLL failures which seem to be common?· I imagine there are a lot of propellers out there with more than 500uA going through that protection diode.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-26 15:41
    The current through the protection diodes has to go somewhere and it goes into the power supply network on the chip (to Vdd or Vss). If there's a lot of current, the resistance in the power supply interconnections will cause regional voltage differences. If there are external ground loops as well, it's easy to get transient voltages in parts of the chip that exceed the maximum allowable voltage and cause gate oxide damage. The PLL seems to be the most vulnerable structure for whatever reason.

    The short answer for your question is "not really". Current through protection diodes may be a contributing factor in the PLL failures, but not a cause. In other words, if you have a situation close to failure (of the PLL) and add injected currents through the protection diodes, you may push the chip into failure. If you use the diodes for clamping of signals and limit the current to approximately the range specified (and particularly limit the total current for all I/O pins' diodes to avoid shifting the supply voltage), that will not by itself cause problems.

    Post Edited (Mike Green) : 11/26/2008 3:48:07 PM GMT
  • jazzedjazzed Posts: 11,803
    edited 2008-11-26 16:43
    Ken Peterson said...
    Is it well known what the failure mode is as a result of too much current in the protection diodes? ...
    My experience with switches shorter term for shorter connection lengths (and by accident) is that the logic voltage gets misinterpreted especially after prolonged exposure to the "intolerable" current. Series 2.2K resistors (as Mike mentioned) do seem to eliminate the problem. My switches are much like the .pdf minus the pull-down and with cable about 8".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • DavidMDavidM Posts: 630
    edited 2008-11-27 00:40
    Hi,

    To JAZZED - you are saying you don't need a PULL-DOWN resistor ?? Why, Won't the input pin just float?

    If the maximum CURRENT AN INPUT pin on the prop is only 0.0005 AMPS ( 1/2 milliamp, or 500uA ) then according to my calculations I will use the following resister values.

    VIN = 5V
    R1 = 5K1
    R2 = 10K 1
    VOUT = 3.3V

    To MIKE, if I keep the voltage under 3.3v ( by using my suggested resistors above) then why would the diode come into effect??
    I also CANNOT see how this is not a voltage divider? if this simple circuit is not a voltage devider then what is?


    Regards

    Dave M
  • DavidMDavidM Posts: 630
    edited 2008-11-27 02:26
    OK,

    I just did a breadboard with this circuit

    using 2 X 10K resistors works well

    ACTUAL VALUES ( using a multimeter )

    VIN = 4.97
    R1 = 9960 OHMS ( actual value of 10K resistor )
    R2 = 9960R OHMS
    VOUT = 2.48V

    the current is about 0.0002 AMPS

    I understand that the prop need at least 1/2 of VDD to register a high which is 1.65V

    regards

    Dave M
Sign In or Register to comment.