* Z:\home\khalils\Downloads\files\data\raw_asc\0d6bbf677ed1_CCCV_Battery_Charger.asc
* Generated by LTspice 26.0.1 for Windows.
* Constant Current Source (CC)
* Constant Voltage Supply (CV)
* 3.7 - 4.2V Threshold Detector (CC/CV Switching)
* 2.7V
* Direct compare using open loop gain (A) to swing output quicker and invert the signal (using Rail-to-Rail op-amp)
* Schmitt = LOW, CC current = ON
* Schmitt = HIGH, CV current = ON
* 3.7 - 4.2 V Triggers
* high power shunt resistor (I_battery)
* High when I_shunt <= 0.1C (~1.1 mA)
* Termination current sensing circuit
* Vcv = 4.2V
* Icc = 0.1C (1.1mA in this circuit)
* Termination = LOW, CV current = ON
* Low-side shunt removes common mode rejection ration (CMRR) with low tolerance resistors
* Library below included based on ModelFile attribute of instance XU5 (C:\users\khalils\AppData\Local\LTspice\lib\sym\PowerProducts\LT1117.asy)
* Library below included based on ModelFile attribute of instance XU1, XU2, XU4, XU3 (C:\users\khalils\AppData\Local\LTspice\lib\sym\OpAmps\UniversalOpAmp2.asy)
R13 N014 DAD_5V 4.7k
XU5 N017 N010 DAD_5V LT1117 ;pnba ADJ)OUT)IN
V2 VRef_3_9 0 3.9
VDAD+5 DAD_5V 0 5
R8 N008 0 .1
XU2 N005 N002 DAD_5V 0 V_schmitt level2 Avol=1Meg GBW=10Meg Slew=10Meg Ilimit=25m Rail=0 Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
Rb N003 0 1k
R3 0 N013 4.7k
R6 N016 V_termination 10k
VBattery V_battery 0 EXP(3.0 4.2 2m 5m 25m 0.005)
Roff N003 DAD_5V 220
Q3 N001 N001 DAD_5V 0 PNP
R5 N005 DAD_5V 850
R14 N014 0 100
XU1 N003 V_battery DAD_5V 0 N002 level2 Avol=1Meg GBW=10Meg Slew=10Meg Ilimit=25m Rail=0 Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
D2 N011 V_battery D
Q2 N012 N016 N013 0 NPN
R11 N008 N009 1k
Q4 N004 N001 DAD_5V 0 PNP
R1 N010 N017 1k
R9 N007 N006 100k
Ra N002 N003 3.9k
R7 0 N005 1k
R15 N015 V_schmitt 10k
R16 N011 N010 10k
Q1 N011 N015 N012 0 NPN
V3 N008 0 1m
D1 N004 V_battery D
R4 N001 V_schmitt 4k
R2 N017 0 2.2k
V1 VRef_4_15 0 4.15
R10 0 N009 100k
XU3 N009 N006 DAD_5V 0 N007 level2 Avol=1Meg GBW=10Meg Slew=10Meg Ilimit=25m Rail=0 Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
R12 0 N006 1k
XU4 N014 N007 DAD_5V 0 V_termination level2 Avol=1Meg GBW=10Meg Slew=10Meg Ilimit=25m Rail=0 Vos=0 En=0 Enk=0 In=0 Ink=0 Rin=500Meg ;pnba In+)In-)V+)V-)OUT
.model D D
.lib C:\users\khalils\AppData\Local\LTspice\lib\cmp\standard.dio
.model NPN NPN
.model PNP PNP
.lib C:\users\khalils\AppData\Local\LTspice\lib\cmp\standard.bjt
.tran 40m
.lib LT1117.lib
.lib UniversalOpAmp2.lib
.backanno
.end

* LTspice schematic (.asc):
Version 4
SHEET 1 4020 1620
WIRE -272 -32 -272 -64
WIRE -80 -32 -272 -32
WIRE 320 -32 -80 -32
WIRE 1264 -16 1168 -16
WIRE 1568 -16 1264 -16
WIRE 2064 -16 1568 -16
WIRE 2368 -16 2064 -16
WIRE -80 64 -80 -32
WIRE 320 64 320 -32
WIRE 128 112 -16 112
WIRE 256 112 128 112
WIRE 1568 144 1568 -16
WIRE 1536 160 1424 160
WIRE 2368 160 2368 -16
WIRE 1824 176 1600 176
WIRE 2336 176 1824 176
WIRE -80 192 -80 160
WIRE 128 192 128 112
WIRE 128 192 -80 192
WIRE 1536 192 1424 192
WIRE 2608 192 2400 192
WIRE 320 208 320 160
WIRE 752 208 320 208
WIRE 2336 208 2240 208
WIRE -80 224 -80 192
WIRE -928 240 -928 176
WIRE -736 240 -736 176
WIRE -528 240 -528 128
WIRE 1568 272 1568 208
WIRE 2368 272 2368 224
WIRE 2064 336 2064 -16
WIRE 2112 336 2064 336
WIRE 2240 336 2240 208
WIRE 2240 336 2192 336
WIRE -928 352 -928 320
WIRE -736 352 -736 320
WIRE -736 352 -928 352
WIRE -528 352 -528 320
WIRE -528 352 -736 352
WIRE -80 352 -80 304
WIRE 752 352 752 208
WIRE 752 368 752 352
WIRE 2240 368 2240 336
WIRE -528 384 -528 352
WIRE 1264 448 1264 -16
WIRE 1280 448 1264 448
WIRE 1424 448 1424 192
WIRE 1424 448 1360 448
WIRE 1504 448 1424 448
WIRE 1824 448 1824 176
WIRE 1824 448 1584 448
WIRE 2240 480 2240 448
WIRE 1424 496 1424 448
WIRE 752 560 752 416
WIRE 752 560 240 560
WIRE 1216 560 752 560
WIRE 240 608 240 560
WIRE 1216 720 1216 560
WIRE 1328 720 1216 720
WIRE 1424 720 1328 720
WIRE 2192 736 2112 736
WIRE 2352 736 2272 736
WIRE 1664 896 1424 896
WIRE 2112 896 2112 736
WIRE 2112 896 1920 896
WIRE 1424 928 1424 896
WIRE 2240 944 2240 896
WIRE 2112 960 2112 896
WIRE 2208 960 2112 960
WIRE 2672 960 2672 928
WIRE 2352 976 2352 736
WIRE 2352 976 2272 976
WIRE 2640 976 2352 976
WIRE 2208 992 2112 992
WIRE 2880 992 2704 992
WIRE -272 1008 -272 -32
WIRE -208 1008 -272 1008
WIRE 96 1008 48 1008
WIRE 128 1008 96 1008
WIRE 240 1008 240 672
WIRE 240 1008 208 1008
WIRE 320 1008 240 1008
WIRE 544 1008 416 1008
WIRE 864 1008 640 1008
WIRE 2640 1008 2576 1008
WIRE 2672 1040 2672 1024
WIRE 1424 1056 1424 1008
WIRE 1520 1056 1424 1056
WIRE 1664 1056 1840 896
WIRE 1664 1056 1520 1056
WIRE 1840 1056 1664 896
WIRE 2112 1056 2112 992
WIRE 2112 1056 1920 1056
WIRE 2240 1072 2240 1008
WIRE 2432 1072 2400 1072
WIRE 2576 1072 2576 1008
WIRE 2576 1072 2512 1072
WIRE 1328 1088 1328 720
WIRE 1360 1088 1328 1088
WIRE 1424 1088 1360 1088
WIRE 2576 1104 2576 1072
WIRE 1424 1120 1424 1088
WIRE 96 1184 96 1008
WIRE 368 1184 368 1072
WIRE 592 1184 592 1072
WIRE 2112 1200 2112 1056
WIRE 2576 1232 2576 1184
WIRE 1424 1248 1424 1200
WIRE -80 1296 -80 1104
WIRE 96 1296 96 1264
WIRE 96 1296 -80 1296
WIRE 368 1312 368 1264
WIRE 592 1312 592 1264
WIRE 2112 1312 2112 1280
WIRE 96 1328 96 1296
WIRE 96 1440 96 1408
SYMBOL voltage -528 224 R0
SYMATTR InstName DAD+5
SYMATTR Value 5
SYMBOL OpAmps\\UniversalOpamp2 1568 176 R0
SYMATTR InstName U1
SYMBOL voltage 1424 1104 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName Battery
SYMATTR Value EXP(3.0 4.2 2m 5m 25m 0.005)
SYMBOL res 2128 1296 R180
WINDOW 0 36 76 Left 2
WINDOW 3 36 40 Left 2
SYMATTR InstName R10
SYMATTR Value 100k
SYMBOL res 1824 912 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 0 56 VBottom 2
SYMATTR InstName R12
SYMATTR Value 1k
SYMBOL npn 320 1072 R270
SYMATTR InstName Q1
SYMBOL OpAmps\\UniversalOpamp2 2240 976 R0
SYMATTR InstName U3
SYMBOL res 1376 432 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName Roff
SYMATTR Value 220
SYMBOL res 80 1312 R0
SYMATTR InstName R2
SYMATTR Value 2.2k
SYMBOL res 2224 464 M180
WINDOW 0 36 76 Left 2
WINDOW 3 36 40 Left 2
SYMATTR InstName R7
SYMATTR Value 1k
SYMBOL res 2208 320 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R5
SYMATTR Value 850
SYMBOL res 80 1168 R0
SYMATTR InstName R1
SYMATTR Value 1k
SYMBOL res -96 208 R0
SYMATTR InstName R4
SYMATTR Value 4k
SYMBOL res 352 1168 R0
SYMATTR InstName R15
SYMATTR Value 10k
SYMBOL res 2560 1088 R0
SYMATTR InstName R14
SYMATTR Value 100
SYMBOL diode 256 672 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D2
SYMBOL pnp 256 160 M180
SYMATTR InstName Q4
SYMBOL res 576 1168 R0
SYMATTR InstName R6
SYMATTR Value 10k
SYMBOL res 1408 912 R0
SYMATTR InstName R8
SYMATTR Value .1
SYMBOL res 1600 432 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName Ra
SYMATTR Value 3.9k
SYMBOL OpAmps\\UniversalOpamp2 2368 192 R0
SYMATTR InstName U2
SYMBOL diode 736 352 R0
SYMATTR InstName D1
SYMBOL OpAmps\\UniversalOpamp2 2672 992 R0
SYMATTR InstName U4
SYMBOL voltage -736 224 R0
SYMATTR InstName V1
SYMATTR Value 4.15
SYMBOL npn 544 1072 R270
SYMATTR InstName Q2
SYMBOL res 1408 480 R0
SYMATTR InstName Rb
SYMATTR Value 1k
SYMBOL voltage 1424 912 R180
WINDOW 0 24 96 Left 2
WINDOW 3 24 16 Left 2
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V3
SYMATTR Value 1m
SYMBOL res 1824 1072 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 0 56 VBottom 2
SYMATTR InstName R11
SYMATTR Value 1k
SYMBOL pnp -16 160 R180
SYMATTR InstName Q3
SYMBOL PowerProducts\\LT1117 -80 1008 R0
SYMATTR InstName U5
SYMBOL res 2528 1056 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R13
SYMATTR Value 4.7k
SYMBOL voltage -928 224 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName V2
SYMATTR Value 3.9
SYMBOL res 2288 720 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R9
SYMATTR Value 100k
SYMBOL res 960 992 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R3
SYMATTR Value 4.7k
SYMBOL res 224 992 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R16
SYMATTR Value 10k
FLAG -528 384 0
FLAG 1568 272 0
FLAG 1424 576 0
FLAG -528 128 DAD_5V
FLAG -272 -64 DAD_5V
FLAG -80 352 V_schmitt
FLAG 1424 160 V_battery
FLAG 1168 -16 DAD_5V
FLAG 2608 192 V_schmitt
FLAG 2368 272 0
FLAG 2240 480 0
FLAG 368 1312 V_schmitt
FLAG -736 176 VRef_4_15
FLAG -928 176 VRef_3_9
FLAG 2112 1312 0
FLAG 2400 1072 DAD_5V
FLAG 2576 1232 0
FLAG 2672 1040 0
FLAG 2672 928 DAD_5V
FLAG 96 1440 0
FLAG 592 1312 V_termination
FLAG 1424 1248 0
FLAG 2240 1072 0
FLAG 2240 896 DAD_5V
FLAG 1360 1088 V_battery
FLAG 1424 816 0
FLAG 1520 1056 0
FLAG 2880 992 V_termination
FLAG 944 1008 0
TEXT -512 -144 Left 2 !.tran 40m
TEXT -56 -80 Left 2 ;Constant Current Source (CC)
TEXT -208 864 Left 2 ;Constant Voltage Supply (CV)
TEXT 1216 -64 Left 2 ;3.7 - 4.2V Threshold Detector (CC/CV Switching)
TEXT 2176 224 Left 2 ;2.7V
TEXT 1872 -64 Left 2 ;Direct compare using open loop gain (A) to swing output quicker and invert the signal (using Rail-to-Rail op-amp)
TEXT -16 272 Left 2 ;Schmitt = LOW, CC current = ON
TEXT 384 1136 Left 2 ;Schmitt = HIGH, CV current = ON
TEXT 1432 360 Left 2 ;3.7 - 4.2 V Triggers
TEXT 1432 1024 Left 2 ;high power shunt resistor (I_battery)
TEXT 2600 1072 Left 2 ;High when I_shunt <= 0.1C (~1.1 mA)
TEXT 1608 640 Left 2 ;Termination current sensing circuit
TEXT 824 952 Left 2 ;Vcv = 4.2V
TEXT 824 328 Left 2 ;Icc = 0.1C (1.1mA in this circuit)
TEXT 608 1296 Left 2 ;Termination = LOW, CV current = ON
TEXT 1608 672 Left 2 ;Low-side shunt removes common mode rejection ration (CMRR) with low tolerance resistors