# Can I PWM this electromagnet at audio frequencies?

The pictured electromagnet will be PWM'd at 12V / ~100-500Hz.

The goal of PWM-ing the electromagnet is to vibrate a metal bar in close proximity, whose fundamental frequency is the same as the PWM frequency.

This all looks OK in the simulator, but based on other questions and my limited knowledge it

• Might not be possible due to the inductive load of the electromagnet
• Might require a flyback diode
• Might benefit from an H-bridge to reverse the electromagnet's polarity and double the amount that it "pushes" on the metal bar. (Edit: In this case I'd attach a permanent magnet to the bar as well, so that reversing the electromagnet pushes instead of pulls. Forgot to mention this initially)

The primary question is: How do I tell if this PWM'ing strategy will work? Hook it up and see if it gets hot? Can I measure the inductance in advance to figure it out via math™?

(I can split this up if mods prefer, but the basic level of what I'm asking makes me think that it might be best as-is.)

• When you use the CircuitLab button on the editor toolbar the editable schematic is added inline to your post. This makes it easy for you to update and us to copy and paste into our answers for editing. There is no need to take a screengrab. You need a flyback diode around the coil or Q1 will be zapped. Feb 12, 2018 at 19:51
• What exactly is your goal? Are you trying to make sound? Feb 12, 2018 at 19:55
• @Transistor it's not a screengrab, just a circuit I did in CircuitLab before asking the question. If embedding a pre-existing circuit is worse for SO, though, I can easily copy-paste it into the "add circuit" window? Feb 12, 2018 at 20:39
• @HarrySvensson yes, I'm trying to vibrate a metal bar at its resonant frequency to make it sound. Feb 12, 2018 at 20:40

If you want to make the field change quickly and if the inductance is relatively large, the only way to make that happen is with a lot of volts. It sure ain't 1uH. It could easily be ~1H.

You can experimentally try it (with a flyback diode and a low duty cycle pulse) to see how rapidly the current builds up (on an oscilloscope). If it is too slow, you might have to do something like use a higher voltage supply with a resistor (dumping copious heat) in series. If you're just doing a test that might be fine. The field strength is proportional to the current through the coil. Similarly, tying the flyback diode to a high voltage supply will allow the field to collapse relatively fast.

I'm not sure what you are trying to accomplish with an H-bridge unless you are planning to put a permanent magnet on the bar. For a ferroelectric bar the electromagnet "sucks" with either polarity of current.

• Tying a diode to a high voltage power supply can only work if the power supply can sink current. Typically you would use a high voltage Zener diode if you wanted to have fast current fall time. Feb 12, 2018 at 20:41
• @JackCreasey A capacitor on the supply will suffice. The energy is returned to the power supply. A zener would just waste the energy as heat. Feb 13, 2018 at 4:27
• If you want to return energy (of the collapsing field) to the power supply you need two diodes (as shown in the other answer), you don't achieve this with a single diode across the coil. Feb 13, 2018 at 5:25

Might not be possible due to the inductive load of the electromagnet

There is no reason why a load being inductive would make it impossible to control. You just need to adapt your circuit to suit the load being driven.

Might require a flyback diode

With the single transistor topology you propose, it certainly requires a flyback diode, or you'll either overheat or outright destroy the transistor.

In order to reach relatively high frequencies, you'd need to add a resistor in series with the diode in order to quench the current fast enough, as otherwise the electromagnet current would flow for such a long time that it wouldn't reach zero before the start of the next period:

simulate this circuit – Schematic created using CircuitLab

The value of the resistor depends on the drive voltage and the frequency you want to reach. Higher frequencies require larger value resistors, but keep in mind that increasing the resistance also increases the voltage that the transistor has to withstand. This is also very inefficient, as that resistor will have to dissipate all the energy stored in the electromagnet during the high time as heat, wasting a lot of power, which brings us to the next point...

Might benefit from an H-bridge to reverse the electromagnet's polarity and double the amount that it "pushes" on the metal bar.

Reversing the electromagnet current would only be useful in the case that the "metal bar" is also a permanent magnet. If the bar is just a chunk of steel, you'd only cause eddy currents and hysteresis losses for no benefit since the steel would be attracted in the same direction regardless the polarity of the electromagnet.

A H-bridge would bring a significant benefit: efficiency. A bridge topology allows the energy stored within the magnetic field of the inductor to be recovered for the next cycle.

This schematic shows a discrete transistor bridge (omitting the gate drivers), but most off the shelf DC motor drivers would work too. The diode in series with the electromagnet is there in order to prevent the unwanted reversal of electromagnet current. Without that diode you'd need to actively sense the current in order to explicitly switch the transistors off as the current nears zero. If the electromagnet is acting on a permanent magnet, that diode must of course be omitted.

If you only need unidirectional current in the electromagnet, as when driving a ferromagnetic vibrating object, you can replace two of the transistors with diodes:

simulate this circuit

The electromagnet is specified for 12V 0.33A so its DC resistance is around 36 ohms, which is pretty high.

A very simple solution to your problem is to go to a pawn shop and purchase a second hand audio power amplifier for about \$20. Wire the electromagnet to the loudspeaker output, and input your waveform on the audio input. The only drawback is you can't set a DC component on the waveform. But it's cheap and it should work.