Just an idea for a crude circuit that uses a capacitor charged by a current source to produce a ramp voltage (whose rate of voltage increase over time is adjustable by adjusting the charging current). The charge across the capacitor is periodically discharged by a square wave input signal. The frequency of the input signal determines how high of a voltage the capacitor will be charged to before being discharged. A peak detector then records and smooths (or maybe somewhat smoothes lol) the maximum voltage converting this into a “DC” voltage corresponding to the frequency of the input signal. The lower the frequency of the input signal, the higher the DC voltage at the output.
When you do this, you will be operating your N-channel MOSFET in the linear region. Generally, switch-mode power supplies are designed to operate MOSFETs either completely ON or completely OFF to improve efficiency.
Also, it seems like your feedback mechanism is happening from the drain to the gate.
For high-side switching, I recommend using a P-channel MOSFET and switching the polarity of your pulse circuit around to reference the 5 V rail instead of the 0 V rail. Or, you could switch your output MOSFET to a low-side switch instead, but then you load does not have a ground reference.
Edit: keep tinkering, learning, etc., it only gets better.
Edit 2: have you learned about Op Amps yet? These types of circuits are made better and more fun to design with the addition of op amps and feedback circuits!
Just an idea for a crude circuit that uses a capacitor charged by a current source to produce a ramp voltage (whose rate of voltage increase over time is adjustable by adjusting the charging current). The charge across the capacitor is periodically discharged by a square wave input signal. The frequency of the input signal determines how high of a voltage the capacitor will be charged to before being discharged. A peak detector then records and smooths (or maybe somewhat smoothes lol) the maximum voltage converting this into a “DC” voltage corresponding to the frequency of the input signal. The lower the frequency of the input signal, the higher the DC voltage at the output.
Also [here is](https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEA2AnNAzAFi2DCxItsxkkFIQliqBTAWjDACgAzcAdmRAwCZLeWSn2G9w0JDEi9mAcxCDhGbop4AOLFCjMAxgrVr9h3gZ7JDw2PGs24WBoazQOvDBw6oCXihyySrLADuRmbGQqHawarKYUrckMxRpiaxIQlR4SkK4RhE2gCWIWCoYllZlFJwxag1tXV1amwhWTEhfOL+0okRvC4RxWLp-SVFIwl6rbmak+ZaYBK2i9IMHDywboIckHi9aIbzFEs2vCvdM8amrQkATiC43FN3pBGUYIdw3fcR55FPD3mTPIJABudzUwlmWHB4DGWnCki0MAQn2hA2GgxREMczyuzDAW04Kj6+JUmR4cAU8Co4G6JIUxK4PH42gA9uAkMhNJQhDVqZU4KguAhkLwESwgA) a link to the Falstad version of the circuit in case you feel like messing around with it!
What is this app?
When you do this, you will be operating your N-channel MOSFET in the linear region. Generally, switch-mode power supplies are designed to operate MOSFETs either completely ON or completely OFF to improve efficiency.
Also, it seems like your feedback mechanism is happening from the drain to the gate.
For high-side switching, I recommend using a P-channel MOSFET and switching the polarity of your pulse circuit around to reference the 5 V rail instead of the 0 V rail. Or, you could switch your output MOSFET to a low-side switch instead, but then you load does not have a ground reference.
Edit: keep tinkering, learning, etc., it only gets better.
Edit 2: have you learned about Op Amps yet? These types of circuits are made better and more fun to design with the addition of op amps and feedback circuits!
It’s an app called EveryCircuit (android and ios I believe)