Gain limiter circuit in LTspice - current flowing in wrong direction

  • #1
Wrichik Basu
Science Advisor
Insights Author
Gold Member
2,179
2,716
This is one more thread in my quest to learn simulations in LTspice. I am trying to simulate the gain limiter network shown in this video. A snapshot of the video is available for quick reference:

1623312950591.png

My schematic in LTspice is shown below:

1623313011515.png

For the simulation, I am using DC sweep on voltage source V3, starting from -10 V to 10 V, incrementing by 0.01 V. Regarding the diode, I have picked the first one available in the library of LTspice. I am plotting the current through V3 vs the voltage of V3, and the ratio V3/I(V3) vs V3. The results are shown below:

1623313052678.png

As you can see, my graphs are almost identical to those in the video, except that they are flipped. Actually, the current in my circuit is flowing in the opposite direction to what has been shown in the video.

What is the error that I am making?

The LTspice files are attached; please remove the .txt extension before loading them in the software.
 

Attachments

  • Gain_limiter.plt.txt
    559 bytes · Views: 152
  • Gain_limiter.asc.txt
    2 KB · Views: 181
Engineering news on Phys.org
  • #2
The positive current direction in the first picture is in the opposite of the positive current direction in the LTSpice simulation. In order to see the direction of positive current in the simulation, hover the mouse over V3 and you will see a symbol with an arrow, which points down (at least when I run your .asc file).

jason
 
  • #3
jasonRF said:
The positive current direction in the first picture is in the opposite of the positive current direction in the LTSpice simulation. In order to see the direction of positive current in the simulation, hover the mouse over V3 and you will see a symbol with an arrow, which points down
Yes, I know, and that's what I wrote — in my simulation, the current is flowing in the opposite direction to what is shown in the video. I can easily plot the negative of the current and dV/dI and get the required plot, but that is not what has been done in the video. I need to find the error in the simulation.
 
  • #4
The spice current direction and polarity of voltage sources makes it difficult sometimes. The easiest way here is to use a current sense resistor, then plot "V3/I(Rsense)". If you need to reverse the sign of the current then "end for end" Rsense on the schematic. Alternatively insert a unary - in the plot equation; -V3/I(V3); to invert the plot.
 

Attachments

  • Gain_limiter_2.asc.txt
    2.1 KB · Views: 169
  • Gain_limiter_2.plt.txt
    559 bytes · Views: 166
  • Informative
Likes Wrichik Basu
  • #5
Baluncore said:
The spice current direction and polarity of voltage sources makes it difficult sometimes. The easiest way here is to use a current sense resistor, then plot "V3/I(Rsense)". If you need to reverse the sign of the current then "end for end" Rsense on the schematic. Alternatively insert a unary - in the plot equation; -V3/I(V3); to invert the plot.
Thanks a lot; sensing the current through Rsense instead of V3 solves all the problems. But this was a bit weird.
 
  • #6
@Baluncore I found something more weird: If I disconnect the Rsense in your file, rotate it by 180°, and reconnect it, the direction of current changes! How is this possible?
 
  • #7
Baluncore said:
If you need to reverse the sign of the current then "end for end" Rsense on the schematic.
Wrichik Basu said:
If I disconnect the Rsense in your file, rotate it by 180°, and reconnect it, the direction of current changes! How is this possible?
There is a spice convention that current always flows into "pin one" of a component. That current in the component will be reversed if you turn the component around, but the current actually flows the same way in the circuit wires between the nodes. LTspice can't measure the current in a wire, only the current in a terminal. You can always edit the plot equation with a unary minus to fix the sign.
 
  • Informative
Likes Wrichik Basu
  • #8
Wrichik Basu said:
But this was a bit weird.
My experience with simulations has been that there are a lot of trivial problems that are often easier to fix than to understand. I think it is important to have a basic understanding of what the result should look like, as you did. I've done lots of simulations with 1μΩ or 1GΩ resistors and such added to get the result I need.
 
  • Like
Likes Wrichik Basu

Similar threads

Replies
4
Views
3K
Replies
14
Views
1K
Replies
19
Views
36K
Replies
10
Views
2K
Replies
1
Views
1K
Replies
6
Views
3K
Replies
4
Views
1K
Back
Top