LT Spice 101

Thread Starter

PhilTilson

Joined Nov 29, 2009
153
I am a regular designer of digital circuits, MCU projects etc, but totally new to LT Spice.

I have tried to follow some introductory articles but am still floundering somewhat. I am trying to analyse a fairly simple circuit, designed to take input from a 230V nominal supply and cause an opto-isolator to trigger an input on an MCU. I have attached the circuit diagram that I have put into LT Spice below.

My problem is that I cannot see how to set up the voltage source/analysis parameters in order to simply see what voltages etc I am getting in various parts of the circuit. I know that there are people on this forum that eat LT Spice for breakfast! Can you advise, please?

1753810091704.png
 

crutschow

Joined Mar 14, 2008
38,400
My problem is that I cannot see how to set up the voltage source/analysis parameters in order to simply see what voltages etc I am getting in various parts of the circuit.
LTspice 101 - Lesson 1 :

Your sim shows the input sine voltage setting for V1 which is fine (the AC voltage value, normally set to 1V when doing an AC linear analysis over a frequency range, giving a Bode plot, but is not useful for this non-linear circuit).
(You need circuit values for all components and you are missing one for R4.)

So you run a transient analysis for an appropriate time (here start with100ms), and then clicking on any circuit node will show the voltage for that node plotted versus time (as an oscilloscope would show).
And if you click on a component it will plot the current through that component.

Note that you may get an error when doing a sim for that circuit, since there is no connection to the outputs of U1 (usually LTspice doesn't like floating nodes).
You can just connect them to ground, if you like.
 

Alec_t

Joined Sep 17, 2013
15,112
Note that for a sine wave source you specify the amplitude, not the RMS voltage. So for 230V RMS mains the amplitude will be 230 x √2 = 325V.
BTW, the inbuilt Help offers guidance for newbies to LTS.
 

eetech00

Joined Jun 8, 2013
4,704
I am a regular designer of digital circuits, MCU projects etc, but totally new to LT Spice.

I have tried to follow some introductory articles but am still floundering somewhat. I am trying to analyse a fairly simple circuit, designed to take input from a 230V nominal supply and cause an opto-isolator to trigger an input on an MCU. I have attached the circuit diagram that I have put into LT Spice below.

My problem is that I cannot see how to set up the voltage source/analysis parameters in order to simply see what voltages etc I am getting in various parts of the circuit. I know that there are people on this forum that eat LT Spice for breakfast! Can you advise, please?

View attachment 353344
Hi

Lesson 1: Know the real circuit behavior and the expected results.
LTspice will not design the circuit for you, but will help you confirm the designs' theory and behavior.

Here is a link to "LTspice Basics" video showing a "how to" on transient simulation analysis setup.
https://www.analog.com/en/resources/media-center/videos/6368296727112.html

The same concepts apply to DC operating point analysis and AC analysis

Quick comments:
Use actual (reasonable) values for your passive components.
Avoid using generic active components.
AC "Sine" sources interprets the specified amplitude value as Pk-Pk.
To use RMS, specify an amplitude value as RMS_value * sqrt(2).
Never leave nodes floating.

Note the quick comments above, however, with experience you'll learn that there are exceptions to some of these.

If you post your circuit, we can help set it up.
 

Thread Starter

PhilTilson

Joined Nov 29, 2009
153
Thanks for help so far!

This is the netlist for the (revised) circuit, shown below:

* C:\Users\phil\OneDrive\Documents\LTspice\SensorMonitor.asc
* Generated by LTspice 24.1.9 for Windows.
C2 N001 IN 0µ1 V=400
R1 N001 IN 470K
R3 0 P001 100
D2 N001 N002 1N4007
C1 N002 0 220 V=16
V1 IN P001 SINE(0 262 50) AC 230
D1 0 N002 UMZ5_1N
R4 Voi N002 1k
X§U1 Voi 0 Vin 0 PC817 Igain=2.3m
V2 N003 0 3.3v
R5 N003 Vin 10k
.model D D
.lib C:\Users\phil\AppData\Local\LTspice\lib\cmp\standard.dio
.lib PC817.sub
.backanno
.end

1753823701099.png
 

Attachments

Papabravo

Joined Feb 24, 2006
22,065
You can use an operating point analysis to compute the DC operating point of the circuit. The spice command is ".op" and your schematic would look something like this:

1753825022528.png

The information from the operating point calculation is in the Spice Error Log or the Spice Output File
 

eetech00

Joined Jun 8, 2013
4,704
Thanks for help so far!

This is the netlist for the (revised) circuit, shown below:

* C:\Users\phil\OneDrive\Documents\LTspice\SensorMonitor.asc
* Generated by LTspice 24.1.9 for Windows.
C2 N001 IN 0µ1 V=400
R1 N001 IN 470K
R3 0 P001 100
D2 N001 N002 1N4007
C1 N002 0 220 V=16
V1 IN P001 SINE(0 262 50) AC 230
D1 0 N002 UMZ5_1N
R4 Voi N002 1k
X§U1 Voi 0 Vin 0 PC817 Igain=2.3m
V2 N003 0 3.3v
R5 N003 Vin 10k
.model D D
.lib C:\Users\phil\AppData\Local\LTspice\lib\cmp\standard.dio
.lib PC817.sub
.backanno
.end

View attachment 353351
Upload your LTpsice schematic "SensorMonitor.asc" file.
 

crutschow

Joined Mar 14, 2008
38,400
Note that your circuit will take a very long time to settle with C2=220F (a huge capacitor).

C2 also needs a diode to ground (anode) to discharge it during the negative half cycle.
 
Last edited:

Thread Starter

PhilTilson

Joined Nov 29, 2009
153
I think it will be fairly obvious to most, but just to clarify, the module described above is designed to allow me to monitor certain aspects of home energy consumption. The boards I have designed have inputs for four DS18B20 temperature sensors and four inputs for "mains on/off".

So, for example, I could monitor temperatures in the airing cupboard and on the hot water tank, as well as knowing when the immersion heater switches on and off, when the iBoost comes on etc.
 

Thread Starter

PhilTilson

Joined Nov 29, 2009
153
Note that your circuit will take a very long time to settle with C2=220F (a huge capacitor).

C2 also needs a diode to ground (anode) to discharge it during the negative half cycle.
As you will see from my latest post, I am really only interested in the steady state - is the input on or off? So I am hoping that neither of the cautions you mention will apply!
 

Thread Starter

PhilTilson

Joined Nov 29, 2009
153
hi Phil,
Add the .tran100m
Also use vo output label.
E


BTW: LTSpice uses Vpeak values so 230V *1.414 = 325v

View attachment 353379
Thank you, Eric. Having put in the .tran command, I now get a similar result to yours above. However, it doesn't make sense!

On both your and my plots, what you have labelled as Vsensormonitor is zero, as is Voi. Looking at the diagram, I would have thought that this voltage would rise rapidly to a level limited by the zener diode and stay there. Voi should sit at the PC817C diode forward voltage and Vo should drop to near zero. For interest, the plot below shows the voltage at the right-hand side of C2 which, again, I don't understand.

1753959477079.png
So where am I going so badly wrong?!
 

ci139

Joined Jul 11, 2016
1,976
the google assures that several countries have ~230V low voltage grid std. ►► Vpk = √¯2¯' · 230Vʀᴍꜱ ≈ 325.269V
+ the grid has impedance of about 4Ω = your 100Ω peak limit must be present at your actual circuit
Xc=31.8kΩ → (230/2)/33k → 3.5mA to irLED at first , (230/2)/470k → 245μA later
(C₁ introduces a considerable delay for whatever you detect)
 
Last edited:

crutschow

Joined Mar 14, 2008
38,400
I would have thought that this voltage would rise rapidly to a level limited by the zener diode and stay there
Back to my comment about the 220 Farad capacitor which you "hoped" wouldn't apply.
It can't rise "rapidly" with such a large capacitor being charged thru a 0.1µf capacitor from the AC.
That would require over 4 billion cycles of the input voltage. :eek:

And hope also doesn't eliminate the need for the added diode.

Hoping doesn't generally get you very far when designing circuits. :rolleyes:
 

Thread Starter

PhilTilson

Joined Nov 29, 2009
153
Back to my comment about the 220 Farad capacitor which you "hoped" wouldn't apply.
It can't rise "rapidly" with such a large capacitor being charged thru a 0.1µf capacitor from the AC.
That would require over 4 billion cycles of the input voltage. :eek:

And hope also doesn't eliminate the need for the added diode.

Hoping doesn't generally get you very far when designing circuits. :rolleyes:
I acknowledge the c*ckup over the 220 farad capacitor!

I have now managed to run a series of simulations in LT Spice and I think I may have found a component combination that should work. It does mean a larger input capacitor (0.68μF) but it does exactly what is required using a 220μF 'smoothing' capacitor. Now all I have to do is to see if it works ion practice. Watch this space!

1753997192949.png
 
Top