ASCII Circuits

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

Reply to
Jonathan Kirwan
Loading thread data ...

Thanks, Terry. I have created PNG files from LTSpice before, but it's a series of somewhat unfamiliar steps for me and I appreciate your help.

I was surprised just how easy the code was to imagine and then write, by the way. I didn't know anything about the details of the .ASC files (I have posted a question about that in the LTSpice Yahoo group), but after looking at them I decided it was sufficiently understandable without documentation that I could make a first-shot attempt.

The first thing I noticed were the WIRE lines in the file and the numbers used. I knew that LTSpice probably used an abstract drawing surface for its positioning (anyone doing Windows coding has been there and done that) and that these numbers probably represented these positions. Four numbers meant to me, at a guess, start and end points in (x y) format, so I went with that. I also assumed the numbers in positions 1 and 3 would be left-right x and that those in position 2 and 4 would be up-down y. I assumed (0,0) would be upper-left, at first. Then I saw some negative values. But I still retained the idea that it was positive-down and positive-right orientation, which appears to have been correct.

Next thing was to imagine how to translate the wiring into ASCII character positions. It seemed obvious to try and use a GCD computation to find the GCD for all the wiring end points and use that to then "shrink" the numbers to adjacent positions needed in the ASCII output. This seems to have worked out really well. The schematics I've tried have their wiring tapped on the course grid of LTSpice, which I believe is every 16 points on the abstract plane. I have also looked into the .ASY files, just for kicks, and found that there are often sub-16 in their positioning. For example, on the 8's in places. If I were to try and simulate the .ASY representations, I can easily see that this may greatly increase the overall spread of the ASCII schematic (for example, just going from x16 to x8 would double the width and double the height.) So, my plan is to simply hard-code (or, perhaps, define a file format that can be easily edited) the .ASY equivalents for *known* parts. In other words, I think it would be better to supply new .ASY equivalents for each ASCII part. There are only four rotations to worry about and each of these may be mirrored, for a total of 8 images needed for each ASCII part. The common ones can be quickly defined, leaving specialty stuff for those with an interest and inclination, I suppose.

The wiring system works by dividing up each ASCII character into four walls arranged like:

. T . | | L ----- + ----- R | | . B .

In this way, I have left side, right side, bottom side, and top side walls with a (+) dot in the middle, which may be dotted or not. Any WIRE I draw places a DOT at the two end-points. It also draws the L&R or T&B walls through any ASCII cell as it draws, without DOT'ing them. The starting and ending cells get only one or the other wall, though. In the end, this provides a maximum of 32 possible permutations, but only a little more than half of those are legal ones. The code then just decides what to emit as ASCII for each one.

I also reserve a bit to tell me if the cell is storing a specific ASCII character rather than all these walls/dots. In that case, it overrides. That way, I can place text and the like. The rest was dead easy, once I'd conceptualized this in mind.

Anyway, that's my strategy.

Jon

Reply to
Jonathan Kirwan

Thanks. In case anyone else who wants to try playing with an ASCII version of it doesn't have SWCADIII, here's a screenshot of how it loads here:

formatting link

--
Terry Pinnell
Hobbyist, West Sussex, UK
Reply to
Terry Pinnell

Robert C Monsen schrieb:

Added Zener Diode, and made some changes so the components are now "american-style"

Added a selectbox which can be moved, copied or deleted. test it. greetings Andy

Reply to
Andreas Weber

Jonathan Kirwan schrieb:

is

did some work on the redraw procedure, should be very better now. added move/select/delete in a selectbox

you can also try the IMPORT feature in AACircuit v1.26 when released

Reply to
Andreas Weber

Randy Day schrieb:

Improved the symbol editor, just take a look Thanks for the component.ini, they look "american ISO" MfG Andy

Reply to
Andreas Weber

Very cool! I'll try it out today. Thanks.

Bob Monsen

Reply to
Robert Monsen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.