0

I need a circuit that, whenever there is a voltage change on a control pin (from 5v to 0v or vice versa), simulates the press of a button (aka closing a circuit for a brief period of time and then opening it again).

Here is some diagram, hoping that it would make it look more clear:

This is what I have at the moment: enter image description here

And this is what I need to achieve: enter image description here

Luca Reccia
  • 101
  • 2
  • 1
    your top picture and bottom picture are mutually exclusive. In the top picture you either pass full 9V further or don't. In the bottom picture you talk about outputting 5V or 0V. So is it supposed to be 9V/0V output in "pseudobutton" or 5V/0V? Also, what is supposed to "trigger" your pseudobutton? What event should cause it to simulate "press"? – Ilya Jun 09 '22 at 10:29
  • Sorry for 9v volt 5v volt confusion, I just edited the image from a pic online, imagine the same voltage. The "top connection" is connected to other parts, and it is either 5v or 0v depending on other components during time. The "trigger" of the pseudobutton has to be the change of state (5v to 0v or 0v to 5v) of the top signal. I will try to update the picture now to make them more meaningful – Luca Reccia Jun 09 '22 at 10:34
  • Do you want to simulate physical button's function only (switch on/off) or do you also want to have button's bounce (noise/jitter/multiple voltage jumps during actual physical press that you need to filter out)? – Ilya Jun 09 '22 at 10:37
  • 1
    Couple of questions: do you need the LED to flash briefly when the signal rises from 0 to 5, and also to flash briefly when it falls from 5 to 0, or should there be one single flash for a complete cycle of rise+fall? Do you want to just flash the LED, or is there something else you plan to control with the system later on? – Simon Fitch Jun 09 '22 at 10:38
  • @Ilya I've updated the picture, I just need the brief on/off to make the LED flash. I don't need noise, jitter and other things. – Luca Reccia Jun 09 '22 at 10:41
  • @SimonFitch the first one, the led needs to briefly flash when the signal goes from 0v to 5v then stay off the entire time, eventually flash again when it goes from 5v to 0v and so on – Luca Reccia Jun 09 '22 at 10:42
  • 1
    @LucaReccia Andy AKA's answer below is a great suggestion; it does what you ask. Choose values for R1 and C1 so that their product is about the time you want the LED pulse to last. His suggestion of using a schmitt trigger device is strongly recommended, take his advice. – Simon Fitch Jun 09 '22 at 12:40

1 Answers1

2

the led needs to briefly flash when the signal goes from 0v to 5v then stay off the entire time, eventually flash again when it goes from 5v to 0v and so on – Luca Reccia

It sounds like you need an edge detector so that when your signal rises to 5 volts from 0 volts or, when it falls from 5 volts to 0 volts, a pulse is generated. This can be achieved with an exclusive-or gate and an RC delay like this: -

enter image description here

Image cropped from this answer.

You can make the width of the pulse as wide as necessary by making R and C a lot bigger. I would also use a Schmitt-input exclusive-or gate to avoid edge jitter and false triggers.

The output of the exclusive-or gate can drive a lower power LED in series with a suitable resistor to limit current.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
  • Great idea! And the output of the XOR feeds into N-MOSFET that controls the gate of P-MOSFET in the LED circuit (control 9V circuit with 5V input). I was also writing my solution rn, also with XOR, but I went a little crazy and put two schmitt trigger comparators with different hysteresis ranges on its input, now that I'm seeing this, it was clearly an overengineering. – Ilya Jun 09 '22 at 11:44
  • The output of the xor can feed a low power LED directly with a suitable series resistor @Ilya unless I'm mistaken. – Andy aka Jun 09 '22 at 12:23
  • I'm trying to test this ic in tinkercad, but it doesn't seem to work. Can u tell me if I implemented it wrong or if the backend emulation engine doesn't cover properly this situation? https://www.tinkercad.com/things/6dYaOtMhN0e-frantic-duup/editel?sharecode=xKIRmqch8g1tUhIYSj-hkhBGOPRLEqgPpDiA21toijY – Luca Reccia Jun 09 '22 at 16:26
  • 1
    Sorry but I don't use tinkercad. It's a tried and tested circuit (well-proven) by many folk so it's likely to be a tinkercad issue or you've drawn it incorrectly @LucaReccia – Andy aka Jun 09 '22 at 16:57
  • Ok I understand that, can u at least just check if I've drawn it as u meant it? The schematic is the exact same setup I'm using at home and I think I've made some mistake because it doesn't work. If u can't it's not a problem, thanks for all the help! – Luca Reccia Jun 09 '22 at 17:05
  • https://imgur.com/vzubABl.png – Luca Reccia Jun 09 '22 at 17:12
  • It looks like it should work but what values did you choose for R and C and why didn't you use a current limiting resistor in series with the LED? – Andy aka Jun 09 '22 at 17:15
  • Voltage output by battery=5V R=1kΩ C=56pF I didn't use any resistor in series with the led just because I tried with it, it still didn't work and I removed it in order to make to circuit look as a similar as possible to the one described above (idc if i burn the led, i'm just doing tests to understand) – Luca Reccia Jun 09 '22 at 17:25
  • You need values that are massively bigger for R and C such as 10 kohm and 10 uF. Together they produce a "CR" time of 100 ms and that will be the approximate length of time your LED will flash for. If you need longer make R = 100 kohm but, do use a current limit resistor in series with the LED @LucaReccia – Andy aka Jun 09 '22 at 17:36