Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Modeling a switch in LTspice

Status
Not open for further replies.

carbonzit

Active Member
Sometimes it seems the simplest things are the hardest to deal with ...

I'd like to model this circuit in LTspice:

**broken link removed**

In order to test it, I need to be able to "throw" the switches. How do I do that? For instance, I'll run the simulation for one second, and I want to throw the "set" switch half a second after starting.

I'm guessing this falls under the heading of "behavioral" circuit elements, but I have no clue as to how to implement it. Any (hopefully) simple way of doing this?
 
I use voltage controlled switch. See asc file for example.
 

Attachments

  • capcharge.asc
    1.1 KB · Views: 3,232
Here is a switch model I found on the net. Have not used it, but I am sure it will work.
 

Attachments

  • 1P3T.ZIP
    671 bytes · Views: 2,448
Oh, I see what your asking. Right click the switch in LTspice, in the component attribute editor in the value box you can set switch to on/off eg. value SW1 On
For real time control, I dunno.
 
No, actually your first idea what what I needed, something that can be automagically switched during the simulation. I tried it and it works fine. Thanks.

Pretty clunky to implement on the schematic, though. What I'd really like would be a SPICE subcircuit, called "switch" that just appears on the schematic as a single 2-terminal component and which I can set to close (or open) at some specified time. I hate having to include all those stray .model directives and such on a nice neat schematic. So I'll play around with this. (Any advice how to do this appreciated.)
 
I have designed a switch circuit that I have stored in a file called 'switch'. I then just copy and paste it into any circuit I need. Yes it is a pain to implement everytime. Alternatively, you can do the same above with MOSFETs - one of the internal models in LTSpice. The ON resistance is so low, it can be assumed to be as good as a switch. Control it with a Pulse voltage source. I use a MOSFET when I can get away with it purely for simplicity
 
Electronic Workbench from Multisim has a simple switch that can be controlled from a keyboard key while the simulation is running, which is very handy. Unfortunately LTspice does not seem to support such a feature.
 
I have designed a switch circuit that I have stored in a file called 'switch'. I then just copy and paste it into any circuit I need. Yes it is a pain to implement everytime.

Yes, it is. But I believe LTspice gives you all the "hooks" one needs in order to implement this in a neat package that could actually be chosen from the "component" menu, by building a .subckt and attaching it to an .asy symbol. Anyone know enough about this program to tell us how to do that?
 
Hmmm. I've had a think about this... How would making it into a subckt make it any simpler? You still need a switch input and output and I/O to provide a drive signal to activate the switch. The only thing you can simplify is the ON resistance. Regardless you would still need a .subckt command to specify it, so you might as well import your own library part... Attached is the file I use if it helps (just remove V1)
 

Attachments

  • switch.asc
    730 bytes · Views: 1,766
Hmmm. I've had a think about this... How would making it into a subckt make it any simpler? You still need a switch input and output and I/O to provide a drive signal to activate the switch. The only thing you can simplify is the ON resistance. Regardless you would still need a .subckt command to specify it, so you might as well import your own library part... Attached is the file I use if it helps (just remove V1)

hi simon
I also use a 'master' asc on which I have common components with their includes. Arranged such that they can be copied and pasted in a couple of seconds, to a new asc file.

I would say that its important that the components used should be kept as standard as possible if its intended that the asc files be shared with other LTS users.
 
Eric, that sounds really handy.
 
You can always open up 2 schematics - one with the library part (switch.asc) and one with the schematic you are editing, then use <F6> to copy from one to the other. it is clunky, but I use this every time
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top