Driving a small coil directly with a microcontroller pin atmega or stm32 - Page 1
Forum section: electronics / projects

author: ale500
author_rank: Frequent Contributor
timestamp: April 14, 2020, 07:58:03 am
content: I would like to drive a small coil (magnetic actuator), small in size, current say ca. 10 mA with the pin of a microcontroller. I would like to keep part count to a minimum, say microcontroller and coil(s), and batteryDo I need extra diodes ?Any thoughts ?

author: Circlotron
author_rank: Super Contributor
timestamp: April 14, 2020, 08:04:48 am
content: Some older CMOS logic had a parasitic SCR in the totem pole output stage that could be triggered if the output pin was pulled outside the supply rails. The SCR would switch on and short the supply rails and perhaps destroy the device. When turning off your inductive load it might do the same thing to your micro. Others may care to comment on this possibility.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 14, 2020, 11:57:08 am
content: CMOS latchup these days is usually >100mA, and you'll be hard pressed to draw more than 10mA from a coil that idles at 10mA. But YMMV. A lot of MCUs don't spec it.Could even wire it between two pins (H-bridge drive), to speed turn-off. You'll have to know the inductance though.Schottky clamp diodes won't hurt; a BAT54S per pin will certainly do.If you need the assurance of a proper spec'd logic family, 74HC3G14 or the like would be a good idea; wire all three sections in parallel to get extra-strong drive. (Or use a 2G or 1G part and only as many as you need. One should be enough, after all, but you can also overkill if you like.) The output transistors will handle that current with very little voltage drop indeed, and the CMOS latchup rating is given either in the datasheet or the logic family sheet.Tim

author: ahbushnell
author_rank: Frequent Contributor
timestamp: April 14, 2020, 05:42:16 pm
content: What is the inrush current on the coil. It takes more current to pull in the contact compared to the DC current. I would put a diode across the coil. Use an open collector transistor to buffer. 10 kohm gate resistor. 2n3904 transistor. and use a diode on the coil would be the safest way.

author: rvalente
author_rank: Frequent Contributor
timestamp: April 14, 2020, 05:49:52 pm
content: Yes, can do...Some analog gauges based on small stepper motors uses just the uC IO + some diodes

author: Ian.M
author_rank: Super Contributor
timestamp: April 14, 2020, 06:39:39 pm
content: It can be done, so long as there is no chance of the I/O going tri-state while the coil is still carrying current, and the I/O is *NOT* open drain. Lets assume a coil fed from Vcc, with the other end driven by the I/O pin. Take the I/O pin low to power the coil. When it is taken high to switch the coil off, the I/O's internal upper MOSFET shorts the coil, so the back-EMF from the coil as its current decays doesn't take the I/O pin significantly above the Vcc rail. However if something resets the MCU while the coil is powered, the I/O will tri-state and the coil current has nowhere to go as it decays except through the I/O's upper ESD protection diode, which risks latchup if the abs. max. protection diode current is exceeded, and if not, may still cause abnormal operation until the current has decayed to zero with a small probability the MCU may have to be power-cycled to recover.You need to be 100% certain the MCU has enough drive capability considering component tolerances and temperature extremes, otherwise it gets *FUGLY* as BobAGI found out with the commercial product design he inherited:https://www.microchip.com/forums/m788787.aspx

author: excitedbox
author_rank: Regular Contributor
timestamp: April 15, 2020, 02:41:23 am
content: I think the esp32 can drive 50ma from an output pin so that should be able to power your coil. To prevent damaging anything I would suggest a diode since it will be cheaper than the mosfet. Depending on where you put the diode depends on how quickly your actuator shuts off though so keep that in mind.Here is a nice little discussion where someone even posted a simulation.https://electronics.stackexchange.com/questions/455375/can-the-inductive-kick-be-discharged-without-a-freewheeling-diode-in-this-examp

author: ale500
author_rank: Frequent Contributor
timestamp: April 15, 2020, 06:15:01 am
content: As I see there are several possibilities, and the protection diodes shouldn't be discarded.I'll order some thin wire and wind some coils and test. Let's see.Many many thanks !

author: Miyuki
author_rank: Frequent Contributor
timestamp: April 15, 2020, 09:02:34 am
content: Atmel/Microchip AVRs have 100mA pins with reasonable robust protectionMost 32bit chips uses much more delicate technology and have lover current and are more sensitive to transients as it uses low voltage