So I´ve designed a PCB for a Pre-/Discharge Circuit for a 400V DC system which is controlled by a STM32 microcontroller. When powered the program waits for 1s and then starts by switching the (precharge) relay on the PCB and one of the accumulator insulation relays (AIR) to allow current to flow thru a 1k resistor into the capacitors of the system. After a calculated time the second AIR closes and completes a circuit without the resistor.

When testing the circuit with no connected load everything works just fine but with the accumulator on one side and the load on the other the microcontroller apparently gets stuck in some kind of loop of switching the first relay, then resetting and the relay gets released, and so on.

Below is the basic schematic of how the power supply is handled and the circuit used to switch all relays.

How can I stop the relays from chattering? What is causing this in my circuit?

circuit overview enter image description here


enter image description here

  • 1
    \$\begingroup\$ How much separation do you have between the 400V lines and the rest of the circuitry, and are those grounds completely separate? \$\endgroup\$
    – Trevor_G
    Commented May 31, 2017 at 14:58
  • \$\begingroup\$ If you mean the HV traces connecting the precharge relay to the connectors on the PCB they are >= 15mm apart from other traces.The grounds are separate and monitored by a insulation measurement device. \$\endgroup\$
    – Max
    Commented May 31, 2017 at 15:18
  • 1
    \$\begingroup\$ I'm assuming the 400V switch is coupling back somehow.. You would have to scope it out to see. \$\endgroup\$
    – Trevor_G
    Commented May 31, 2017 at 15:23
  • 1
    \$\begingroup\$ Show layout. Show ground planes. \$\endgroup\$
    – winny
    Commented May 31, 2017 at 16:43
  • 1
    \$\begingroup\$ Missing ground plane! But if you listen to Tony and it's possible to slow down the flank significantly, you may still make it. \$\endgroup\$
    – winny
    Commented May 31, 2017 at 21:12

2 Answers 2


I would suggest that when the relay closes/opens and makes/breaks the 400 VDC, it may be generating an EM wave that crashes or stops dead your MCU.

I would look into this possibility.

You can try adding snubbers across your relay contacts. These are traditionally an RC network that absorbs the energy that would otherwise arc across the contacts. There may be other, more modern contact suppressors you can try.

It may not be the same reason but for the record...

I had a major problem with a design many years back, where a mechanical relay was switching the mains going to an AC motor. When the relay opened, our microprocessor (MPU) froze completely. There was no bus activity and only cycling the power let the MPU recover. This was a repeatable fault and occurred on six test machines. It took me two days of hunting to find the cause. It was when I tried it with the lights off that I noticed the spark across the relay contacts. The relay actually started switching when the mains had fallen around 80 Vac, not at the full 340-ish V peak of the 240 V mains.

Note that the microprocessor PCB was on one side of an excellently earthed, large (maybe 800 x 600 mm) 4 mm-thick steel plate. The relay was on the other side of the plate, about a foot lower and amongst more earthed steel. All that earthed metal didn't stop the problem.

We needed the complete disconnection of a mechanical relay for other reasons so I designed a board to put an SSR in series with the relay, and therefore with the mains to the motor. The board controlled the timing sequence of the relays (ON was: relay on, wait 10 ms contact travel, SSR on; OFF was: SSR off, 20 ms for mains to cross next 1/2 cycle with margin, relay off). This solved it and we made at least 20,000 units of that machine with no more problems.

Months later, we saw another freeze on the microprocessor when an insulated metal part picked up a large static charge then later touched the earthed steel metalwork. The sparking/touching and discharge into earth knocked the microprocessor over every time. By then, we were on the lookout for it, and earthed the metal part, stopping it charging and fixing the problem. We used a static discharge gun to prove it all, removing and reattaching our earthing strip fix and watching the problem come back and go away.

  • \$\begingroup\$ Can you explain how contact arcing cause MPU to freez?. \$\endgroup\$
    – M lab
    Commented Jun 7, 2023 at 10:51
  • 1
    \$\begingroup\$ @Mlab, I can't explain it, no. There's not sufficient information available on the MPU. But I can sure that the empirical evidence was conclusive. We did an awful lot of testing on that and it failed reliably and worked reliably as the discharging was allowed and removed. We also ruled out conducted effects through lab measurements. \$\endgroup\$
    – TonyM
    Commented Jun 7, 2023 at 12:11

a lot of information is missing but here are some things to consider:

  1. place micro controller decoupling capacitors near the supply pins
  2. add stronger pull up on reset pin
  3. add capacitor to reset pin
  4. add ground plane near sensitive areas
  5. widen the tracks and try to decrees loops on the high voltage side

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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