#!/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))
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) 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([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]) nfet = MOS(g=gd.o, xoff=25, kind='n', orient='v') Wire([nfet.g, gd.o]) Wire([nfet.d, pfet.d], kind='|-') Ground(C=nfet.s) ind = Inductor(n=with_x(pfet.d, nfet.E), orient='h') Wire([pfet.d, ind.n]) cap = Capacitor(p=ind.p, orient='v') Ground(C=cap.n) out = Pin(C=ind.p, xoff=100, kind='out', name='out', w=2) out_wire = Wire([ind.p, out.C]) fb = shift_y(R1.n, 100) Rt = Resistor(n=with_x(fb, out_wire.m), orient='v') Rb = Resistor(p=with_x(fb, out_wire.m), orient='v') Wire([Rt.p, with_y(Rt.p, out.C)]) Ground(C=Rb.n)
#!/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))
# 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")
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]) Wire([with_x(vin.t, c1.C), c1.p]) Wire([with_x(vin.t, c2.C), c2.p]) Wire([with_x(vin.t, c3.C), c3.p]) Wire([with_x(vin.t, c4.C), c4.p]) Wire([with_x(vin.t, c5.C), c5.p]) Wire([p1.t, c1.n], kind='-|') Wire([p2.t, c2.n], kind='-|') co = Dot(C=with_x(p1.C, c2.C), color='white') # wire cross over
rf_amp2 = Amp(i=rf_amp1.o, xoff=25, kind='se', name='RF Amp2') Label(C=rf_amp2.S, loc='s', name='A<=20dB') Wire([rf_amp1.o, rf_amp2.i]) # RF mixer rf_mixer = Source(W=rf_amp2.o, xoff=25, kind='mult') Label(C=rf_mixer.N, loc='n', name='DSB') Wire([rf_amp2.o, rf_mixer.W]) # RF local oscillator rf_lo = Source(p=rf_mixer.S, yoff=50, kind='sine', name='fo=1230MHz', value='P=10dBm') Ground(t=rf_lo.n) Wire([rf_mixer.S, rf_lo.N]) # IF band-pass filter if_bpf = Box(i=rf_mixer.E, xoff=25, name='IF BPF') l = Label(C=if_bpf.S, loc='s', name='fc=190MHz') Label(C=l.S, name='BW=22MHz') Wire([rf_mixer.E, if_bpf.i]) # IF amplifier if_amp = Amp(i=if_bpf.o, xoff=25, name='IF Amp') Label(C=if_amp.S, loc='s', name='A=20dB') Wire([if_bpf.o, if_amp.i]) # IF mixer if_mixer = Source(W=if_amp.o, xoff=20, kind='mult')
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))
# 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) vout = Pin(t=inv.o, xoff=25, kind='out', name=r'$V_{\rm out}$', w=2) Wire([inv.o, vout.t]) Wire([inv.i, vin.t]) except Error as e: e.report() except OSError as e: