Electronic – arduino – Controlling an electromagnet strengh with arduino

arduinocoilelectromagnetisminductance

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

Best Answer

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.