PWM for a solenoid

My solenoid is working fine with a 0-5v PWM signal from an Arduino analogoutput controlling a MOSFET that feeds the solenoid 0-24V. I was concerned that maybe a PWM from the MOSFET would harm the solenoid somehow.

I set up a simple RC circuit to change the Arduino output to steady DC voltage. The problem is with a simple RC circuit I can only get 2.5V out of it and the solenoid does not work. Is it a case that I am just messing with a good thing? Thank you all for the continued help!

I was concerned that maybe a PWM from the MOSFET would harm the solenoid somehow.

It won't.

I set up a simple RC circuit to change the Arduino output to steady DC voltage.

So show the schematic of that, I can only guess at how you wired that up but if the current for the solenoid goes through the R then that will limit the current available to the solenoid.

Don't use a RC filter to shape the PWM signal. The solenoid already filters the PWM signal, forming a RL filter.

If your FET does not turn fully on, replace it by a logic level FET that turns fully on from a +5V gate voltage.