# Controlling a relay with a MCU output pin and trying to drive a solenoid using the same power source

I've used a known circuit design to successfully (wait for it!) control a 12V relay using a 3.3V MCU pin, from the pictures you can check that I am using the same 12V power source for both (relay and MCU) but the MCU is being supplied by the output from a L78L voltage regulator that converts 12 to 3.3V. The problem appears when I use this relay to drive a solenoid (1A current and using the same 12V power source for it), after the NO switch is closed all current goes to the solenoid and none is reaching my MCU (consequently turning it off), only after 1 second the current flow is established again in the MCU and it is reset.

My question: Is there any other way apart from inserting big capacitors (>100uF) on the L78L output to try to keep my MCU powered on when the relay is active (thus making a 1A current flows to the solenoid) ?

EDIT: The issue here is that both my circuit (MCU+Relay driver) and the solenoid are connected in the same power source (12V) and the solenoid is draining all the power source current for about 1 sec. Summary:

12V -> Solenoid and circuit

12V_Protect -> Relay Driver and L78L

TP_3.3 -> MCU

If I use a different power source for the solenoid the circuit works fine.

You shouldn't be driving your relay from 12V_Protect, but directly from a voltage source that doesn't have the direct possibility to "leech current" from C16.

Approach:

    Schottky
12V -->|------+------->|--- >to C16
D0       |       D1
12V_Protect


A sufficiently sized Schottky diode will have lower voltage drop even when the relay draws a lot of current. D1 isn't strictly necessary afterwards, but would mitigate the "my relay draws so much current that my stabilizing capacitor gets discharged" problem.

Then: measure 12V_Protect across the coil when you directly connect the coil between 12V_Protect and ground.

If it's much smaller than the nominal voltage of your power supply: your supply is too weak and can't supply enough current. Get a better 12V supply, or a relay that needs less current.

• I would have to disagree. D1 looks like it is there to act as reverse polarity protection. By driving the relay coil from 12V and not 12V_Protect, you're negating the reverse polarity protection and when the mistake is made of applying reverse polarity... Q1 is going to get blown. – CalMachine Apr 28 '20 at 15:45
• then, add another diode between the supply of the relay and C16. – Marcus Müller Apr 28 '20 at 16:05
• @CalMachine is that better? – Marcus Müller Apr 28 '20 at 17:30
• The issue itself is not with the relay or the driver circuit, but with the current drained by the solenoid that is connect in the relay contacts (NO or COMMON). I will edit the question to make this more clear. As per the response @CalMachine is correct, the 12V_Protect is mandatory to avoid reverse polarity. – Godofredo Onofre Apr 28 '20 at 20:53
• yeah, OK, same thing: measure your 12V supply voltage when you connect your load. If that drops, than your power source is too weak. – Marcus Müller Apr 29 '20 at 7:16

Just getting back here in case anyone is interested. I just added a RC snubber with a freewhell diode in the relay contacts and it worked just fine.