0
\$\begingroup\$

This question already has an answer here:

I'm driving 4 coil relays with an MCU through BJTs. As I activate one by one, sometimes the third won't even turn on, and if it does, it nor anyone will turn off, as if the MCU freezed. I'm totally sure this is because of noise since Relays are 5V, the MCU is 5V and of course, the power supply is only one, and to worsen the case, it's an SMPS taken from a cellphone charger. I've improved the board by adding a 470uF decoupling capacitor very close to the MCU (ATMEGA328P), and it did indeed enhance the functionality of the MCU. Without the capacitor, it would barely turn on just one relay. Since the relays are 4, it's undoubtably the coil inductance giving the power rails a LOT of turbulence. As I've read around the Internet, the only way out of this is to use two different power supplies (and optionally an optotransistor for better isolation). One for the MCU and logical parts, and other for the relays. If you could give me a simpler solution, it'd be great, but otherwise I'd like to know if using a 12V transformer and two 7805 for each appliance is enough, or do I have to make two rectification stages or even to use two different transformers.

P.S. I've also googled on the use of Solid State Relays, but they don't seem to be very cost-efficient for this, and I don't even know if I'm going to find them available here in my country.

EDIT

The schematic is this. The 470uF cap and 10k pullup resistor in RESET pin are not present here, but I added them to the board.

Schematic

\$\endgroup\$

marked as duplicate by SamGibson, laptop2d, winny, akohlsmith, Bruce Abbott Nov 2 '17 at 18:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ 2 different supplies won't necessarily solve your problem. There are plenty of boards with relays that don't use 2 transformers so that's clearly not necessary. Schematics and photos of your setup will be better than text for people to understand what you built. \$\endgroup\$ – Wesley Lee Oct 11 '17 at 7:15
  • 1
    \$\begingroup\$ Have you connected a flyback diode across relay terminals? \$\endgroup\$ – GPS Oct 11 '17 at 11:42
  • \$\begingroup\$ @WesleyLee I know, but I'm pretty sure that those boards are powered from a transformer PSU which is a lot better than my SMPS. I'll add more detail too, thanks \$\endgroup\$ – Joaquin Guevara Oct 11 '17 at 17:36
  • \$\begingroup\$ @GPS Sure, I'll add the schematic right away. \$\endgroup\$ – Joaquin Guevara Oct 11 '17 at 17:37
  • 2
    \$\begingroup\$ This is effectively a duplicate of your question from almost 2 weeks ago: "ATMEGA328P standalone sketch doesn't work as expected" - same schematic; same "MCU hangs" problem (although there are missing & ambiguous details in both questions). Repeating the question just duplicates the effort of readers :-( Also you didn't implement all the corrections for mistakes in the schematic, which were suggested in that previous question, so there's no point in giving the same advice again, if it just gets ignored, is there? :-( \$\endgroup\$ – SamGibson Oct 11 '17 at 18:27
0
\$\begingroup\$

It could be that your transformer is not capable of supplying the current needed to turn all of the relays on. When you try to turn them on, the voltage probably drops enough for the MCU to Brown-out.

You need to look at how much current the transformer is able to supply. Also find out how much current your circuit needs to to turn all the relays on.

You could also monitor the MCU supply voltage while turning the relays on and see if the voltage drops.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your help! Remember it's a transformerless supply, it's a little SMPS board taken from a cheap cellphone charger. The cellphone charger case says it's supposed to deliver 5V x 2 Amps, but even if that's not true (which is probably the case) two relays ON mean just 80mA, so it's still very little. The voltage drops might be the problem, I'll try to probe the MCU supply voltage although if the drop is too fast, I don't think the multimeter will pick it up. I also added the schematic to the question. \$\endgroup\$ – Joaquin Guevara Oct 11 '17 at 17:42
  • \$\begingroup\$ @JoaquinGuevara You didn’t give any of the important current specifications in your question. \$\endgroup\$ – HandyHowie Oct 11 '17 at 20:08

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