Shop OBEX P1 Docs P2 Docs Learn Events
RC network to extend High on a Pin — Parallax Forums

RC network to extend High on a Pin

In my program I have a loop going around checking inputs and doing stuff. In general this is ok, but there are a few momentary inputs that could be too short - e.g. a pushbutton. The idea (has probably already been invented but cannot find it) is to connect the input from the pushbutton though R to the input Pin, but having a, say 47uF capacitor to keep it high for a while, preferably until the input Pin has been read (and thereafter made an output=0 to discharge the capacitor).
Questions are:
1) How high is the input Pin impedance, i.e. how long can I expect the signal to be High?
2) How robust is the output circuit, i.e. is 47uF@3.3V too much energy to discharge?
3) Is this silly because there is a much simpler way to do it?

Erlend

Comments

  • Just have the button discharge a small cap of around 1uf ceramic with a pull-up of around 100k should give you a rough 50ms or so at VDD/2. The inputs are probably in the 100s of megaohms so no need to worry there and I wouldn't even bother trying to charge the cap back up either, just read a low and accept if the previous reading was a high.

    I prefer to have switches connect to ground rather than the supply as it is much safer (shorts/shielding etc) especially when you run off board.
  • With hundreds of megaohms on the inputs I should get away with a very small cap, and I need not worry about sinking the discharge energy. Thanks.
  • Make a circuit that has a small capacitor charged by a pin output through a resistor and have a normally open pushbutton that discharges the cap to ground when pressed. Set the pin to output to charge the capacitor and then set the pin to input. The button, when pressed, would discharge the capacitor and create a low on the pin until the cap is charged up again.

    Not sure how long the cap would retain a charge to keep the input pin high but that should be fairly easy to establish.
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2019-12-12 21:00
    I'd posted a couple of articles on this topic for the BASIC Stamp.
    http://www.emesystems.com/OLDSITE/OL2wind.htm#Interface_using_the_COUNT_command_
    http://emesystems.com/OLDSITE/OWL2rain.htm
    I think you work with weather instruments too, say, cup anemometers and rain gages, where the switch closure or pulse can be quite short and asynchronous. If reed switches (or mechanical pushbuttons) are involved, don't discharge a capacitor through the switch itself, which can arc and eventually weld or degrade the contacts. Also, as you noted, don't discharge a big capacitor into the µC pin. Use a a couple of hundred ohms between the capacitor and the pin to be safe. The capacitor also serves the purpose of debouncing the signal from mechanical relay or button contacts.

    With weather instruments, the pull-up R or a rain gage or anemometer needs to be strong, because, per Murphy, eventually the path to the instrument will get wet and will leak electrons like crazy, which is bad if you are storing the event on the dynamic memory of a capacitor. For the most part, reed relays are a thing of the past in anemometers, so the pulse may be clean but still short, via a solid state detector that is powered by the charge on a local capacitor.

    With the BASIC Stamp -p series, you also had the option to use the latched modes of the POLLed inputs. The equivalent on the Propeller is to use a cog counter to store the pulses that arrive at an input pin. Or simply dedicate a cog to pin monitoring and debouncing, so that a main cog can retrieve the relevant info at leisure.

Sign In or Register to comment.