I got a solenoid with the following data:
- 460Ohm resistance
- Inductance value unknown
I'm working on a sensor PCB which also needs to control the force of the solenoid. The sensor PCB is already using an ATTINY44 and has a 24V supply.
To control the force of the magnet I want to basically use a buck converter, with the ATTINY as controller. When configured as fast PWM 8bit with no prescaler and running on a 16Mhz crystal it should give a PWM signal of 62.5kHz.
This PWM signal I want to feed into the following circuit:
The value of VOut5 is fed back by a resistor divider to one of the ATTINY analog inputs. The ATTINY ADC is configured to convert it in "free running mode" and the PWM signal is adjusted according to this value.
Which is basically working fine except for one Problem (btw. I want to control the magnet voltage VOut5 from 5V to 24V). To get the following voltages the PWM signal is settling at about:
- 5V -> ~15% (PWM comparator OCR1B ~ 38)
- 10V -> ~28%
- 15V -> ~44%
- 20V -> ~61%
- 24V -> ~75% (PWM comparator OCR1B ~ 191)
This reduces my resolution to \$ Res=191-38=153\$ instead of 255. As I need quite a bit of precision I would like to use the full resolution of 255. By trial and error (mostly by changing the inductor value) I got to the chosen values in this circuit.
So my question: What do I have to change to get nearly the full resolution of 255 (e.g. 5V at close to 0% PWM and 24V close to 100% PWM)? Or is there a better way to than my trial and error (because each simulation run on my computer takes about 20min)? Can I calculate this?
As I need to make about 200 of these boards I would like to find a simple / cheap solution (that's basically, why I wanted to use the existing ATTINY, which had 2 free pins left as a controller in the first place).
P.S. to simulate this circuits behavior I build up below LTSpice model: The part of the circuit in the red box emulates the ATTINY. Due to the rest of the program running on the ATTINY it is only able to adjust the PWM signal every 0.5ms (modeled by the sample and hold part. The LTC6992 is used to generate the PWM signal of 62kHz (R18 set to 800k) out of 0V to 1V voltage at the MOD pin. This emulates the behavior of the ATTINY pretty close.
The model can be downloaded here in case you need it.