I am trying to use an Arduino(Mega) to control an electromagnet strength.
In the end of the day, I will need to control the strength in 3 levels (High/ Low/ Off), I don't know yet what Voltage I will use for each level (Off is 0V of course).
My electromagnet is a 12V electromagnet. the High level will be at least 8 - 10V (possibly the full 12V strength).
I tried controlling the electromagnet with a DC motor driver L298N (with PWM signal from the Arduino to the Enable pin).
It worked well but when the PWM is not in 100%, the electromagnet vibrates and it causes noise with the bracket (really small vibrations, not visible by the naked eye, I only hear the noise from the bracket).
I would like to hear if you have any idea for a method to control the electromagnet strength with an Arduino (or solving the vibrations problem with the L298N).
Thank you for the response, the current is a direct function of the voltage (V=RI), this is why i AM referring to voltage.
the electromagnet resistance is ~30 Ohm.
I did not found any data sheet, this is the electromagnet:
Yes, but in this case we have an inductive load and the current also depends on the inductance of the magnet and the switching frequency. With a power supply of 12 volts and a resistance of 30 ohms, a maximum current of 0.4 amps is obtained at saturation of the magnetic circuit. I guess a field effect transistor like the SI2300 is a good choice.
Thanks for the response,
the SI2300 comes in a package that is not compatible with my project.
I did a little research on the MOSFET option and I found someone do a similar thing with the IRF520, do you think it can work for my situation?
May I ask why you think a PWM solution and mosfets will work well? An electromagnet needs a constant current supply. NOT a PWM. Otherwise it will just buzz and be less effective.
Simplest way is to use a relay and a 12DC supply. You can use a MOSFET but why?, when a relay is perfect for that?
You will need a small mosfet and flyback diode to switch the relay coil on and off. But that's it.
A relay is smaller and cheaper and easier than a mosfet with its necessary heatsink.
I don't know if you have realised it, but most constant-current supplies nowadays use an inductor as the main element.
Yes, buzzing is exactly the problem the OP describes, so the solution is to shift the PWM frequency into the ultrasonic range. But there is no suggestion that PWM would be "less effective" than any other approach. Altering the "effectiveness" of the electromagnet is exactly what the OP is requiring.
Using a constant-current regulator and altering its current setting by program control is certainly a possibility, but said constant-current regulator will necessarily include an inductor. As you already have an inductor in the electromagnet, you might as well use it and simplify the overall circuit. Note that a commutating diode is a critical component of the PWM control.