1
\$\begingroup\$

I'm having problems with my PCB board based on atmega328p microcontroller (very similar to an Arduino standalone board).

This is my current PCB schematics and Eagle board.

SCHEMATICS UPDATED!

enter image description here

I use connectors on VSX, VDX, MOT1A, MOT2A, MOT2A, MOT2B to switch ON and OFF solenoid valves (the valves are rated as 12VDC, 2A at max).

The board works randomly fine only for few seconds or minutes until the micontroller crashes or resets and I think this happens due to solenoids noise.

The main power is 12VDC, 35A (used for the valves and the relay) and then I use a 5VDC voltage regulator to power on the atmega328p.

As you can see, I already added flyback diodes across each mosfet, but may be this is not enough to prevent solenoid noise. I also twisted each couple of wires (maximum wire length is 90 cm) which connect the valves pins to VSX, VDX, MOT1A, MOT2A, MOT2A, MOT2B connectors and I added an additional diode in parallel on each valve pins.

How can I solve the problem? I was thinking to add 100nF ceramic caps between VCC and GND and AREF and GND and AVCC and GND as close as possible to the microcontroller pads and another 100nF cap in parallel on each valve pins. Do you think it can be enough to solve the problem?

Unfortunately, I think I can't separate the solenoid power source from the atmega328p power source since they are currently sharing the same GROUND.

What can I do to solve the problem by continuing using the same PCB board?

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm not exactly sure what the relay at the extreme right of the PCB is supposed to do, but if one pair of screw terminals is a mains input and the other pair is a relay-switched output it's not wired correctly. It will just short out the mains: Illustration. There is also a second issue with that relay; the clearance between the relay coil and the common terminal of the switch is unnecessarily small. If the relay is used to switch the mains, this could be dangerous. \$\endgroup\$ – jms Oct 5 '16 at 2:22
  • \$\begingroup\$ Thank you, jms for your support. The relay has no function on this board and I'm not using it. It is not even mounted on this layout. Its task was to short the two terminals to act like a switch, but I'm not using it. \$\endgroup\$ – Marcus Barnet Oct 5 '16 at 2:33
2
\$\begingroup\$

Cut that trace running up from pin 22 and jumper it directly back to the middle pin on the 7805 with a fly wire.

Add a 10uF X7R or X5R cap directly between pin 7 and 8.

Make the layout better next time or use a 4-layer board.

\$\endgroup\$
  • \$\begingroup\$ So, should I cut the GND traces (pins 22 and 8) from the atmega and directly connect them to the 7805 central pin (GND)? \$\endgroup\$ – Marcus Barnet Oct 5 '16 at 3:00
  • 1
    \$\begingroup\$ Yes, jumper from pin 8 directly back to GND on the 7805 \$\endgroup\$ – Spehro Pefhany Oct 5 '16 at 3:01
  • 3
    \$\begingroup\$ Current from the MOSFETs is flowing through the micro GND trace. The cut and jumper avoids the ground bouncing around. This may not be enough but it may help. Next step is to add series gate resistors of a few hundred ohms. \$\endgroup\$ – Spehro Pefhany Oct 5 '16 at 3:05
  • 1
    \$\begingroup\$ @MarcusBarnet The resistors you have added are parallel resistors, being between the gate and the drain. Don't get me wrong, they are a great addition (they ensure that the MOSFETs stay off when the AVR resets), but they won't help against voltage spikes caused by excessively fast switching. Their current values (220 ohms) are way too low trough, normally you want those parallel resistors to have a value of a few thousand ohms (e.g. 10 k), especially if you add the gate series resistors mentioned (series as in between the IO pins and the gates). \$\endgroup\$ – jms Oct 5 '16 at 3:24
  • 1
    \$\begingroup\$ Sorry guys, I did a mistake and I uploaded an old schematics. I edited my first topic and replaced it with the REAL schematics. As you can see, I'm using 220R series resistors. Do you think they are OK? \$\endgroup\$ – Marcus Barnet Oct 5 '16 at 3:31
0
\$\begingroup\$

It is very unlikely that something will help to fix this board layout. This PCB design has a very poor ground, so somewhere the ground bounces, and a glitch kills the processor. Why so many folks here are not using ground pour? Then the ground return path for relays must be separated from the ground for low-power control electronics. It should be designed in first. Then, a main capacitor is missing, on input 12V jack, which is the main power rail for all relays.

\$\endgroup\$
  • 1
    \$\begingroup\$ Hello Ali, thank you for your answer. This is my first time in PCB designing and so I did several errors. Is there any way to solve my problem? For example, where can I place the main capacitor? Across +12v and ground? \$\endgroup\$ – Marcus Barnet Oct 5 '16 at 1:58
  • \$\begingroup\$ 100nF As main capacitor should be enough? \$\endgroup\$ – Marcus Barnet Oct 5 '16 at 2:02
  • 1
    \$\begingroup\$ No. I would put a 100uF or 2,200uF or something. Maybe you will be able to drop thick blue wires to beef up the ground return from power electronics. \$\endgroup\$ – Ale..chenski Oct 5 '16 at 2:17
  • \$\begingroup\$ And why do you have heat sinks on FETs? The transitors should be operating in ON of OFF mode, and dissipate almost nothing. \$\endgroup\$ – Ale..chenski Oct 5 '16 at 2:23
  • 1
    \$\begingroup\$ A 100nF bypass at microcontroller is a must. 2A times 10 valves is still a lot \$\endgroup\$ – Ale..chenski Oct 5 '16 at 2:46

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.