Monday, November 16, 2009

Pulses on pushbutton

A friend was asking after a circuit for making pulses from a pushbutton on push and release. Two ways immediately suggest themselves- using a PIC and using a differentiator.

The PIC is easy for me, at least- I have a small stock of 12F683s which are 8-pin devices. Add a bypass cap and you're in business- you could even reprogram it to change the delay, debounce the input, etc. Of course, not everyone has a PIC programmer, and I feel like it's a pretty trivial app for a PIC, so I'll not talk much more about it.

The differentiator circuit is a little more involved.
Apologies for the crappiness of the image- LTSpice doesn't generate great output images, for one, and this was part of a larger image (it started NPN based, and generated negative going pulses; that's where Q3, Q4, etc etc went).

V3 is the switch- in the application, it should be a 100-ohm pull-up to 5V and a switch that yanks C2 to ground when it's closed.

R4 pulls up the base of Q3 and Q4, keeping them turned off and providing a 0V output normally. In steady-state non-pushed, C2 will have about 0V across it. When the switch closes, the base of Q3 and the emitter of Q4 get yanked down (since the voltage across the cap can't change instantly). Q3 turns on, and the load sees a pulse that goes up to 5V. C2 charges to 5V (since one end is at 0V and the other is tied to 5V through R4), and as it charges, Q3 slowly turns off. Q4 has, as yet, never turned on, since the base has never been at a lower potential than the emitter. When you release the button, the (not shown in the drawing) 100-ohm resistor which is a pullup to 5V yanks the bottom of the capacitor up by 5V. Since the cap is already charged to 5V, the voltage across the capacitor is now 10V, which shoves the base of Q3 above the 5V rail by about 5V (turning it off even harder, for what it's worth)(which is not much) and, here's the magic part, shoves the emitter of Q4 5V above the 5V rail. Now, there's a 5V difference between the base and emitter, the transistor is biased, and it turns on, which again yanks the load up towards 5V. Again, C2 will discharge, and Q4 turns off as it does. The diode provides a clamp to the 5V rail, limiting the voltage on the output. It tends to pop up to 8V or so, although only briefly, so it may not be an issue.

This circuit is a real hack job- I know I could kill that >5V excursion if I spend a little more time on it. It's simple, though, and I like it.

The LTSpice file is available here.

EDIT: Adding a 270-ohm resistor between the base of Q3 and the emitter of Q4 keeps the excursion to a very reasonable .2V above 5V.

1 comment:

  1. Thanks for this, I'm still trying to grok it all. My one concern is that there are limitations on how the switch needs to work that are not compatible with the rest of my circuit. The switches (one for each key on a keyboard) have the double duty of choosing a pitch resistance and triggering the sample. Anyway I'll have to study and think about it some more.

    ReplyDelete