In a solenoid (ie, something like a pinball solenoid, not a solenoid-wound inductor), the inductance is at first much lower, until the core is fully engaged. Once the core is fully bottomed out, the inductance does not change.

If the PWM is fast enough that the current has very little ripple in it, then you can wait long enough for it to stabilize and then measure the current. However, this relies on the PWM duty cycle remaining the same.

Hmm… I think at that point, only the resistance limits current. So (Vcc x duty cycle)/I should equal the DC resistance of the solenoid.

Imagine this: a 50% PWM from 0-12V can be broken into a 6Vdc signal with a 50% duty cycle AC squarewave of 6Vpeak. The DC component of the stabilized current will come from 6Vdc / 36 ohms = 166.66mA.

So for a solenoid with the core fully engaged and no longer moving, and waiting long enough for the current to stabilize:

Assume a solenoid inductance of 50mH and a DC resistance of 36 ohms. The time for an RL circuit to stabilize is 5Tau, where Tau = L/R. So the time to stabilize current must be equal to or greater than 5 x 50x10^-3 / 36 = 6.9444ms or about 7 milliseconds.

The ripple on the current will be due to the squarewave component across the combined inductance and resistance. However, you can’t just use XL = 2 x pi x freq x inductance, as stated that only works with a sine wave. Instead, we will look at the charge/discharge time.

I = I_{max}(1 ? e^{? t/?au} )

I_{max} = 6V (the peak value) / 36 ohms (the DC resistance) = 166.67mA

Tau = 50mH/36 ohms = 1.3889ms

t = 0.5 (50% duty cycle) x 1/freq of PWM

To get a reliable measurement, I’d suggest the ripple current should be <= 1/20th of the DC current. At 50% duty cycle, that is about 8mA.

8x10^-3 = (6/36)(1 ? e^{? (0.5/f)/(0.05/36)} )

48x10^-3 = 1 ? e^{? (0.5/f)/(0.05/36)}

1 - 0.048 = e^{? (1/(2f))/(0.05/36)}

ln(0.952) = ? (1/(2f))/(0.05/36)

-ln(0.952) x (0.05/36) = (1/(2f))

f = 1/(-ln(0.952) x (0.05/36))

f = 14.6387kHz

So if you can use a PWM of at least 15kHz (higher is better), then you can simply measure the current with a small series resistor.

Otherwise, you could use 300 to 600Hz, and add a lowpass filter between the series current sense resistor and the Arduino. It’ll require a fairly low frequency knee, and will respond more slowly than if you just used f_{PWM} >= 15kHz.