# Electromagnet and MOSFETS

Hey, so currently I am trying to achieve a working electromagnet that will be powered by an AVR microcontroller and will be turned on and of when metal is sensed. Currently I have LED reflecting and sensing the block which passing through the photo diode and tells the AVR when to turn on the electromagnet. My problem is with the electromagnet. I have made my own and current I need to put 9V through it with 0.5Amps. Now I know I cna use a mosfet as a switch to turn it on and off however I am not sure how to work out the values for the resistors in the circuit. I will be using a similar circuit to the one shown on this page http://www.embeddedrelated.com/showarticle/77.php. However I am unsure how to develope the resistor values I would need to ensure my magnet works correctly. Any help?

davenn
Gold Member
Hey, so currently I am trying to achieve a working electromagnet that will be powered by an AVR microcontroller and will be turned on and of when metal is sensed. Currently I have LED reflecting and sensing the block which passing through the photo diode and tells the AVR when to turn on the electromagnet. My problem is with the electromagnet. I have made my own and current I need to put 9V through it with 0.5Amps. Now I know I cna use a mosfet as a switch to turn it on and off however I am not sure how to work out the values for the resistors in the circuit. I will be using a similar circuit to the one shown on this page http://www.embeddedrelated.com/showarticle/77.php. However I am unsure how to develope the resistor values I would need to ensure my magnet works correctly. Any help?

Hi Camzke
welcome to PF

the resistor values are not overly critical
he gave you a value range for R1 100 Ohm to 1k ... I would commonly use 1k on the output of micros or other driver ICs
if you found the MOSFET wasn't switching reliably, lower that value a but , say to 560 Ohms

R2 is just being used as a pull-down resistor. 4k7 or 10k are common values for that ( or something in between ... 5k6, 6k8, 8k2)

Dave

meBigGuy
Gold Member
First off you definitely need the freewheeling diode or else high voltage spike will destroy the system when you turn off.

You don't "really" need R1, and in fact it will slow down the turnon of Q1. But, as the article said, it does afford some protection and is good practice.
The time constant of the RC (R1*(Cgd+Cgs)) will determine the Q1 turnon time. The slower it is, the more power consumed in Q1 as it slews on, but the inductance of the coil will slow the current so that may not be an issue.

R1 can be as low as 270 ohms (3.3V/ 270 ohms = 12ma) or as high as you want to go.
R2 just needs to pull leakage to ground, so can be 4.7K to 10K or even more.

Another possibility is to use a mosfet driver or other high current buffer to isolate the FET from the uC.

Be sure your FET will turn on completely. Vgs-on specs can be pretty misleading. Best you post the FET you want to use.

EDIT: davenn posted while I was composing. Pretty similar answers. LOL

Baluncore
Be sure your FET will turn on completely. Vgs-on specs can be pretty misleading.
Camzke; Vgs-on is a most important parameter.
You need to take care that the Vcc supply and output voltage from the AVR, with the resistor network, will satisfy the Vgs-on of the MOSFET you select.

meBigGuy
Gold Member
The problem with many Vbs-on specs is that it is the voltage to get to 250uA, the cusp of turnon, so to speak. You need to determine the maximum voltage that is required to drive to 500ma. Mosfets are fine for 5V Vgs, there are fewer devices that work well at 3.3V Vgs.

I don't know what fets are popular.
This one looks reasonable http://www.mouser.com/ds/2/200/ [Broken]irlml2402gpbf-90059.pdf

https://www.fairchildsemi.com/datasheets/FD/FDN337N.pdf

http://www.vishay.com/docs/68645/si2302cds.pdf
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
WOW --- just found the infineon BTS smart switch series with built in gate drivers. No series resistor required.
There are selection guides
http://www.infineon.com/cms/en/prod...rue=Low-Side&statusValue=active and preferred

Here is a HUGE 3A TO220 part you can drive from an AVR
http://www.infineon.com/dgdl/Infineon-BTS117-DS-v01_04-en.pdf?fileId=db3a30433a747525013abff8302d549c&ack=t [Broken]

http://www.infineon.com/dgdl/Infine...fileId=db3a3043163797a6011667b19dc90e14&ack=t

Last edited by a moderator: