LTspice Voltage dependent Switch (variable substitution)

Thread Starter

dowon

Joined Feb 11, 2022
6
Hi, Guy.

I hope I can get some answers or clues for my simple switch circuit.

View attachment 289278

As shown in the diagram above, I do not want to use the independent voltage source for MYSW.
I want to operate the MYSW depending on the sinewave 50Hz voltage on the note "Vout".

For example, if the voltage value at "Vout" node is over 1V, the MYSW operates to turn on. So some current will flow through the resistor R3.

Thank you for being so helpful in advance.
 

Papabravo

Joined Feb 24, 2006
21,160
If I understnad you correctly you want a switch that monitors the voltage of some net in the circuit and switches when that voltage is exceeded. Is tha correct?
 

Papabravo

Joined Feb 24, 2006
21,160
You should know that you cannot have a switch with no hysteresis. That will cause the simulation to go into Heightened Defcon mode from which it may not recover. I added a small amount and I get this result.

1678333825955.png
You can tell that the switch is on by looking at the current in R3. It goes from 0 to approximately 525 mA. The switch symbol and subcircuit are not part of the standard LTspice library.
 
Last edited:

Thread Starter

dowon

Joined Feb 11, 2022
6
You should know that you cannot have a switch with no hysteresis. That will cause the simulation to go into Heightened Defcon mode from which it may not recover. I added a small amount and I get this result.

View attachment 289282
You can tell that the switch is on by looking at the current in R#. It goes from 0 to approximately 525 mA. The switch symbol and subcircuit are not part of the standard LTspice library.
Thank you, Papabravo!
You mentioned that "The switch symbol and subcircuit are not part of the standard LTspice library."
Does it mean that I need to create the switch model which you showed in the model?
Could you please tell me how I get the switch (U1) model?
Regards,
 

Papabravo

Joined Feb 24, 2006
21,160
Thank you, Papabravo!
You mentioned that "The switch symbol and subcircuit are not part of the standard LTspice library."
Does it mean that I need to create the switch model which you showed in the model?
Could you please tell me how I get the switch (U1) model?
Regards,
I can give you the symbol and a subcircuit file, but I can't tell you how to use them on your system because there are a number of possibilities:
  1. You can put them in the standard locations, either Documents or AppData, and use them in multiple projects.
  2. You can locate them in a private library
  3. You can make copies of them for each folder that will use them.
Depending on which choice you make the actual contents of the symbol file (extension .asy) may have to change. Some folks are experienced enough to take what I give them and modify it to suit their purposes. Other folks may need a bit more hand holding.

Which version of LTspice are you using?
  1. LTspice IV
  2. LTspice XVII 17.0.36 or earlier
  3. LTspice 17.1.6 (latest version)
 

Thread Starter

dowon

Joined Feb 11, 2022
6
If I can receive the symbol and subcircuit file, It will be awesome and thankful.
I am using LTspice XVII 17.0.36 version.
1678340711068.png

Again, I deeply appreciate your response and time.
 

Papabravo

Joined Feb 24, 2006
21,160
If I can receive the symbol and subcircuit file, It will be awesome and thankful.
I am using LTspice XVII 17.0.36 version.
View attachment 289285

Again, I deeply appreciate your response and time.
Can do. The symbol and the subcircuit file are intended to be placed in the same folder as the schematic. If you want to do something else we can talk about it.
 

Attachments

Thread Starter

dowon

Joined Feb 11, 2022
6
I am very impressed and appreciate it.
I will have a look at the details and learn about it further.
Again, Thank you !
 

Alec_t

Joined Sep 17, 2013
14,280
You can use the LTS-provided switch model if you set the parameters as vt=1.5 vh=1.5 . The switch will then close when v(out) exceeds 3V and open close to the next zero-crossing of the sine wave, if that's what you want to happen.
 
Last edited:
Top