4
\$\begingroup\$

Below is an H bridge inverter circuit model I came across in net:

enter image description here

I'm getting Singular matrix Iteration error when I try to run this.

If I delete the circuit on the right things work. Or if I ground the C1's terminal it also works but then it is not the same circuit anymore.

I uploaded the circuit asc file here:

What could be the reason causing this error?

\$\endgroup\$
  • \$\begingroup\$ I'll answer, but I have to know something first: is this only a test, that is, only for simulation, to view waveforms, or will this be a full-working schematic? \$\endgroup\$ – a concerned citizen May 3 '18 at 13:43
  • \$\begingroup\$ This is only to simulate Im not gonna build it. \$\endgroup\$ – user16307 May 3 '18 at 13:45
  • \$\begingroup\$ What if you add a 1 Meg resistor from D1 anode to ground and same for D3? Ground A1 and A2. \$\endgroup\$ – winny May 3 '18 at 13:54
  • \$\begingroup\$ @user16307 As a general guide-line, if you only want to see a certain behaviour, use a behavioural, idealistic approach: SW instead of MOS, A-devices instead of comparators, or anything involving logic, ideal .model of diodes with proper epsilon and revepsilon can go a long way, ... and don't forget that voltage sources have zero internal resistance, so a cap across does nothing, unless some series resistance is added, but then you can specify it in the source, Rser, Cpar, which also transforms it, internally, in a current source, thus convergent friendly (see manual for V). \$\endgroup\$ – a concerned citizen May 3 '18 at 14:52
5
\$\begingroup\$

@loudnoises (and @Dorian, while I was writing) is right, so I'll only add a few more things: NMOSes in LTspice usually have a body diode, unless it's a monolithic MOS (which you don't have). Also, using behavioural sources is nice and handy, but the if() function brings unwanted discontinuities in the solver, which forces the derivative in that point to become a problem, numeric-wise.

It looks like you only need a comparator, so you're safer to use LTspice's own A-devices, which are fit for this task. By the way, that delay doesn't do what you want, it does delay, but until the waveform appears it will have the DC value; what you probably wanted was SINE(0 5 50 0 0 180), or a simple phase inversion with an E-source. Also, since you're only interested in a simulation, the MOSFETs can be replaced by the time-frendlier switches (SW). Looking over your picture, you are driving the MOSFETs directly referred to ground, but the high ones need a level shifter. The switches circumvent this problem.

Here's a reworked version:

hbridge

A1 is the comparator with complementary outputs, A2 together with A3 and A4 create the deadtime (specified through the .param dt=<value>), and I set the driving voltage 1.01 to be better plotted in the waveform window.

And here's the contents of the .asc file (copy and save as an .asc file, not .asc.txt):

Version 4
SHEET 1 1236 680
WIRE 496 -32 432 -32
WIRE 768 -32 496 -32
WIRE 832 -32 768 -32
WIRE 976 -32 832 -32
WIRE 432 0 432 -32
WIRE 496 0 496 -32
WIRE 768 0 768 -32
WIRE 832 0 832 -32
WIRE 96 16 -96 16
WIRE 192 16 160 16
WIRE -304 48 -384 48
WIRE -176 48 -304 48
WIRE -96 48 -96 16
WIRE -96 48 -112 48
WIRE -80 48 -96 48
WIRE 96 48 -16 48
WIRE 976 64 976 -32
WIRE -272 80 -288 80
WIRE -176 80 -272 80
WIRE -96 80 -112 80
WIRE 16 80 -16 80
WIRE 16 96 16 80
WIRE 96 96 16 96
WIRE 192 96 160 96
WIRE 432 96 432 80
WIRE 496 96 496 64
WIRE 496 96 432 96
WIRE 768 96 768 64
WIRE 832 96 832 80
WIRE 832 96 768 96
WIRE -288 128 -288 80
WIRE -96 128 -96 80
WIRE 96 128 -96 128
WIRE 432 144 432 96
WIRE 480 144 432 144
WIRE 592 144 560 144
WIRE 608 144 592 144
WIRE 736 144 688 144
WIRE 832 144 832 96
WIRE 832 144 736 144
WIRE 432 192 432 144
WIRE 496 192 432 192
WIRE 832 192 832 144
WIRE 832 192 768 192
WIRE 432 208 432 192
WIRE 832 208 832 192
WIRE 496 224 496 192
WIRE 592 224 592 144
WIRE 624 224 592 224
WIRE 736 224 736 144
WIRE 736 224 688 224
WIRE 768 224 768 192
WIRE 432 320 432 288
WIRE 496 320 496 288
WIRE 496 320 432 320
WIRE 768 320 768 288
WIRE 832 320 832 288
WIRE 832 320 768 320
WIRE 432 352 432 320
WIRE 608 352 432 352
WIRE 832 352 832 320
WIRE 832 352 608 352
WIRE 976 352 976 144
WIRE 976 352 832 352
FLAG -384 128 0
FLAG -288 208 0
FLAG 192 16 A
FLAG -304 48 Vcon1
FLAG -272 80 tri
FLAG 384 64 0
FLAG 384 272 0
FLAG 384 16 A
FLAG 384 224 _A
FLAG 880 64 0
FLAG 880 272 0
FLAG 880 224 A
FLAG 880 16 _A
FLAG 608 352 0
FLAG 192 96 _A
SYMBOL Digital\\diffschmitt -176 0 R0
WINDOW 3 -7 -16 Left 2
SYMATTR InstName A1
SYMATTR Value vt=0 vh=0 Vhigh={VH}
SYMBOL voltage -384 32 R0
WINDOW 3 26 80 Left 2
SYMATTR InstName V1
SYMATTR Value sin 0 4.5 50
SYMBOL voltage -288 112 R0
SYMATTR InstName V2
SYMATTR Value pulse -5 5 0 16u 16u 0 32u
SYMBOL Digital\\and -48 0 R0
WINDOW 3 -40 114 Left 2
SYMATTR InstName A2
SYMATTR Value td={dt} Vhigh={VH}
SYMBOL Digital\\and 128 -32 R0
WINDOW 3 -1 1 Left 2
SYMATTR InstName A3
SYMATTR Value tripdt=10n Vhigh={VH}
SYMBOL voltage 976 48 R0
WINDOW 3 28 100 Left 2
SYMATTR InstName V3
SYMATTR Value 10 rser=10m Cpar=10u
SYMBOL sw 432 96 M180
SYMATTR InstName S1
SYMBOL sw 432 304 M180
SYMATTR InstName S2
SYMBOL sw 832 96 R180
SYMATTR InstName S3
SYMBOL sw 832 304 R180
SYMATTR InstName S4
SYMBOL ind 464 160 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 5 56 VBottom 2
SYMATTR InstName L1
SYMATTR Value 500u
SYMBOL cap 688 208 R90
WINDOW 0 0 32 VBottom 2
WINDOW 3 32 32 VTop 2
SYMATTR InstName C1
SYMATTR Value 50u Rser=10m
SYMBOL res 592 160 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 0 56 VBottom 2
SYMATTR InstName Rout1
SYMATTR Value 5
SYMBOL diode 480 64 M180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D1
SYMBOL diode 784 64 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D2
SYMBOL diode 480 288 M180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D3
SYMBOL diode 784 288 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D4
SYMBOL Digital\\and 128 48 R0
WINDOW 3 -31 117 Left 2
SYMATTR InstName A4
SYMATTR Value tripdt=10n Vhigh={VH}
TEXT 80 288 Left 2 !.tran 20m
TEXT -352 320 Left 2 !.model sw sw ron=10m roff=10meg vt=0.5 vh=-0.5\n.model d d ron=10m roff=10meg vfwd=0.5 epsilon=50m revepsilon=10m
TEXT 88 256 Left 2 !.param dt=1u VH=1.01

Your schematic probably want to be a three-level modulation, but the way you did it would burn the power switches. I modified it a bit, you're welcome to modify it, yourself, to your heart's desire.


Just so I don't leave with teasing, here's the three-level version:

3lvl

and here's the .asc file:

Version 4
SHEET 1 1280 680
WIRE 496 -32 432 -32
WIRE 768 -32 496 -32
WIRE 832 -32 768 -32
WIRE 976 -32 832 -32
WIRE 432 0 432 -32
WIRE 496 0 496 -32
WIRE 768 0 768 -32
WIRE 832 0 832 -32
WIRE 96 16 -96 16
WIRE 192 16 160 16
WIRE -336 48 -384 48
WIRE -304 48 -336 48
WIRE -176 48 -304 48
WIRE -96 48 -96 16
WIRE -96 48 -112 48
WIRE -80 48 -96 48
WIRE 96 48 -16 48
WIRE 976 64 976 -32
WIRE -272 80 -288 80
WIRE -208 80 -272 80
WIRE -176 80 -208 80
WIRE -96 80 -112 80
WIRE 16 80 -16 80
WIRE 16 96 16 80
WIRE 96 96 16 96
WIRE 192 96 160 96
WIRE 432 96 432 80
WIRE 496 96 496 64
WIRE 496 96 432 96
WIRE 768 96 768 64
WIRE 832 96 832 80
WIRE 832 96 768 96
WIRE -288 128 -288 80
WIRE -96 128 -96 80
WIRE 96 128 -96 128
WIRE 432 144 432 96
WIRE 464 144 432 144
WIRE 480 144 464 144
WIRE 592 144 560 144
WIRE 608 144 592 144
WIRE 736 144 688 144
WIRE 784 144 736 144
WIRE 832 144 832 96
WIRE 832 144 784 144
WIRE 432 192 432 144
WIRE 496 192 432 192
WIRE 832 192 832 144
WIRE 832 192 768 192
WIRE 432 208 432 192
WIRE 832 208 832 192
WIRE 496 224 496 192
WIRE 592 224 592 144
WIRE 624 224 592 224
WIRE 736 224 736 144
WIRE 736 224 688 224
WIRE 768 224 768 192
WIRE 96 240 -96 240
WIRE 192 240 160 240
WIRE -176 272 -288 272
WIRE -96 272 -96 240
WIRE -96 272 -112 272
WIRE -80 272 -96 272
WIRE 96 272 -16 272
WIRE -336 288 -336 48
WIRE -208 304 -208 80
WIRE -176 304 -208 304
WIRE -96 304 -112 304
WIRE 16 304 -16 304
WIRE 16 320 16 304
WIRE 96 320 16 320
WIRE 192 320 160 320
WIRE 432 320 432 288
WIRE 496 320 496 288
WIRE 496 320 432 320
WIRE 768 320 768 288
WIRE 832 320 832 288
WIRE 832 320 768 320
WIRE -96 352 -96 304
WIRE 96 352 -96 352
WIRE 432 352 432 320
WIRE 608 352 432 352
WIRE 832 352 832 320
WIRE 832 352 608 352
WIRE 976 352 976 144
WIRE 976 352 832 352
FLAG -384 128 0
FLAG -288 208 0
FLAG 192 16 A
FLAG -304 48 Vcon1
FLAG -272 80 tri
FLAG 384 64 0
FLAG 384 272 0
FLAG 384 16 A
FLAG 384 224 _A
FLAG 880 64 0
FLAG 880 272 0
FLAG 880 224 _B
FLAG 880 16 B
FLAG 608 352 0
FLAG -288 352 0
FLAG -336 336 0
FLAG 192 96 _A
FLAG 192 240 B
FLAG 192 320 _B
FLAG 464 144 x
FLAG 784 144 y
SYMBOL Digital\\diffschmitt -176 0 R0
WINDOW 3 -7 -16 Left 2
SYMATTR InstName A1
SYMATTR Value vt=0 vh=0 Vhigh={VH}
SYMBOL voltage -384 32 R0
WINDOW 3 26 80 Left 2
SYMATTR InstName V1
SYMATTR Value sin 0 4.5 50
SYMBOL voltage -288 112 R0
WINDOW 3 33 36 Left 2
SYMATTR InstName V2
SYMATTR Value pulse -5 5 0 16u 16u 0 32u
SYMBOL Digital\\and -48 0 R0
WINDOW 3 -40 114 Left 2
SYMATTR InstName A2
SYMATTR Value td={dt} Vhigh={VH}
SYMBOL Digital\\and 128 -32 R0
WINDOW 3 -1 1 Left 2
SYMATTR InstName A3
SYMATTR Value tripdt=10n Vhigh={VH}
SYMBOL voltage 976 48 R0
WINDOW 3 28 100 Left 2
SYMATTR InstName V3
SYMATTR Value 10 rser=10m Cpar=10u
SYMBOL sw 432 96 M180
SYMATTR InstName S1
SYMBOL sw 432 304 M180
SYMATTR InstName S2
SYMBOL sw 832 96 R180
SYMATTR InstName S3
SYMBOL sw 832 304 R180
SYMATTR InstName S4
SYMBOL ind 464 160 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 5 56 VBottom 2
SYMATTR InstName L1
SYMATTR Value 500u
SYMBOL cap 688 208 R90
WINDOW 0 0 32 VBottom 2
WINDOW 3 32 32 VTop 2
SYMATTR InstName C1
SYMATTR Value 50u Rser=10m
SYMBOL res 592 160 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 0 56 VBottom 2
SYMATTR InstName Rout1
SYMATTR Value 5
SYMBOL diode 480 64 M180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D1
SYMBOL diode 784 64 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D2
SYMBOL diode 480 288 M180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D3
SYMBOL diode 784 288 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D4
SYMBOL Digital\\and 128 48 R0
WINDOW 3 -31 117 Left 2
SYMATTR InstName A4
SYMATTR Value tripdt=10n Vhigh={VH}
SYMBOL e -288 256 R0
SYMATTR InstName E1
SYMATTR Value -1
SYMBOL Digital\\diffschmitt -176 224 R0
WINDOW 3 -4 -11 Left 2
SYMATTR InstName A5
SYMATTR Value vt=0 vh=0 Vhigh={VH}
SYMBOL Digital\\and -48 224 R0
WINDOW 3 -40 114 Left 2
SYMATTR InstName A6
SYMATTR Value td={dt} Vhigh={VH}
SYMBOL Digital\\and 128 192 R0
WINDOW 3 -1 1 Left 2
SYMATTR InstName A7
SYMATTR Value tripdt=10n Vhigh={VH}
SYMBOL Digital\\and 128 272 R0
WINDOW 3 -31 117 Left 2
SYMATTR InstName A8
SYMATTR Value tripdt=10n Vhigh={VH}
TEXT 1040 288 Left 2 !.tran 20m
TEXT 480 400 Left 2 !.model sw sw ron=10m roff=10meg vt=0.5 vh=-0.5\n.model d d ron=10m roff=10meg vfwd=0.5 epsilon=50m revepsilon=10m
TEXT 1048 256 Left 2 !.param dt=1u VH=1.01
\$\endgroup\$
  • \$\begingroup\$ Thanks for the great answer. Btw you created PWM by using a sine wave and a triangular wave which are inputs to a Schmitt trigger comparator. How is that in a real implemented? By sine and triangular wave? Are they generated by an oscillator? \$\endgroup\$ – user16307 May 3 '18 at 16:51
  • \$\begingroup\$ @user16307 The Schmitt gate is used here as a comparator, because it's the fastest you'll get with this role, in LTspice, while being completely convergent friendly, and with a ton of parameters to taylor for your needs: vhigh/vlow, trise/tfall or rout/cout or tau, vt/vh, td, tripdt. BTW, the dead-time could have been simplified, too, by eliminating all NANDs, setting trise/tfall, and setting vt=0.75 vh=-0.25 for the SW (IIRC, take a grain of salt). And the whole thing could have been even more simplifed by eliminating all A-devices, only sine, triangle, and bridge, but clarity suffers. \$\endgroup\$ – a concerned citizen May 3 '18 at 17:29
3
\$\begingroup\$

The V4 source is ideal and, at some point both upper and lower MOSFET-s are opening. That translates to a huge current value through V4 that cannot be computed.

Enter V4 properties and put some series resistance to go further. Like 0.000001 ohm.

Edit

Not only V4 is ideal but also the other components, I can see that even with V4 having internal resistance there are huge spikes that slow the simulation. Put some real components from the list. Changing only the diodes to real ones made a really big difference.

\$\endgroup\$
1
\$\begingroup\$

Basically SPICE simulates circuits by solving a set of linear (usually linearised from nonlinear) equations i.e. \$Ax = b\$. Depending on the circuit, the matrix \$A\$ may not be invertible, which means that you cannot find the solution to \$x\$ or the unknowns (nodal voltages, branch currents etc.). This is referred to as singularity.

(The iteration term refers to when nonlinearities are linearised for the inversion of the \$A\$ matrix, this requires multiple iterations using a nonlinear solver to find the final solution.)

Things that can cause matrix singularity are hanging nodes, impedances with too high/too low values, ill-defined nonlinearities etc.

Finding out the specific issue would require a lot of debugging. Can you remove things until the circuit works, then add things until it breaks? This will indicate which components/connections are causing the issue.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.