11
\$\begingroup\$

This previous question Controlling an electromagnet with Arduino deals with binary control (ON or OFF) only. On my side I need to choose the strength of the magnetic field.

It is a home made electromagnet, I managed to power it with 12V DC + a 5ohm resistor which gives around 2Amps. The resulting magnetic field is big enough. The resistor gets hot, but this is bearable.

Now I want to modulate the intensity between 0 and 2 amps from some sensor reading, so I'm planning to use an Arduino.

Can I use PWM knowing that the inductive load is significant? Is the frequency choice of the PWM critical? Will I have trouble with Eddy currents in the soft core? (I can't use laminated core).

So my question is : is PWM a good choice really? If yes, should I keep the 5ohm resistor? How can I calibrate my PWM frequency + alpha? If no, what could I do instead? Which circuit?

Thanks

\$\endgroup\$
  • \$\begingroup\$ PWM is routinely used for continuous intensity control of electromagnet loads, so yes it will work. Your concerns will be the mechanism you use to switch the high current needed for the electromagnet (many questions on this site address that), inductive flyback (use a diode in reverse bias across the coil), and (maybe) ensuring your PWM frequency is not a harmonic of whatever natural resonance frequency your coil happens to have. \$\endgroup\$ – Anindo Ghosh Apr 27 '13 at 18:25
  • \$\begingroup\$ DC motors are also inductors. Maybe a motor shield would be a convenient solution? \$\endgroup\$ – Phil Frost Apr 27 '13 at 18:38
  • \$\begingroup\$ If you have an oscilloscope, you can easily see if the inductor saturates. If it does, you should consider a higher PWM frequency. If the frequency gets high enough, the current through the inductor will only reach its maximum/minimum at 100/0 percent duty cycle. \$\endgroup\$ – jippie Apr 28 '13 at 8:44
  • \$\begingroup\$ @jippie : this what I don't understand. If this is > 50% then, during each cycle, the 'going up' time is longer than 'going down time' so the current finishes a little bit higher than where it started. So why does it not saturate after many cycle? (I observed it doesn't, but I can figure out why) \$\endgroup\$ – repied2 Apr 29 '13 at 14:02
6
\$\begingroup\$

PWM is a good choice and remember that the coil needs a reverse connected diode across it to prevent back-emf's from the open-circuited inductor damaging stuff. You will also need to use a power transistor of some type to interface between the arduino and the coil - the arduino doesn't provide enough "drive" to get anywhere near 2A. Here's a diagram that shows a transistor from an MCU but it has a motor instead of a coil. This doesn't matter - the important thing is that it shows the diode and a method of driving the coil: -

enter image description here

It also shows +5V but this can be +12V. Things to watch out for: -

1) The diode needs to be rated at a current that exceeds the maximum current through the coil.

2) The coil still needs the resistor in series in case of short circuits but, it maybe reduced to something like 1 ohm when you are happier with operations.

3) The transistor has to be rated to switch the current so probably choose one that can easily handle at least 3A.

4) Voltage rating on the transistor need only be 20V or higher

5) Resistor in series with base may need to be 100 ohm - try this to begin with. From a 3V3 IO line 100 ohm will mean a base current of about 30mA and if the HFE of the transistor is good when switching power loads (100+) it should be OK however, it may be better to use a FET for this and there are plenty to choose from.

Next try putting out a 50:50 mark-space pulse (a square wave) and changing the frequency and see what the core losses are like with progressively higher frequencies. I would have thought 1kHz is a good starting point and you may be satisfied with 10kHz hopefully.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your complete answer. I got it working with the default arduino 500Hz PWM and a MOSFET IRF520 (gets hot so I'll try a better one) + flyback diode + optocoupler. But I still don't figure out why the current doesn't build up progressively (after many cycles) when the PWM ratio is > 50% since during each cycle, the 'going up' time is longer than 'going down time' and the current should finish a little bit higher than where it started! \$\endgroup\$ – repied2 Apr 29 '13 at 14:12
  • \$\begingroup\$ ok, I think I figured it out thanks to some simulations circuitlab.com/circuit/73nx5a/ferropwm. \$\endgroup\$ – repied2 Apr 29 '13 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.