Mechanical switch in LTspice

Discussion in 'General Electronics Chat' started by cmartinez, Apr 15, 2015.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    I'd like to use LTspice to simulate how a mechanical switch produces a spike in voltage when it is opened while driving an inductive load.
    Can it be done?
     
  2. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,320
    889
    I haven't used it myself, but you might try the sw (voltage-controlled switch) component, driven by a PWL or PULSE voltage source.
     
    cmartinez likes this.
  3. crutschow

    Expert

    Mar 14, 2008
    13,023
    3,236
    LTspice has a voltage controlled switch model (sw) that will certainly generate a spike with an inductive load.
    You need the sw model discription for the switch to work (look up "sw" in the help file).
    You add it as a Spice directive (hit the S key while in the schematic window) .
     
    cmartinez likes this.
  4. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Here is something I did some time ago...

    SnubberRc.gif
     
    DickCappels and cmartinez like this.
  5. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    Very, very interesting. Thank you both.

    I just found the Vswitch.asc example included in LTspice and am finding it quite useful.
    My only issue with it is that it's a voltage controlled switch... is there no other kind of switch that could be timed during the simulation? But maybe that's not important since I can always configure a voltage source to drive it.

    Thanks again!
     
  6. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    Excellent file Mike! Thanks for posting.
     
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    It is easy to make the switch state a function of time, a voltage, a current, etc...
     
  8. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    Would you please share with me your definition of easy? I'm a neophyte in most LTspice-related things... need to find an example of making a switch a function of time... or maybe I just need more experience with the spice-directive instruction.
     
  9. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    The sim I just posted makes the switch state a function of time because the controlling voltage V(pulse) is a function of time. By default, the switch is closed when the input voltage is >0V, and is off if the input control voltage is <=0V. If you prefer it to have a different Threshold voltage, you can set it in the .model SW statement. You can model a switch with hysteresis, too.
     
  10. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    Yeah... that's more or less what I meant on post #5 ... but you've given me even more information now, thanks.
     
  11. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    Hello all... I just found the time function in LTspice, and I'm using it to change resistor or pot values (or any value for that matter) during the simulation. In the case of a resistor, for instance, one only has to change its value to:

    R=if(time<10m, 5, 15)

    Alternative:
    R=table(time,0,5, 10m,5,10.01m,15, 20m,15, 20.01m,25)

    You can make nested if() of course.
    R=if(time<10m, 5, if(time<20m,15, 25))

    EDIT: will next try it with the switch
     
    Sinus23 likes this.
Loading...