# Simulating SMPS with ideal switch in LTSpice?

Yes, this in a portion of a homework assignment (hence the idealized and slightly asinine problem statement). Aside from solving the circuit (which I have done), I am supposed to simulate the following circuit using LTSpice. The problem is that idealized switch in the middle. I have tried using the voltage controlled switch built into LTSpice, but keep getting errors.

I am expecting a regulated voltage of (roughly) 50V.

I have tried simulated using a BJT with a square wave driving into the gate, but the result is highly dependent upon the voltage applied to the base. When I simulate with a 5V square wave, I get roughly 18V at the output, but when I simulate with a 50V square wave, I get an output around 42V.

I tried simulating using a FET (similar to above, just swap in the generic NFET model) as well, but out an output in the microvolt range, which clearly isn't correct. I also tried simulating using a voltage controlled switch, but I keep getting weird errors, I assume because the switch is only designed to be "thrown" once, not at a frequency of 200kHz. It keeps telling me that it can't find a model for my switch, even though the .op is clearly listed:

If anybody know how to simulate a switch like these, my class mates and I would be very appreciative (especially since the professor simply said 'Ask Google' when I came to him after trying for several hours).

EDIT:

I just tried running the simulation again using an NFET. It regulates to roughly 19V, which makes me think this isn't work either, consider the diode drop between the 20V source and the output. I tried several different voltages to the gate, none of which made any difference in the simulation.

• So, I Google 'spice ideal switch', and the second links is this: bwrcs.eecs.berkeley.edu/Classes/IcBook/SPICE/UserGuide/… - also, you mention you 'keep getting errors' using a voltage controller switch. I'm not a spice expert but you might want to elaborate on that. – RJR Mar 19 '14 at 0:36
• Thanks for the "lmgtfy" response, but the link you provided didn't address my issue. Yes, it mentions switches, but it doesn't address flipping a switch on/off at a certain frequency. – realityinabox Mar 19 '14 at 1:03
• You have no base current limit in your BJT. A BJT isn't the best choice for 200kHz. A MOSFET should work fine, what was your gate drive voltage? You need to make sure you have enough voltage to fully enhance the channel. Your diode is a 1N4148 yet you may have lots of amps of output current, not sure what the model will do with that. Since this is a boost converter you should maybe start with 10% duty cycle instead of 50% to see what happens. – John D Mar 19 '14 at 1:22
• @realityinabox, the switch is voltage controlled so I'd assume you just hook a square wave voltage source with the desired frequency up to nodes 3 and 4. Also, see here uta.edu/ee/hw/pspice/pspice10.htm ... – RJR Mar 19 '14 at 2:36

• The driving pulse is going from zero to 50V, yet the switch has vt=0 vh=-0.5; you should raise vt. Also, the 1N4148 is not quite the right choice, even if this is SPICE world and it can take 1kA without smoke effects. @realityinabox One reason is that you're not using negative feedback. Another is the choices for the elements (as mentioned above, for the diode). Use an ideal diode with .model d d ron=0.1 roff=10meg vfwd=0.45 vrev=100 epsilon=100m revepsilon=50m for a better and speedier choice. Then again, I am replying to a >2years old thread... – a concerned citizen Oct 9 '16 at 7:10