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)
from svg_schematic import Schematic, Diode, Label from inform import Error, error, os_error try: with Schematic(filename='diode.svg'): d = Diode(name='D1') Label(C=d.c, name='c', loc='e', kind='dot', color='blue') Label(C=d.a, name='a', 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, Source, Label from inform import Error, error, os_error try: with Schematic(filename = 'source.svg'): s = Source(kind='empty', name='Ve') Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) s = Source(kind='vdc', name='Vd', C=s.C, xoff=150) Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) s = Source(kind='idc', name='Id', C=s.C, xoff=150) Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) s = Source(kind='sine', name='Vs', C=s.C, xoff=150) Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) s = Source(kind='sum', name='S', yoff=150) Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) s = Source(kind='mult', name='M', C=s.C, xoff=150) Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) s = Source(kind='cv', name='Vc', C=s.C, xoff=150) Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2)
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))
#!/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, 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")
from svg_schematic import Schematic, BJT, Label from inform import Error, error, os_error try: with Schematic(filename='bjt.svg'): q = BJT(kind='npn', name='Qn') Label(C=q.c, name='c', loc='n', kind='dot', color='blue') Label(C=q.b, name='b', loc='w', kind='dot', color='blue') Label(C=q.e, name='e', loc='s', kind='dot', color='blue') q = BJT(kind='pnp', name='Qp', C=q.C, xoff=150) Label(C=q.e, name='e', loc='n', kind='dot', color='blue') Label(C=q.b, name='b', loc='w', kind='dot', color='blue') Label(C=q.c, name='c', loc='s', kind='dot', color='blue') except Error as e: e.report() except OSError as e: error(os_error(e))
from svg_schematic import Schematic, Ground, Label from inform import Error, error, os_error try: with Schematic(filename = 'ground.svg'): g = Ground() Label(C=g.t, name='t', loc='n', kind='dot', color='blue') # Label(C=g.N, name='N', loc='n', kind='dot', color='blue') # Label(C=g.NE, name='NE', loc='ne', kind='dot', color='blue') # Label(C=g.E, name='E', loc='e', kind='dot', color='blue') # Label(C=g.SE, name='SE', loc='se', kind='dot', color='blue') # Label(C=g.S, name='S', loc='s', kind='dot', color='blue') # Label(C=g.SW, name='SW', loc='sw', kind='dot', color='blue') # Label(C=g.W, name='W', loc='w', kind='dot', color='blue') # Label(C=g.NW, name='NW', loc='nw', kind='dot', color='blue') except Error as e: e.report() except OSError as e: error(os_error(e))
Amp, Box, Label, Pin, Source, Wire, midpoint, shift_x, shift, with_x, with_y, ) from inform import Error, error, os_error try: with Schematic(filename='pipeline-adc.svg', line_width=2): # Stage 1 i = Pin(kind='in', name='in') s1 = Box(NW=i.t, 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='−')
from svg_schematic import Schematic, Capacitor, Label from inform import Error, error, os_error try: with Schematic(filename='capacitor.svg'): c = Capacitor(name='C1', value='1.2pF') Label(C=c.p, name='p', loc='n', kind='dot', color='blue') Label(C=c.n, name='n', loc='s', kind='dot', color='blue') except Error as e: e.report() except OSError as e: error(os_error(e))
from svg_schematic import Schematic, BJT, Label from inform import Error, error, os_error try: with Schematic( filename = 'orient.svg', background = 'none', ): q11 = BJT(orient='v') l11 = Label(N=q11.S, name="orient='v'") q12 = BJT(W=q11.E, xoff=50, orient='v|') l12 = Label(N=q12.S, name="orient='v|'") q13 = BJT(W=q12.E, xoff=50, orient='v-') l13 = Label(N=q13.S, name="orient='v-'") q14 = BJT(W=q13.E, xoff=50, orient='v|-') l14 = Label(N=q14.S, name="orient='v|-'") q21 = BJT(N=l11.S, yoff=25, orient='h') l21 = Label(N=q21.S, name="orient='h'") q22 = BJT(N=l12.S, yoff=25, orient='h|') l22 = Label(N=q22.S, name="orient='h|'") q23 = BJT(N=l13.S, yoff=25, orient='h-') l23 = Label(N=q23.S, name="orient='h-'") q24 = BJT(N=l14.S, yoff=25, orient='h|-') l24 = Label(N=q24.S, name="orient='h|-'") except Error as e: e.report() except OSError as e: error(os_error(e))
from svg_schematic import ( Schematic, Capacitor, MOS, Inductor, Label, Source, Wire, midpoint, shift, shift_y, ) from inform import Error, error, os_error try: with Schematic(filename="oscillator.svg", background='none', line_width=2): # resonator vdd = Label(loc='n', nudge=10, name=r'$V_{\rm dd}$') Wire([vdd.C, shift_y(vdd.C, 25)]) ll = Inductor(p=shift(vdd.C, -125, 25), orient='v', name=r'$\frac{1}{2} L$') lr = Inductor(p=shift(vdd.C, 125, 25), orient='v|', name=r'$\frac{1}{2} L$') c = Capacitor(C=midpoint(ll.n, lr.n), orient='h', name='$C$') Wire([ll.p, lr.p]) Wire([ll.n, c.p]) Wire([lr.n, c.n])
from svg_schematic import Schematic, Inductor, Label from inform import Error, error, os_error try: with Schematic(filename='inductor.svg'): l = Inductor(name='L1', value='1μH') Label(C=l.p, name='p', loc='e', kind='dot', color='blue') Label(C=l.n, name='n', loc='w', kind='dot', color='blue') except Error as e: e.report() except OSError as e: error(os_error(e))
#!/usr/bin/env python3 from svg_schematic import Schematic, MOS, Ground, Gate, Label, Pin, Wire, midpoint from inform import Error, error, os_error try: with Schematic(filename='inverter.svg', line_width=2, background='none'): # transistor version mp = MOS(kind='p') mn = MOS(N=mp.S, kind='n') vin = Pin(C=midpoint(mp.g, mn.g), xoff=-50, kind='in', name=r'$V_{\rm in}$', w=2) vout = Pin(C=midpoint(mp.d, mn.d), xoff=50, kind='out', name=r'$V_{\rm out}$', w=2) Label(C=mp.s, loc='n', name=r'$V_{\rm dd}$') Ground(C=mn.s) Wire([vin.t, mp.g], kind='-|') Wire([vin.t, mn.g], kind='-|') Wire([vout.t, mp.d], kind='-|') Wire([vout.t, mn.d], kind='-|') # gate version inv = Gate(N=mn.S, yoff=25, kind='inv') vin = Pin(t=inv.i, xoff=-25, kind='in', name=r'$V_{\rm in}$', w=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")
#!/usr/bin/env python3 from svg_schematic import (Schematic, shift_x, shift_y, Amp, Box, Ground, Label, Pin, Source, Wire) with Schematic( filename='receiver.svg', font_size=12, font_family='sans', outline='none', pad=20, line_width=2, ) as schematic: # Input from horn antenna rf_in = Pin(kind='in', name='L-band Horn', w=3) Label(C=rf_in.C, yoff=15, loc='w', name='fc=1420MHz', w=3.5, nudge=14) Label(C=rf_in.C, yoff=30, loc='w', name='BW=15MHz', w=3.5, nudge=14) # First preamp rf_preamp1 = Amp(i=rf_in.t, xoff=25, kind='se', name='RF Preamp1') Label(C=rf_preamp1.S, loc='s', name='A>=26dB') Wire([rf_in.t, rf_preamp1.i]) # Second preamp rf_preamp2 = Amp(i=rf_preamp1.o, xoff=25, kind='se', name='RF Preamp2') Label(C=rf_preamp2.S, loc='s', name='A>=26dB') Wire([rf_preamp1.o, rf_preamp2.i]) # RF band-pass filter rf_bpf = Box(i=rf_preamp2.o, xoff=25, name='RF BPF')
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', ): 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) Label(name="kind='|-|'", C=c, xoff=25, loc='e', w=5)
from svg_schematic import Schematic, Switch, Label from inform import Error, error, os_error try: with Schematic(filename='switch.svg'): s = Switch(kind='spst', name='φ₁') Label(C=s.i, name='i', loc='w', kind='dot', color='blue', w=2) Label(C=s.ot, name='ot', loc='e', kind='dot', color='blue', w=2) Label(C=s.o, name='o', loc='e', kind='dot', color='blue', w=2) Label(C=s.ob, name='ob', loc='e', kind='dot', color='blue', w=2) s = Switch(kind='spdt', name='φ₂', C=s.C, xoff=150) Label(C=s.i, name='i', loc='w', kind='dot', color='blue', w=2) Label(C=s.ot, name='ot', loc='e', kind='dot', color='blue', w=2) Label(C=s.o, name='o', loc='e', kind='dot', color='blue', w=2) Label(C=s.ob, name='ob', loc='e', kind='dot', color='blue', w=2) except Error as e: e.report() except OSError as e: error(os_error(e))
#!/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, Amp, Converter, Label from inform import Error, error, os_error try: with Schematic(filename='amp.svg'): origin = (0, 0) a = Amp(C=origin, kind='se', name='As') Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) a = Amp(kind='oa', name='Ao', C=a.C, xoff=200) Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) a = Amp(kind='da', name='Ad', C=a.C, xoff=200) Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) a = Amp(kind='comp', name='Ac', C=a.C, xoff=200)
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"):
#!/usr/bin/env python3 from svg_schematic import Schematic, Capacitor, Diode, Ground, Pin, Wire, Dot, with_x from inform import Error, error, os_error try: with Schematic( filename = "charge-pump.svg", line_width=2, background='none'): vin = Pin(kind='in', name=r'$V_{\rm in}$', w=2) p1 = Pin(C=vin.C, yoff=150, kind='in', name=r'$\phi_1$', w=2) p2 = Pin(C=p1.C, yoff=50, kind='in', name=r'$\phi_2$', w=2) d1 = Diode(a=vin.C, xoff=25, orient='h') c1 = Capacitor(p=d1.c, off=(25, 25), orient='v') d2 = Diode(a=d1.c, xoff=50, orient='h') c2 = Capacitor(p=d2.c, off=(25, 25), orient='v') d3 = Diode(a=d2.c, xoff=50, orient='h') c3 = Capacitor(p=d3.c, off=(25, 25), orient='v') d4 = Diode(a=d3.c, xoff=50, orient='h') c4 = Capacitor(p=d4.c, off=(25, 25), orient='v') d5 = Diode(a=d4.c, xoff=50, orient='h') c5 = Capacitor(p=d5.c, off=(25, 25), orient='v') vout = Pin(C=d5.c, xoff=75, kind='out', name=r'$V_{\rm out}$', w=2) Ground(t=c5.n) Wire([vin.t, d1.a]) Wire([d1.c, d2.a]) Wire([d2.c, d3.a]) Wire([d3.c, d4.a]) Wire([d4.c, d5.a]) Wire([d5.c, vout.t])
from svg_schematic import Schematic, MOS, Label from inform import Error, error, os_error try: with Schematic(filename='mos.svg'): m = MOS(kind='n', name='Mn') Label(C=m.d, name='d', loc='n', kind='dot', color='blue') Label(C=m.g, name='g', loc='w', kind='dot', color='blue') Label(C=m.s, name='s', loc='s', kind='dot', color='blue') m = MOS(kind='p', name='Mp', C=m.C, xoff=150) Label(C=m.s, name='s', loc='n', kind='dot', color='blue') Label(C=m.g, name='g', loc='w', kind='dot', color='blue') Label(C=m.d, name='d', loc='s', kind='dot', color='blue') m = MOS(kind='', name='M', C=m.C, xoff=150) Label(C=m.d, name='d', loc='n', kind='dot', color='blue') Label(C=m.g, name='g', loc='w', kind='dot', color='blue') Label(C=m.s, name='s', loc='s', kind='dot', color='blue') except Error as e: e.report() except OSError as e: error(os_error(e))
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))
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)
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))
#!/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 = "noninverting.svg"): 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='Ve', 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))
try: from svg_schematic import (Schematic, Capacitor, Dot, Ground, Inductor, Label, Resistor, Pin, Source, Wire) from inform import Error, error, os_error 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)
from svg_schematic import ( Schematic, Capacitor, Ground, Inductor, Resistor, Pin, Source, Wire ) from inform import Error, error, os_error try: with Schematic( filename = 'mfed.svg', background = 'none', ): vin = Source(name='Vin', value='1 V', kind='sine') Ground(C=vin.n) rs = Resistor(name='Rs', value='50 Ω', n=vin.p, xoff=25) Wire([vin.p, rs.n]) c1 = Capacitor(name='C1', value='864 pF', p=rs.p, xoff=25) Ground(C=c1.n) l2 = Inductor(name='L2', value='5.12 μH', n=c1.p, xoff=25) Wire([rs.p, l2.n]) c3 = Capacitor(name='C3', value='2.83 nF', p=l2.p, xoff=25) Ground(C=c3.n) l4 = Inductor(name='L4', value='8.78 μH', n=c3.p, xoff=25) Wire([l2.p, l4.n]) c5 = Capacitor(name='C5', value='7.28 nF', p=l4.p, xoff=25) Ground(C=c5.n) rl = Resistor(name='Rl', value='50 Ω', 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]) except Error as e: e.report() except OSError as e: