On Fri, 10 Sep 2004 08:31:07 +0100, Terry Pinnell wrote:
Hehe. Well, keep in mind that it's a DOS based command line program, accepting a file name and just dumping to 'stdout.' But I'll put something out there as soon as I think it's sufficiently useful in a general way and the code, too, once I get it organized a little better so that others have a chance with it. I compiled it with VC 1.52C. It's surprisingly short C code, though. Just a few hundred lines.
The original .ASC follows. It was NOT designed for any kind of demonstration here, so it has .param and the like on it. But I'll include the file for examination. In the above diagram, I still hadn't gotten around to adding Q1's stuff (BJTs), so that's missing there. But I've got another version adding that, now.
Anyway, here's the file:
Version 4 SHEET 1 1792 828 WIRE 672 480 672 512 WIRE 672 400 672 384 WIRE 144 80 144 48 WIRE 128 384 128 416 WIRE 128 256 128 304 WIRE 144 176 144 160 WIRE 672 176 672 208 WIRE 672 96 672 64 WIRE 336 400 336 384 WIRE 336 208 336 304 WIRE 336 480 336 512 WIRE 336 96 336 128 WIRE 672 208 752 208 WIRE 672 208 672 256 WIRE 240 256 128 256 WIRE 800 480 800 512 WIRE 800 576 800 608 WIRE 672 368 800 368 WIRE 672 368 672 352 WIRE 800 368 800 400 WIRE 496 304 560 304 WIRE 416 304 336 304 WIRE 560 384 672 384 WIRE 672 384 672 368 WIRE 496 384 336 384 WIRE 336 384 336 304 WIRE 304 256 560 256 WIRE 560 256 560 304 WIRE 560 304 608 304 FLAG 144 48 Vcc FLAG 672 64 Vcc FLAG 128 416 0 FLAG 336 96 Vcc FLAG 672 512 0 FLAG 336 512 0 FLAG 144 176 0 FLAG 752 208 Vc IOPIN 752 208 Out FLAG 800 608 0 SYMBOL npn2 608 256 R0 SYMATTR InstName Q1 SYMATTR Value 2N2222 SYMBOL res 656 384 R0 SYMATTR InstName R1 SYMATTR Value {Ve/Iq} SYMBOL voltage 144 64 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName V1 SYMATTR Value {Vbat} SYMBOL voltage 128 288 R0 WINDOW 123 24 132 Left 0 WINDOW 39 0 0 Left 0 SYMATTR Value2 AC .02 0 SYMATTR InstName V2 SYMATTR Value SINE(0 .1 5000) SYMBOL res 656 80 R0 SYMATTR InstName R2 SYMATTR Value {Vbat/(2*Iq)} SYMBOL res 320 112 R0 SYMATTR InstName R3 SYMATTR Value {10*Ve/Iq} SYMBOL res 320 384 R0 SYMATTR InstName R4 SYMATTR Value {(10*Ve/Iq)/(Vbat/(Ve+Vbe)-1)} SYMBOL cap 304 240 R90 WINDOW 0 0 32 VBottom 0 WINDOW 3 32 32 VTop 0 SYMATTR InstName C1 SYMATTR Value 10µ SYMBOL res 784 384 R0 SYMATTR InstName R5 SYMATTR Value {(Ve/Iq)*((Vbat/(2*G)-Vtemp)/(Ve-Vbat/(2*G)+Vtemp))} SYMBOL cap 784 512 R0 SYMATTR InstName C2 SYMATTR Value {(2*Iq*G)/(6.2832*f*(2*G*Vtemp+Vbat))} SYMBOL res 512 288 R90 WINDOW 0 0 56 VBottom 0 WINDOW 3 32 56 VTop 0 SYMATTR InstName R6 SYMATTR Value 150k SYMBOL cap 560 368 R90 WINDOW 0 0 32 VBottom 0 WINDOW 3 32 32 VTop 0 SYMATTR InstName C3 SYMATTR Value .033µ TEXT 1030 122 Left 0 !.tran 0 .05 0 1000n TEXT 1032 168 Left 0 !.param Iq=200uA TEXT 1032 200 Left 0 !.param Vbat=9V TEXT 1032 232 Left 0 !.param G=20 TEXT 1032 264 Left 0 !.param f=100Hz TEXT 1032 296 Left 0 !.param Ve=1V TEXT 1032 328 Left 0 !.param Vbe=0.767V TEXT 1032 360 Left 0 !.param Vtemp=25.3mV