Electronic – Transistor switch with capacitive load

capacitormosfettransistors

The goal

I would like to know how to connect a transistor (MOSFET) to a capacitive load. I would like to rapidly charge and discharge a capacitor.

How do I do it correctly? I basically want the transistor to work as a mechanical switch.

enter image description here

What I have tried so far

I have tried the following circuit, but for some reason, VDS (voltage, drain-source) is always zero. Here VDS = V_cap (Voltage over the capacitor)

enter image description here

Here is a transient analysis:

enter image description here

The issue:

As you can see VDS is always zero. I expect it to be alternating.

Additional Material

EDIT:

As suggested, putting a small Resistor (here I put 10Ohms) in parallel solves the issue:

enter image description here

enter image description here

… but I don't understand why? Wouldn't we have a floating node if the transistor is open?
enter image description here

Best Answer

To observe a VDS of 5V you must have some way of reducing the voltage across the capacitor to zero. Your circuit has no path for current flow to accomplish that. Try putting a resistor in parallel with the capacitor and you should see VDS change.