I have a circuit which reads push-button presses. If it is pressed, it turns on the door by rotating motor. In this system, safety and stability are keys.

I added r/c filter to debounce button and cables are also shielded. Pull-up resistors also exist but there is a problem which is voltage spike.

Let me explain with some examples, when i run a drill next to cables, it reads randomly button presses or when i shake circuit roughly, it randomly reads button presses. It happens rarely but the system should be stable and does correctly for a long time such as months, years, so these random presses are not acceptable.

To solve this, I added a relay and connected it to power with a push button. When push button pressed current flows to relay and switch it. I read button presses from relay. It works stable. But I am not sure that i am doing right or whether there is a better way to prevent those spikes.

If there are any other viable solutions to this problem, i would like to appreciate to hear.

(Push button wires are about ~50cm)

Kicad project files Kicad Project Files

Circuit http://ozmach.com/public/board-v2.zip 1: http://ozmach.com/img/schematic.pngenter image description here

  • \$\begingroup\$ You forgot to add a schematic of your circuit. You can use the CircuitLab button on the editor toolbar. \$\endgroup\$ – Transistor Apr 2 '18 at 8:05
  • \$\begingroup\$ I dont use circuitlab but i added as a png \$\endgroup\$ – arnes Apr 2 '18 at 8:19
  • 1
    \$\begingroup\$ U4 is a relay with no flyback diode? \$\endgroup\$ – winny Apr 2 '18 at 8:29
  • 2
    \$\begingroup\$ When you get this problem sorted out it would be worth your while studying Rules and guidelines for drawing good schematics. You have pull-up resistors draw pulling downwards to a +5, the switch circuits all reading right to left and hardly any wires between devices so circuits can't be traced. \$\endgroup\$ – Transistor Apr 2 '18 at 8:36
  • 1
    \$\begingroup\$ Do you mean oscilloscope? Show layout, because it sounds like interference. \$\endgroup\$ – winny Apr 2 '18 at 9:04

Your idea with the relays is good, but it is just a workaround for the real problem. Your DC/DC converter is a major source for noise if the layout is not done carefully and I guess it might be the reason for the spikes. Try to use a simple linear regulator or other (clean) DC source. If that helps, then you can concentrate on improving your DC/DC converter.

  • \$\begingroup\$ I agree, relay seems to me as an ad-hoc solution too. I used 7805 firstly, but i realized that it is getting heated, not too much, even so i changed with lm2575 \$\endgroup\$ – arnes Apr 3 '18 at 9:18
  • \$\begingroup\$ @ArnesTwin To rule out problems caused by switching power supply, replace it again with a 7805 or other linear regulator and test it again. Does it react to spikes even when powered trough a linear regulator? If your problem is the heat, try using an LDO regulator and a bigger heatsink. \$\endgroup\$ – Lorenzo Donati supports Monica Apr 4 '18 at 8:22
  • \$\begingroup\$ I shared project files, you can look at the manufactured board which is mentioned in the question. Heat was about 50-60 celcius and power supply is 220 to 12V 8.5A \$\endgroup\$ – arnes Apr 4 '18 at 8:26
  • \$\begingroup\$ BTW, you say you are using an LM2575: did you design the power supply circuit around that chip yourself or did you use an already-made module? As Stefan said, building an SMPS around a switcher chip (even a tolerant one like the 2575) is much more difficult than putting together a PS around a 7805 or an LM317 chip. A wrong layout could literally kill your project (the chip could oscillate wildly). One of the most common mistake is not to create proper star grounding. Usually the datasheet mention this, but many newbies (if you are one) skim on that. \$\endgroup\$ – Lorenzo Donati supports Monica Apr 4 '18 at 8:26
  • \$\begingroup\$ i used already made module, it is something like this link . LM2575 will exist in new design. 7805 is used in the board which i mentioned. In new design, i created ground zones on bottom and front layers. I am just trying to understand why that happened or happens. \$\endgroup\$ – arnes Apr 4 '18 at 8:54

Although determining and eliminating the true cause of the interference (because that's what probably is, since it happens rarely, as you say) should be better for an high reliability system, it could be useful to add also some "strong" software debouncing routine.

If those "spikes" are short in duration, say less than 5-10ms, then design the button-reading routine so that it acknowledges a button-press only if it lasts at least, say, 100ms (if those buttons are meant to be pressed by humans, requiring a 100ms press is not going to degrade the "user interface" perceived responsiveness).

In this way you could get rid of the relays, which are bulky, costly and power-hungry (assuming you need a low-power design).

  • \$\begingroup\$ Actually, button has 500 ms debouncing time(so long to debounce). The problem is not about debouncing according to me. Let me give another example, i mounted card to the system, builded everything for production. It worked as stable. We closed the lamps in room. Button is just triggered :). I dont why but it is so sensitive to electrical changes. I surpassed this problem with electrical relay. I suppose relay solves problem like this. With electrical changes, electrical changes occurs again but this time magnitude of that electricity can't open the relay. So unstable conditions didn't occur. \$\endgroup\$ – arnes Apr 3 '18 at 9:13
  • \$\begingroup\$ @ArnesTwin Do you mean it already has 500ms of software debouncing? \$\endgroup\$ – Lorenzo Donati supports Monica Apr 3 '18 at 9:59
  • \$\begingroup\$ yes there is 500ms debouncing time in software \$\endgroup\$ – arnes Apr 4 '18 at 8:08

Try adding, at every input pin, one resistor (1k to 4.7k) in serie with the pin, and between the pin and ground: one resistor (100K to 720K), a 0.1 or 0.22 uF capacitor between the pin and ground, a zener diode (same voltage as signal voltage, anode to ground). You can also add a varistor (same voltage as signal voltage) between the line and ground. Then the varistor should be to the first component on the line from the switch or other bulky mechanism, while other components are closer to the pin, with one additional 1k serie resistor between the varistor and the zener cathode. This way, the varistor will protect the zener and the other circuit beyond.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.