Tuesday, 30 December 2014

How to fix this LTspice error


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?



Answer




@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=), 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

No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...