0
\$\begingroup\$

Please see the following LTspice schematic:

enter image description here

This is an excitation circuit for a fluxgate current sensor. The inductor L1 models the magnetic core's B-H loop and dimension along with a sensing winding of 10 turns. The DRV8837 is a H-bridge driver, it is used to run forward and reverse direction currents through the sensing coil in order to drive the magnetic core into saturation in both direction repeatedly for excitation. When current reaches ~30mA, the core is deep in saturation so the direction of current should be reversed. This is done by the TL07XH_TL08XH amplifiying the voltage drop on resistor RSHUNT 20 times, so that it outputs 2.5V(offset) + 0.6V when there is +30mA on the sensing coil and 2.5V - 0.6V at -30mA. The LMV331 with feedback and biasing resistors creates an inverting comparator with hysteresis, with VOH = 3.1V and VOL = 1.9V. Its output and its output's complement are then used to control the H bridge driver.

This circuit is not behaving as expected in LTspice simulations. Especially at node ph+ (output of comparator), voltage settles at 2.5V after just one rising and falling edge: enter image description here

Current on excitation winding is at constant 2A: enter image description here

Initial waveforms at VOA, ph+ and REF, which then all settle to constant value: enter image description here


Same circuit with some LTspice built in models from Analog Devices, and the circuit simulation gives expected result:

enter image description here

Current waveform on the inductor L1. Peaks aren't exactly at 30mA (Why is this? The postive peak is pretty far away from 30mA at 42mA), but the waveform is same as expected.: enter image description here

ph+, REF and VOA waveforms: enter image description here

It could be that the TL07XH and/or the LMV331 are not usable for this particular circuit, but I could not see any specification that does not meet the criterion. I am also not sure if it's an good idea to use an H bridge motor driver (DRV8837) for an application like this, but it's cheap considering it integrates the MOSFETS as well, and it has built in dead time so there is no need for dead time insertion circuit.

Although this question is related to LTspice, but any general advice on this circuit would be very helpful!

\$\endgroup\$
4
  • \$\begingroup\$ Did you set Vhigh for component A1? \$\endgroup\$
    – Ste Kulov
    Commented May 12, 2023 at 18:38
  • \$\begingroup\$ @SteKulov Yes, I did, Vhigh = 5V for A1 \$\endgroup\$
    – Zhi
    Commented May 13, 2023 at 13:50
  • \$\begingroup\$ Do you get any behavior change if you change A1 to a buf, run the comparator output into it, and then run both outputs of the buf into the DRV8837? \$\endgroup\$
    – Ste Kulov
    Commented May 13, 2023 at 17:47
  • \$\begingroup\$ @SteKulov I changed it, but it is still the same. I think there might be some kind of compatibility issue when using PSpice models in LTspice. I simulated the same circuit with a more suitable op-amp in TINA-TI spice, and it shows expected behavior. \$\endgroup\$
    – Zhi
    Commented May 15, 2023 at 9:35

1 Answer 1

1
\$\begingroup\$

When asking a question like this, it's good practice to include links to the actual third-party SPICE models you are using instead of assuming anyone who tries it will coincidentally download the same ones and duplicate your exact issue. For example, I used these SPICE models when duplicating your circuit and it seems to work without an issue. I had to redraw your circuit too because it was horribly confusing to follow.

DRV8837 --> https://www.ti.com/lit/zip/slvm958

TL07XH --> https://www.ti.com/lit/zip/slom513

LMV331 --> https://www.ti.com/lit/zip/snom073

enter image description here

enter image description here

If I had to guess, the LMV331 model above might be different than the one you tried.


LTspice schematic contents as-text are pasted below. Save it as a .asc file to open it in LTspice. Keep in mind the three .lib files and DRV8837 symbol aren't included so they need to be provided on your end in the same way or edited to match how it is on your machine.

Version 4
SHEET 1 1344 680
WIRE 336 -352 336 -384
WIRE 416 -352 336 -352
WIRE 416 -336 416 -352
WIRE -208 -256 -208 -288
WIRE -96 -256 -96 -288
WIRE 336 -240 336 -352
WIRE 336 -240 304 -240
WIRE 416 -240 416 -272
WIRE 416 -240 384 -240
WIRE 160 -224 96 -224
WIRE 384 -208 384 -240
WIRE 384 -208 304 -208
WIRE 416 -208 416 -240
WIRE 160 -192 96 -192
WIRE 464 -176 304 -176
WIRE 656 -176 656 -256
WIRE 656 -176 544 -176
WIRE 688 -176 656 -176
WIRE 800 -176 800 -256
WIRE 800 -176 768 -176
WIRE 832 -176 800 -176
WIRE 160 -160 96 -160
WIRE -208 -144 -208 -176
WIRE -96 -144 -96 -176
WIRE 336 -144 304 -144
WIRE 336 -48 336 -144
WIRE 832 -48 832 -176
WIRE 832 -48 336 -48
WIRE -176 64 -224 64
WIRE -48 64 -96 64
WIRE 0 64 -48 64
WIRE 128 64 80 64
WIRE 880 128 880 96
WIRE 512 176 512 144
WIRE -48 192 -48 64
WIRE 0 192 -48 192
WIRE 128 208 128 64
WIRE 128 208 64 208
WIRE 240 208 128 208
WIRE -176 224 -224 224
WIRE -48 224 -96 224
WIRE 0 224 -48 224
WIRE 720 240 688 240
WIRE 1152 240 1104 240
WIRE 880 256 880 208
WIRE 880 256 784 256
WIRE 960 256 880 256
WIRE 1040 256 960 256
WIRE -48 272 -48 224
WIRE 512 272 512 256
WIRE 608 272 512 272
WIRE 656 272 608 272
WIRE 720 272 656 272
WIRE 1152 272 1104 272
WIRE 512 288 512 272
WIRE 656 368 656 272
WIRE 720 368 656 368
WIRE 880 368 880 256
WIRE 880 368 800 368
WIRE -48 400 -48 352
WIRE 512 400 512 368
FLAG -208 -144 0
FLAG -96 -144 0
FLAG -208 -288 +5V
FLAG -96 -288 +2.5V
FLAG 32 176 +5V
FLAG 752 224 +5V
FLAG 32 240 0
FLAG 752 288 0
FLAG -48 400 +2.5V
FLAG -224 224 VR1+
FLAG -224 64 VR1-
FLAG 240 208 VOA
FLAG 688 240 VOA
FLAG 512 144 +5V
FLAG 512 400 0
FLAG 880 96 +5V
FLAG 416 -208 0
FLAG 336 -384 +5V
FLAG 656 -256 VR1+
FLAG 800 -256 VR1-
FLAG 96 -160 +5V
FLAG 96 -224 ph+
FLAG 96 -192 ph-
FLAG 960 256 comp_out
FLAG 1152 240 ph+
FLAG 1152 272 ph-
FLAG 608 272 ref
SYMBOL Opamps\\opamp2 32 144 R0
WINDOW 3 29 97 Left 2
SYMATTR InstName U1
SYMATTR Value tl07xh_tl08xh
SYMBOL Opamps\\opamp2 752 192 R0
WINDOW 3 28 96 Left 2
SYMATTR InstName U2
SYMATTR Value LMV331
SYMBOL AutoGenerated\\DRV8837 224 -192 R0
SYMATTR InstName U3
SYMBOL ind2 448 -160 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 5 56 VBottom 2
WINDOW 39 -73 54 VTop 2
WINDOW 123 -48 64 VTop 2
WINDOW 40 -98 56 VTop 2
SYMATTR InstName L1
SYMATTR Value Lg=0 N=10
SYMATTR Type ind
SYMATTR SpiceLine A=50u Lm=0.070686
SYMATTR Value2 Hc=0.2771 Bs=0.581 Br=0.561
SYMATTR SpiceLine2 Rser=1
SYMBOL voltage -208 -272 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V1
SYMATTR Value 5
SYMBOL voltage -96 -272 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V2
SYMATTR Value 2.5
SYMBOL res 96 48 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 200k
SYMBOL res -64 256 R0
SYMATTR InstName R2
SYMATTR Value 200k
SYMBOL res -80 208 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R3
SYMATTR Value 10k
SYMBOL res -80 48 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R4
SYMATTR Value 10k
SYMBOL res 816 352 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R7
SYMATTR Value 158k
SYMBOL res 496 160 R0
SYMATTR InstName R5
SYMATTR Value 100k
SYMBOL res 496 272 R0
SYMATTR InstName R6
SYMATTR Value 100k
SYMBOL res 864 112 R0
SYMATTR InstName R8
SYMATTR Value 1k
SYMBOL cap 400 -336 R0
SYMATTR InstName C1
SYMATTR Value 10µ
SYMBOL res 784 -192 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R9
SYMATTR Value 1
SYMBOL Digital\\buf 1040 192 R0
WINDOW 3 -73 125 Left 2
SYMATTR InstName A1
SYMATTR Value Vhigh=5 Vlow=0 td=1n tau=1n
TEXT 128 512 Left 2 !.lib tl07xh_tl08xh.lib
TEXT 128 552 Left 2 !.lib drv8837.lib
TEXT 128 592 Left 2 !.lib LMV331.LIB
TEXT -260 548 Left 2 !.tran 10m startup
\$\endgroup\$
14
  • 1
    \$\begingroup\$ Thank you for actually recreating the circuit. I used the LMV331 model in the link you provided and was able to get the hysteresis comparator to work, just like shown in your graphs. Then I also realized that The TL07XH is not a current sense amplfier nor is rail-to-rail, therefore it is not suitable for current sensing on RSHUNT. This might explain the strange behavior shown in the first post. Therefore I tried with a current sense amplifier INA181, and was able to get the simulation to show expected results. \$\endgroup\$
    – Zhi
    Commented May 16, 2023 at 12:21
  • 1
    \$\begingroup\$ @Zhi I added my schematic as text so you can "download" it if necessary. \$\endgroup\$
    – Ste Kulov
    Commented May 16, 2023 at 16:43
  • 1
    \$\begingroup\$ I looked up a tutorial on how to convert TINA-TI spice models to Pspice models, which could be done by opening it with TINA-TI spice and exporting it as Pspice model and that's what I've done. If that's backporting then yes. \$\endgroup\$
    – Zhi
    Commented May 18, 2023 at 16:08
  • 1
    \$\begingroup\$ @Zhi Gotcha. In the future, it'll be a good idea to include those details in the question and also post the export as a code block so someone can duplicate without having to download and install additional software. Not many people (especially LTspice users) have TINA-TI installed since it is known to have issues. Also, for what it's worth, I think there's a reason why TI doesn't post the model encapsulated within the TINA macro as a separate PSpice model. They probably couldn't get it to run properly on native PSpice without any significant tweaking. \$\endgroup\$
    – Ste Kulov
    Commented May 18, 2023 at 16:41
  • 1
    \$\begingroup\$ @Zhi No, that's not what I meant. I meant that models are only tested/validated on certain platforms. And not just the platform itself, but a specific version of a specific platform. A TINA-TI model has the capability to run on many SPICE platforms, but models are like code and if you don't write the code with cross-compatibility in mind it might not work on another platform. It's just like web browsers. Websites should work on all browsers, but certain web developers are too lazy or don't have the resources to test on anything except Chrome, so several sites don't run properly on my Firefox. \$\endgroup\$
    – Ste Kulov
    Commented May 19, 2023 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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