#!/usr/bin/env python3 from svg_schematic import (Schematic, Amp, Box, Capacitor, Converter, Dot, Ground, Inductor, Label, MOS, Pin, Resistor, Switch, Wire, shift, shift_x, shift_y, with_x, with_y, midpoint) from inform import Error, error, os_error 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')
from svg_schematic import Schematic, Label, Wire, shift_x, shift_y from inform import Error, error, os_error try: with Schematic(filename='label.svg'): Wire([(0, -25), (0, 225)], color='cyan') l = Label(kind='plain', name='plain', loc='se', w=3) Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) l = Label(kind='arrow', name='arrow', C=l.C, yoff=50, loc='se', w=3) Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) l = Label(kind='arrow|', name='arrow|', C=l.C, yoff=50, loc='se', w=3) Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) l = Label(kind='slash', name='slash', C=l.C, yoff=50, loc='se', w=3) Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) l = Label(kind='dot', name='dot', C=l.C, yoff=50, loc='se', w=3) Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) except Error as e: e.report() except OSError as e: error(os_error(e))
from svg_schematic import Schematic, Box, Wire, Label, shift_x, shift_y with Schematic(filename='network-map.svg', line_width=2): # work network work = Box(w=6.5, h=4.5, stroke_dasharray="4 2") Label(C=work.SW, loc='ne', name='work') bastion = Box(S=work.S, yoff=-25, w=5.5, h=2, color='lightgray') Wire([bastion.E, shift_x(bastion.E, 75)]) Label(C=bastion.SW, loc='ne', name='bastion') www = Box(NE=bastion.N, off=(-12.5, 25), w=2, h=1, color='white', name='www') mail = Box(NW=bastion.N, off=(12.5, 25), w=2, h=1, color='white', name='mail') dump = Box(SW=bastion.NW, yoff=-25, w=2.5, h=1, name='dump') laptop = Box(SE=bastion.NE, yoff=-25, w=2.5, h=1, name='my laptop', stroke_dasharray="2 2") # home network home = Box(N=work.S, yoff=50, w=6.5, h=2, stroke_dasharray="4 2")
# Generates schematic as an .svg file. # Requires svg_schematic: # git clone https://github.com/KenKundert/svg_schematic.git # cd svg-schematic # python3 setup.py --user --upgrade install from svg_schematic import (Schematic, shift, shift_x, shift_y, midpoint, Box, Ground, Label, Source, Wire) with Schematic(filename="msnm.svg"): v = Source(kind='noise', value='S(f)', orient='v') Ground(C=v.n, orient='v') m = Source(C=shift_x(v.p, 200), kind='mult') Wire([v.p, m.W]) wm = Wire([m.S, shift_y(m.S, 25)]) Label(C=wm.e, loc='S', name='m(t)') Label(C=midpoint(v.p, m.W), loc='N', name='stationary noise') wo = Wire([m.E, shift_x(m.E, 210)]) Label(C=wo.e, kind='arrow', loc='NW', name='cyclostationary noise') Box(C=shift(v.C, 100, -3), w=5.5, h=3.2, line_width=0.5, background='none', stroke_dasharray="4 2")
from svg_schematic import Schematic, Pin, Wire, shift_x, shift_y from inform import Error, error, os_error try: with Schematic(filename='pin.svg'): Wire([(0, -25), (0, 175)], color='cyan') p = Pin(kind='none', name='none', value='none value', w=5) Wire([shift_x(p.C, -50), shift_x(p.C, 50)]) p = Pin(kind='dot', name='dot', C=p.C, yoff=50, value='dot value', w=5) Wire([shift_x(p.C, -50), shift_x(p.C, 50)]) Wire([shift_y(p.C, -25), shift_y(p.C, 25)]) p = Pin(kind='in', name='in', C=p.C, yoff=50, w=5) Wire([p.C, shift_x(p.C, 25)]) p = Pin(kind='out', name='out', C=p.C, yoff=50, w=5) Wire([p.C, shift_x(p.C, -50)]) except Error as e: e.report() except OSError as e: error(os_error(e))
off=(25, -62.5), w=10.5, h=4.5, background='lightgray') Label(C=s1.SE, loc='nw', name='Stage 1') adc = Box(W=i.t, off=(75, 100), name='2 bit', value='Flash') dac = Box(i=adc.o, xoff=50, name='2 bit', value='DAC') sh = Box(C=with_x(i.t, midpoint(adc.C, dac.C)), name='SAH') sum = Source(W=with_x(i.t, dac.E), xoff=25, kind='sum', orient='h|') Label(C=sum.W, loc='nw', name='+') Label(C=sum.S, loc='se', name='−') amp = Amp(i=sum.E, xoff=25, kind='se', name='4×') Wire([i.t, sh.i]) Wire([sh.o, sum.W]) Wire([sum.E, amp.i]) Wire([shift_x(i.t, 50), adc.i], kind='|-') Wire([adc.o, dac.i]) Wire([dac.o, sum.S], kind='-|') # Stages 2, 3, 4 s2 = Box(N=dac.S, off=(25, 75), name='Stage 2') s3 = Box(W=s2.E, xoff=50, name='Stage 3') s4 = Box(W=s3.E, xoff=50, name='4 bit', value='Flash') Wire([s2.o, s3.i]) Wire([s3.o, s4.i]) Wire([ amp.o, shift_x(amp.o, 50), shift(s1.SE, 25, 25), shift(s2.NW, -25, -25), shift_x(s2.W, -25),
#!/usr/bin/env python3 from svg_schematic import Schematic, Amp, Box, Label, Pin, Source, Wire, shift_x from inform import Error, error, os_error try: with Schematic( filename = "feedback.svg", font_size=16, font_family='serif' ): summer = Source(kind='sum') amp = Amp(W=summer.E, xoff=25, name='$a$', kind='se') fb = Box(C=amp.C, yoff=100, name='$f$', h=1, orient='|') Label(C=summer.W, name='$+$', loc='nw') Label(C=summer.S, name='$-$', loc='sw') i = Pin(C=summer.W, xoff=-50, name='in', kind='in') o = Pin(C=amp.E, xoff=50, name='out', kind='out') Wire([i.C, summer.W]) Wire([summer.E, amp.i]) Wire([amp.E, o.C]) Wire([shift_x(amp.E, 25), fb.i], kind='|-') Wire([summer.S, fb.W], kind='|-') except Error as e: e.report() except OSError as e: error(os_error(e))