Problem controlling a linear solenoid using PWM

Hi all,

For my final year research project I want to determine if a linear solenoid can be used to stabilise a rifle (induced by breathing or slight trembling).

I want to use PWM to control the force exerted by the solenoid as I have a relationship between the force experienced by the rifle and the required PWM signal. I am using the Arduino Nano (ATmega 328)pin 5 (980 Hz) together with an IRFZ44N transistor, 5V regulator, 9V battery, MPU 6050 accelerometer and micro SD reader.

WHen I connect the solenoid to the Arduino circuit (see attached a schematic of my circuit) it gets power but the exerted force remains the same irrelevant of the PWM signal (I determined this by putting masses on the solenoid plunger to see how much it can lift at a specified PWM. When I did the same test with an external variable voltage supply without the arduino it exerted a different force at different voltages).

I checked the PWM output on the Arduino pins with a multimeter and it does change correctly according to that. Also when I connect the 9V battery as in my schematic, the full 9 V goes to the solenoid again irrespective of the PWM signal.

Does anyone have any advice as to why the solenoid is not reacting to the change in PWM and what I can possibly do to fix it?


Circuit layout.pdf (119 KB)

Firstly you have no free-wheel diode across the MOSFET so you've almost
certainly destroyed it when the first PWM pulse ended.

You always need to provide a safe path for current when switching an inductor
or you'll get 1000's of volts of kickback wiping out your circuitry.

Secondly if you want linear control of an inductor or motor you need a half-H-bridge,
ie two switches, not one. You need to define the time-averaged voltage seen at the
coil - with one switching device you have almost no control of this (although upping
the switching frequency will help).

You switch the coil voltage between supply and ground using two switches, then the
duty cycle will determine the average voltage, which in turn controls the average
rate of change of current, which controls your force. Resistance in the coil means
the average current is also controlled (a perfect inductor would actually be less
friendly to operate) You can then close the loop with PID control.

If you use 2 MOSFETs in a half-H-bridge then each MOSFET's body diode can act as
freewheel diode for the other. You'll need to ensure enough dead-time to prevent
shoot-through (google these).

Plenty of MOSFET drivers are available to make this easy to do with two n-channel
MOSFETs (IRS2004 for example will give deadtime and only needs a single PWM

The other term you sometimes see is "two quadrant operation", which for a motor
would mean active braking (which is exactly what you need for stiff control)

Thank you very much I will give it a try :slight_smile: