# Why can't I charge a capacitor using a N-FET as switch

I'm new to MOSFETs and LTspice, but I have an N-MOSFET working as I would expect with resistive loads, I’ve had step like input on the gate too and all seems good, but whenever I put a capacitor in series, since the idea is I want to be able to charge the cap, I get realy wierd values everywhere, like every value changes, sometimes on my sims I get -ve current too and constant drain too sometimes. Am I missing something or can you not charge capacitors using MOSFETs (if so how would I from a signal trigger?)

• Are you checking the UIC in the .TRAN card? Sep 28 at 23:21
• R1 and C1 are in series, so their currents should be identical. Are you sure the oscillogram is for the same circuit as your schematic? Sep 28 at 23:29

If you look at the scale of your current graph, you'll see that the currents being predicted are less than one fempto-amp ($$\\mathrm{fA}\$$). That's $$\10^{-15}\$$ of an amp. The reason that you're getting counter-intuitive visual results is because the simulation isn't accurate for currents that small unless you force it to be -- and if you did force it, with perfect components, you'd just get a capacitor current of zero.

What's happening here is that LTSpice (and most other SPICE variants, if I'm not mistaken) will find the DC operating point of your circuit before it launches the transient simulation.

This means that at the start of the transient simulation the circuit will be at equilibrium. By definition, this means there won't be anything to drive any change in the capacitor voltage, and, hence, no capacitor current.

To see your capacitor charging up, you need to either:

• tell LTSpice to start with an initial capacitor voltage of zero,
• drive your FET gate with a separate power supply that turns on after some delay (a "pulse" supply in SPICE parlance).
• Thankyou! I set the resistor conditions to be the suply initially, so why would the “ capacitor current be zero”? As mentioned in your comment if the cap was perfect, or are you referring to when in dc after settling? Sep 29 at 7:18

Notice that you are getting femtoamps of current change which means the simulator isn't set up properly for what you want to see. You have a few options as shown below.

1. Use the UIC directive in the transient statement as Periblepsis mentions as shown in the left example. You can either type in the UIC directive or check a box in the transient dialog. When Spice first starts up, the initial DC operating points are calculated which negates what you wanted to see. The UIC directive disables the initial DC operating points. Normally, UIC isn't used.

2. You can set an initial condition with the .ic card as shown in the middle example. Here, you would set node b to 20V (same voltage as the voltage source. This overrides the initial DC operating point at the specified node.

3. Do a simple equivalent by driving the RC circuit with a pulse generator as shown in the right example.

• It’s better to use startup instead of uic. See here: electronics.stackexchange.com/a/652838/254890 Sep 29 at 2:48
• Thankyou, i did that, for some reason i had to set the initial resistor value to the supply even with startup. Do you know why? Sep 29 at 7:19

Bread boarding this would have shown it works just fine... Electronics simulation is something I have never really trusted much. There is always something that needs changed in the settings to make it function the way you expect and I have never cared for that. I am really not why Google had to promote this question, I would even go as far to argue that this isnt electronics engineering. Get some parts and a bread board? Can the title be changed to make it obvious we are using a simulation tool?

• It is part of EE. But you're right about the title, it is lack that aspect. Sep 30 at 8:08
• My bad, was in the middle of the night as my temper with the software was running low. The question is still true to my understanding as at the time I didn’t know if this was actually an electronics issue or the softwares issue Sep 30 at 20:38
• If you can't either get the circuit behavior from analysis or by simulation and then see it act as expected in real life then you're not really applying the available science. Since engineering is applied science, I'd argue that accurately predicting a circuit's behavior from simulation or analysis (and knowing what you can't accurately predict) is central to electrical engineering. Oct 2 at 15:57
• @TimWescott i was confused of the behaviour hence my post originally, but i would always be open to havig any of my knowlage be told to be wrong and learn. Oct 3 at 17:52