Author Topic: Driving a small coil directly with a microcontroller pin atmega or stm32  (Read 1308 times)

0 Members and 1 Guest are viewing this topic.

Offline ale500Topic starter

  • Frequent Contributor
  • **
  • Posts: 415
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 battery :) Do I need extra diodes ?
Any thoughts ?
 

Online Circlotron

  • Super Contributor
  • ***
  • Posts: 3364
  • Country: au
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.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
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. :P )  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
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Online ahbushnell

  • Frequent Contributor
  • **
  • Posts: 751
  • Country: us
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. 
 

Offline rvalente

  • Frequent Contributor
  • **
  • Posts: 736
  • Country: br
Yes, can do...

Some analog gauges based on small stepper motors uses just the uC IO + some diodes
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
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
« Last Edit: April 14, 2020, 06:42:16 pm by Ian.M »
 
The following users thanked this post: thm_w

Offline excitedbox

  • Regular Contributor
  • *
  • Posts: 104
  • Country: de
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
 

Offline ale500Topic starter

  • Frequent Contributor
  • **
  • Posts: 415
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 !
 

Offline Miyuki

  • Frequent Contributor
  • **
  • Posts: 908
  • Country: cz
    • Me on youtube
Atmel/Microchip AVRs have 100mA pins with reasonable robust protection
Most 32bit chips uses much more delicate technology and have lover current and are more sensitive to transients as it uses low voltage
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf