from quantiphy import Quantity from math import pi except ImportError: print('Run `pip install --user -r requirements.txt`', 'to install missing packages.') raise SystemExit Quantity.set_prefs(map_sf=Quantity.map_sf_to_greek, prec=2) globals().update(Quantity.extract(__doc__, predefined={'π': pi})) try: with Schematic(filename='mfed.svg', line_width=2, background='none'): vin = Source(name='Vin', value='1 V', kind='sine') Ground(C=vin.n) rs = Resistor(name='Rs', value=Rref, n=vin.p, xoff=25) Wire([vin.p, rs.n]) c1 = Capacitor(name='C1', value=C1, p=rs.p, xoff=25) Ground(C=c1.n) l2 = Inductor(name='L2', value=L2, n=c1.p, xoff=25) Wire([rs.p, l2.n]) c3 = Capacitor(name='C3', value=C3, p=l2.p, xoff=25) Ground(C=c3.n) l4 = Inductor(name='L4', value=L4, n=c3.p, xoff=25) Wire([l2.p, l4.n]) c5 = Capacitor(name='C5', value=C5, p=l4.p, xoff=25) Ground(C=c5.n) rl = Resistor(name='Rl', value=Rref, p=c5.p, xoff=100, orient='v') Ground(C=rl.n) out = Pin(name='out', C=rl.p, xoff=50, w=2) Wire([l4.p, out.t])
from svg_schematic import Schematic, Label, Resistor, Wire, with_x from inform import Error, error, os_error try: with Schematic( filename='wires.svg', background='none', line_width=2, ): r11 = Resistor(orient='h') r12 = Resistor(orient='h', n=r11.p, off=(50, 50)) w = Wire([r11.p, r12.n], kind='plain') c = with_x(w.m, r12.E) Label(name="kind='plain'", C=c, xoff=25, loc='e', w=5) r21 = Resistor(orient='h', C=r11.C, yoff=100) r22 = Resistor(orient='h', n=r21.p, off=(50, 50)) w = Wire([r21.p, r22.n], kind='|-') c = with_x(w.m, r22.E) Label(name="kind='|-'", C=c, xoff=25, loc='e', w=5) r31 = Resistor(orient='h', C=r21.C, yoff=100) r32 = Resistor(orient='h', n=r31.p, off=(50, 50)) w = Wire([r31.p, r32.n], kind='-|') c = with_x(w.m, r32.E) Label(name="kind='-|'", C=c, xoff=25, loc='e', w=5) r41 = Resistor(orient='h', C=r31.C, yoff=100) r42 = Resistor(orient='h', n=r41.p, off=(50, 50)) w = Wire([r41.p, r42.n], kind='|-|') c = with_x(w.m, r42.E)
#!/usr/bin/env python3 from svg_schematic import (Schematic, Amp, Dot, Ground, Label, Pin, Resistor, Source, Wire) from inform import Error, error, os_error try: with Schematic(filename="noninverting.svg", line_width=2): vin = Source(kind='sine') Label(C=vin.p, name='Vin', loc='n') Ground(C=vin.n) amp = Amp(pi=vin.p, xoff=100, kind='oa') Label(C=amp.ni, xoff=-25, name='Vf', loc='n') Wire([vin.p, amp.pi]) out = Pin(C=amp.o, xoff=50, name='out', w=2) Wire([amp.o, out.C]) oj = Dot(C=amp.o, xoff=25) r1 = Resistor(p=amp.ni, off=(-25, 50), name='R1', orient='v') Wire([r1.N, amp.ni], kind='|-') r2 = Resistor(C=amp.C, yoff=75, name='R2') Wire([r1.p, r2.W], kind='|-') Wire([oj.C, r2.E], kind='|-') fj = Dot(C=r2.W, xoff=-25) Ground(C=r1.n) except Error as e: e.report() except OSError as e: error(os_error(e))
#!/usr/bin/env python3 from svg_schematic import (Schematic, Amp, Dot, Ground, Label, Pin, Resistor, Source, Wire) from inform import Error, error, os_error try: with Schematic(filename="inverting.svg", font_size=16, font_family='serif'): vin = Pin(kind='in', name='in', w=1.5) vout = Pin(C=vin.C, xoff=350, kind='out', name='out', w=2) Wire([vin.C, vout.C]) rin = Resistor(W=vin.C, xoff=25, name='Rin') vg = Dot(C=rin.E, xoff=25) rfb = Resistor(W=vg.C, xoff=25, name='Rfb') oj = Dot(C=rfb.E, xoff=25) amp = Amp(C=rfb.C, yoff=75, orient='-', kind='oa') Wire([oj.C, amp.o], kind='|-') gnd = Ground(C=amp.pi, xoff=-25, orient='h|') Wire([gnd.C, amp.pi]) Wire([vg.C, amp.ni], kind='|-') Label(C=vg.C, name='Vg', loc='sw') except Error as e: e.report() except OSError as e: error(os_error(e))
from svg_schematic import Schematic, Resistor, Capacitor, Inductor, Wire, shift_y from inform import Error, error, os_error try: with Schematic(filename="rlc.svg"): r = Resistor(name='R', orient='v') c = Capacitor(C=r.C, xoff=100, name='C', orient='v') l = Inductor(C=c.C, xoff=100, name='L', orient='v|') Wire([r.p, c.p, l.p], kind='-|-') Wire([r.n, c.n, l.n], kind='-|-') with Schematic(filename="rlc1a.svg"): r = Resistor(name='R', orient='v') c = Capacitor(W=r.E, name='C', orient='v') l = Inductor(W=c.E, name='L', orient='v|') Wire([r.p, c.p, l.p], kind='-|-') Wire([r.n, c.n, l.n], kind='-|-') with Schematic(filename="rlc1b.svg"): r = Resistor(name='R', orient='h') c = Capacitor(n=r.p, name='C', orient='h|') l = Inductor(n=c.p, name='L', orient='h') with Schematic(filename="rlc2.svg"): r = Resistor(name='R', orient='v') c = Capacitor(C=r.C, off=(100, 25), name='C', orient='v') l = Inductor(C=c.C, xoff=100, name='L', orient='v|') Wire([r.p, c.p, l.p], kind='-|-') Wire([r.n, c.n, l.n], kind='-|-') with Schematic(filename="rlc3.svg"):
try: with Schematic(filename="buck.svg", line_width=2, background='none'): pvdd = Pin(kind='in', name='pvdd', w=2) avdd = Pin(C=pvdd.C, yoff=50, kind='in', name='avdd', w=2) Wire([avdd.C, shift_x(avdd.C, 50)]) lvl = Pin(C=avdd.C, yoff=90, kind='in', name='lvl', w=2) reference = Converter(i=lvl.C, xoff=75, name='ref') lvl2ref = Wire([lvl.C, reference.i]) Label(C=lvl2ref.m, kind='slash', name='6', loc='se') amp = Amp(pi=reference.o, xoff=50, kind='oa', name='amp') Wire([reference.o, amp.pi]) C1 = Capacitor(p=amp.C, off=(-12.5, 75), orient='h') R1 = Resistor(p=C1.p, xoff=12.5, orient='h') C2 = Capacitor(C=midpoint(R1.C, C1.C), yoff=50, orient='h') Wire([C1.n, with_y(C1.n, amp.o)], kind='-|') Wire([R1.n, amp.ni], kind='|-') Wire([C2.p, R1.n], kind='-|') Wire([C2.n, C1.n], kind='-|') cmp = Amp(pi=amp.o, xoff=125, kind='comp', name='cmp') Wire([amp.o, cmp.pi]) gd = Box(i=cmp.o, xoff=50, name='gate', value='drivers') Wire([cmp.o, gd.i]) pfet = MOS(g=gd.N, yoff=-50, kind='p', orient='h') Wire([pfet.g, gd.N]) Wire([pfet.s, pvdd.C])
from svg_schematic import Schematic, Resistor, Label from inform import Error, error, os_error try: with Schematic(filename='resistor.svg'): r = Resistor(name='Rs', value='50Ω') Label(C=r.p, name='p', loc='e', kind='dot', color='blue') Label(C=r.n, name='n', loc='w', kind='dot', color='blue') except Error as e: e.report() except OSError as e: error(os_error(e))
from svg_schematic import Schematic, Resistor, Box, Label from inform import Error, error, os_error try: with Schematic( filename='tile1.svg', background='none', ): b = Box(w=2, h=2, background='lightgray') r = Resistor(C=b.C) Label(C=r.C, name='C', loc='s', kind='dot', color='blue', w=2) Label(C=r.N, name='N', loc='n', kind='dot', color='blue', w=2) Label(C=r.NE, name='NE', loc='ne', kind='dot', color='blue', w=2) Label(C=r.E, name='E', loc='e', kind='dot', color='blue', w=2) Label(C=r.SE, name='SE', loc='se', kind='dot', color='blue', w=2) Label(C=r.S, name='S', loc='s', kind='dot', color='blue', w=2) Label(C=r.SW, name='SW', loc='sw', kind='dot', color='blue', w=2) Label(C=r.W, name='W', loc='w', kind='dot', color='blue', w=2) Label(C=r.NW, name='NW', loc='nw', kind='dot', color='blue', w=2) b = Box(C=b.C, xoff=200, w=2, h=2, background='lightgray') r = Resistor(C=b.C, orient='v') Label(C=r.C, name='C', loc='e', kind='dot', color='blue', w=2) Label(C=r.N, name='N', loc='n', kind='dot', color='blue', w=2) Label(C=r.NE, name='NE', loc='ne', kind='dot', color='blue', w=2) Label(C=r.E, name='E', loc='e', kind='dot', color='blue', w=2) Label(C=r.SE, name='SE', loc='se', kind='dot', color='blue', w=2) Label(C=r.S, name='S', loc='s', kind='dot', color='blue', w=2) Label(C=r.SW, name='SW', loc='sw', kind='dot', color='blue', w=2) Label(C=r.W, name='W', loc='w', kind='dot', color='blue', w=2) Label(C=r.NW, name='NW', loc='nw', kind='dot', color='blue', w=2)