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?