1P3T switch model in ltspice

Discussion in 'General Electronics Chat' started by cmartinez, Dec 5, 2015.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,557
    2,519
    So I downloaded this pretty 1P3T switch model for LTspice. And I've already copied the .asy and .sub files to their proper directories and made this simple circuit to test it.

    Capture.JPG

    My question is, how do I use it? What's the instruction (.step, time, etc) that I'm supposed to use to make it change states during the simulation?

    Thanks in advance
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Open and study 1P3T.sub

    Pretty dumb way of doing it...
     
    cmartinez likes this.
  3. crutschow

    Expert

    Mar 14, 2008
    12,993
    3,227
    Right click on the switch. In the window that opens, the SET function can be set to values of 1, 2, or 3 for the three switch positions.
    Change the SET default value of 1 to {S} including the curly brackets (or any other variable name of your choice).

    Generate the spice directive .step param S list 1 2 3 (no curly brackets).

    Then when you run LTspice it will perform three simulations, one for each position of the switch.
    That will work in any simulation mode.
     
    cmartinez likes this.
  4. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    MikeML is right...that's a funky switch...o_O

    What kind of switch functionality are you lookin for?
     
  5. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,557
    2,519
    Thanks for replying. I'm looking for something like crutschow just described. But I'd also like to learn how to use it using the time directive. That is, to make it change states during the course of a simulation.
     
  6. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    Hi

    Its straight forward in LTspice.

    Use a SW device and drive its control nodes with a pulsed Voltage source.

    There is an example in the LTspice examples folder
     
    cmartinez likes this.
  7. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,557
    2,519
    Yeah... I already know how to generate a pulsed Voltage source using a voltage controlled switch, that comes included in the standard LTspice download, but they look ugly in the schematics (I'm a perfectionist, and it's a quality that I have to live with... and my wife :D)... I was just wondering about the switch devices such as the one I posted, because I'd like to learn how to model them and how they work.
     
  8. crutschow

    Expert

    Mar 14, 2008
    12,993
    3,227
    Don't know of any way to make it change state during a simulation.
     
  9. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Rewrite the three-way switch model so that it is a function of a node voltage, rather than a function of a parameter. Now use this method (or PWL) to make a voltage a function of time. This will cause the switch to change state at specified times...

    152.gif
     
    cmartinez likes this.
  10. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    Here is an example using your switch:

    In SWpos3 I show an example using a user friendly parameter naming to set the switch.

    Note that I could have run a stepped parameter version of this but I thought it would be easier for the OP if I used separate images.
     
  11. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    I thought that TS wanted to step the switch in the middle of a simulation run?
     
  12. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    Yeah...but wouldn't be able to do that with that funky switch model.
     
  13. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    I had said in post #9: Rewrite the three-way switch model so that it is a function of a node voltage, rather than a function of a parameter.
     
  14. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    Here's a cool demonstration.

    This simulation shows the effect of switch bounce.
     
    cmartinez likes this.
  15. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    Yes you did...but I don't think the OP knows why...:(
     
  16. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,557
    2,519
    Excellent example, Mike, thanks! Question, why can't the three-way switch model be written so that it is a function of time instead?

    Very cool! as you've just said. Mind posting the asc file tor that example?

    You're right about that one... I don't yet know why
     
  17. eetech00

    Active Member

    Jun 8, 2013
    648
    110
    Hi cm

    The reason it can't be done with your switch model is because the "SET" variable is a parameter. Parameters are computed before the simulation begins and can't be changed during. So that's why the model would have to be re-written. If you used a voltage source (like the one MikeML showed you) to control a SW, then you could change the state of the switch during transient analysis.

    hope that helps...
     
    cmartinez likes this.
  18. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,777
    1,103
    Easiest to make the model switch state voltage-dependent, as Mike suggested, then add a time-dependent voltage source as the control input. With the voltage-dependent model (any number of positions) it is straightforward to model either a break-before-make or a make-before-break action.
     
    cmartinez likes this.
  19. crutschow

    Expert

    Mar 14, 2008
    12,993
    3,227
    Mike, can you show us how to do that?
     
  20. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,557
    2,519
    I'm kind of curious too.
     
Loading...