Circuit_macros This is a set of macros for drawing electric circuits containing fundamental elements, amplifiers, transistors, and basic logic gates to include in TeX, LaTeX, or similar documents. Some tools for block diagrams are also included. The advantages and disadvantages of such a system are similar to those of TeX itself, which is macro-based, non-wysiwyg, and which uses ordinary character input. These macros evaluate to drawing commands in the pic language, which is very easy to learn and has a good power/complexity ratio. Because pic contains elements of a simple programming language, it is well-suited to line drawings that contain parametric or conditional components, or that require fine tuning, significant geometric calculations, or repetition, or that are naturally block structured or tree structured. Pic is not wysiwyg. Interpreters for the language are readily available, and some are free. Some alternatives to consider, according to taste and the graphics to be drawn, are wysiwyg drawing programs (but the results may be difficult to tune), packages using TeX or LaTeX macros (but harder to learn, of limited power, or for specialized diagrams), Metafont (good for diagrams up to moderate size) and circuit-design applications (but the graphics typically are not easily tuned or not of book quality). REQUIRED SOFTWARE: m4, gpic or equivalent, TeX, a driver recognizing tpic specials My preferred setup: m4, dpic (see below), LaTeX, PStricks, dvips, sometimes xfig Also possible: m4, dpic, LaTeX, mfpic or LaTeX eepic graphics USAGE: A source file, for example cct.m4, is processed as shown: m4 $HOME/lib/libcct.m4 cct.m4 | gpic -t > cct.tex The file cct.tex is then included in the LaTeX document, and the .dvi file printed using dvips. CHANGES: Version 4.1: Xfig prototype file included. Minor document changes. Fixed recursive call bug and blank line bug. Changed argument for dend macro. Better arrowheads in circuit elements. Version 4: Simplified library use. Added capabilities and flexibility to several devices, added _init macros, modified b_current. Updated font.m4, cosmetic changes to inductor. Made gamp, amp, opamp, integrator more robust. Deleted edel_ macro. Fixed elen_ bug in darrow.m4. Removed Capacitor, Inductor and others in favour of parameterized macros. Iron-core inductors. Re-worked use of arcs in basic elements for better robustness. Edited examples document and the manual. Version 3: Document changes, minor changes to dimension_, switch, ground, battery. Added flexibility for several elements. New diodes, Capacitor, transistors, hop, transformer. Experimental Metafont version of basic elements. Version 2.2: Replaced definitions of two-terminal elements with current arrow by an arrow-labelling macro. Version 2.1: one or two examples simplified, and logic gates added. Version 2: considerable added flexibility and robustness, bug fixes, a few new constructs, a manual, and a complex logic-gate example. INSTALLATION: 1. Change the definition of HOMELIB_ in each of the .m4 files to point to your $HOME/lib or other directory where the libraries are to be installed. 2. Copy libgen.m4, libcct.m4, gpic.m4, and optionally darrow.m4 and liblog.m4 into the installation directory. Gpic is part of the GNU groff distribution, the latest version of which is available by ftp from prep.ai.mit.edu in the directory pub/gnu, but there are mirror sites that archive these sources, and others that make executable files available. M4 is part of many (most?) Unix systems. A GNU version is available on prep.ai.mit.edu in pub/gnu. EXAMPLES: View or print the file examples.ps in the examples directory. The sources are also given, but should not necessarily be taken to represent the best practice, since there are often several ways to achieve the same diagram. File examples/mf/cct.mf is an experimental Metafont source for the basic elements, produced using the mfpic output of dpic. It may be of interest to persons who cannot otherwise implement the macros. To see the elements (assuming a typical installation), type `make testfont.ps' in the mf directory. File examples/xfig/xfiglib.fig is an experimental file of basic elements, produced by dpic, for importing into xfig 3.1. Translation between languages always involves a loss of information and idiom, but using a programming language to define the elements, together with interactive graphics to place them in a circuit, is efficient in some contexts. The elements should be custom-designed for this use, which has only partially been done in the sample file. The file is a prototype because many more elements could be included, and because some of the fancier possibilities such as colour and fill, not traditionally used in circuit diagrams, are not included. MANUALS: Print man.ps or man.dvi in the doc directory. A pic manual can be obtained by emailing to netlib@research.att.com with the message body `send 116 from research/cstr', or by ftp as ftp://netlib.att.com/netlib/att/cs/cstr/116.ps.Z. See also the man page that comes with gpic. COMMENTS: Inevitably, sets of macros such as included here will be modified to suit individual use and taste. They continue to evolve in my own library as I use them. No such collection can hope to include all possible circuit-related symbols. You will probably find yourself writing your own macros, possibly using these as a starting point. ELEMENTS: The circuit elements included here are summarized below. amp (single-input amplifier) battery (constant voltage source) bi_tr (bipolar NPN, PNP, right or left-hand transistor) capacitor (capacitor, straight or curved-plate) clabel (writes 3 symbols along centre of element current direction) consource (controlled source with optional current or voltage) d_fet (N or P channel right or left-hand depletion MOSFET) delay (delay symbol) dimen_ (parameter defining size of all elements) diode (semiconductor diode with variations) e_fet (N or P channel right or left-hand enhancement MOSFET) ebox (general box element) elen_ (default length of all elements) gamp (triangle amp without inputs) gap (two dots and a space) ground (ground symbol with or without stem) hop (non-touching conductor crossover) inductor (inductor with variations) integrator (single-input integrator) j_fet (N or P channel right or left-hand JFET) llabel (writes 3 symbols to the left of element current direction) b_current (draw and label branch current arrow for 2-terminal element) opamp (op-amp with + and - input reference points) resistor (ordinary resistor) rlabel (writes 3 symbols to the right of element current direction) source (source with variations) switch (SPST switch symbol) transformer (2-winding transformer) xtal (quartz crystal) L_unit (grid size for logic gates) AND_ht (AND and OR gate height in grid units) AND_wd (AND and OR gate width in grid units) BUF_ht (BUFFER gate height in grid units) BUF_wd (BUFFER gate width in grid units) N_diam (NOT circle diameter in grid units) rgrid_ (relative grid position in grid units) grid_ (absolute grid position in grid units) AND_gate (basic gates ... OR_gate BUFFER_gate NAND_gate NOR_gate XOR_gate NXOR_gate NOT_gate ) ...and other subsidiary macros. Also included is a library for drawing double lines and arrows (as in one of the examples). DPIC: Dpic is not included here you say? If you want to try the mfpic, PStricks, or xfig output provided by dpic, it can be obtained (perhaps temporarily) by ftp from sunee.uwaterloo.ca:pub/dpic. ------------------------------------------------------------------- You may copy or modify the files in this distribution, provided you include this README file and note the changes. You are free to use files resulting from the ordinary use of these macros as you wish. No guarantee whatsoever is given. Feel free to contact me with comments or questions. ------------------------------------------------------------------- Dwight Aplevich aplevich@uwaterloo.ca