Пример #1
0
 def DrawNE555(self):
     d = schemdraw.Drawing()
     IC555def = elm.Ic(pins=[
         elm.IcPin(name='TRG', side='left', pin='2'),
         elm.IcPin(name='THR', side='left', pin='6'),
         elm.IcPin(name='DIS', side='left', pin='7'),
         elm.IcPin(name='CTL', side='right', pin='5'),
         elm.IcPin(name='OUT', side='right', pin='3'),
         elm.IcPin(name='RST', side='top', pin='4'),
         elm.IcPin(name='Vcc', side='top', pin='8'),
         elm.IcPin(name='GND', side='bot', pin='1'),
     ],
                       edgepadW=.5,
                       edgepadH=1,
                       pinspacing=2,
                       leadlen=1,
                       label='555')
     T = d.add(IC555def)
     BOT = d.add(elm.Ground(xy=T.GND))
     d.add(elm.Dot)
     d.add(elm.Resistor(endpts=[T.DIS, T.THR], label='Rb'))
     d.add(elm.Resistor('u', xy=T.DIS, label='Ra', rgtlabel='+Vcc'))
     d.add(elm.Line(endpts=[T.THR, T.TRG]))
     d.add(
         elm.Capacitor('d',
                       xy=T.TRG,
                       toy=BOT.start,
                       label='C',
                       l=d.unit / 2))
     d.add(elm.Line('r', tox=BOT.start))
     d.add(elm.Capacitor('d', xy=T.CTL, toy=BOT.start,
                         botlabel='.01$\mu$F'))
     d.add(elm.Dot(xy=T.DIS))
     d.add(elm.Dot(xy=T.THR))
     d.add(elm.Dot(xy=T.TRG))
     d.add(elm.Line(endpts=[T.RST, T.Vcc]))
     d.add(elm.Dot)
     d.add(elm.Line('u', l=d.unit / 4, rgtlabel='+Vcc'))
     d.add(elm.Resistor('r', xy=T.OUT, label='330'))
     d.add(elm.LED(flip=True, d='down', toy=BOT.start))
     d.add(elm.Line('l', tox=BOT.start))
     return FigureCanvas(d.draw(show=False).getfig())
Пример #2
0
 def __init__(self):
     wx.Frame.__init__(self, None)
     p = wx.Panel(self)
     fgs = wx.FlexGridSizer(cols=1)
     d = schemdraw.Drawing()
     d.add(elm.Resistor())
     d.add(elm.SourceV())
     data = d.get_imagedata('png')
     stream = BytesIO(data)
     img = wx.ImageFromStream(stream)
     sb = wx.StaticBitmap(p, -1, wx.BitmapFromImage(img))
     fgs.Add(sb)
     p.SetSizerAndFit(fgs)
     self.Fit()
Пример #3
0
 def __init__(self):
     QWidget.__init__(self)
     self.layout = QGridLayout(self)
     # # self.imgwidget = QLabel(self)
     # Plot RC filter
     rc = schemdraw.Drawing()
     rc.add(elm.Resistor(d='right', label='R', lftlabel='In', rgtlabel='Out'))
     rc.add(elm.Capacitor(d='down', label='C'))
     rc.add(elm.Ground(d='right'))
     rc.draw(show=False)
     rccanvas = FigureCanvas(rc.draw(show=False).getfig())
     self.layout.addWidget(rccanvas,0,0,2,1)
     self.layout.setMargin(0)
     self.layout.setSpacing(0)
     self.InputWidget=Opreator()
     self.layout.addWidget(self.InputWidget)
Пример #4
0
def Save_Schematic(circuit, voltages, currents, file_name):

    
    d = schemdraw.Drawing()
    elements = {}
    elements["0"] = d.add(elm.Ground)
    drawn = []
    directions = ["up", "right", "down", "left"]
    direc = 0
    for key, node in circuit.nodes.items():
        if key != "0":
            for i, branch in enumerate(node.branches):
                if branch not in drawn:
                    pos, neg = branch.pos_node, branch.neg_node
                    el = None
                    i = int(key) - 1
                    if branch.element_type == "R":                        
                        el = elm.Resistor(directions[direc], lblofst = 1,
                                          label="Ω={z.real:+0.02f} {z.imag:+0.02f}j\nV={v.real:+0.02f} {v.imag:+0.02f}j"
                                                 .format(z=branch.impedance, v=voltages[i]),
                                          to = elements[neg].start if neg in elements else None)
                    else:
                        el = elm.SourceV(label="V = {}".format(str(branch.voltage)))
                    d.add(el)
                    other_node = neg if key == pos else pos
                    new_node = None
                    if key not in elements:
                        new_node = key
                    elif other_node not in elements:
                        new_node = other_node
                    if new_node is not None:
                        label = "Node {}\nI=".format(new_node)
                        c = currents[int(new_node) - 1]
                        label += "{c.real:+0.02f} {c.imag:+0.02f}j".format(c=c) if isinstance(c, complex) else "V-source"
                        if  directions[direc] in ("up", "bottom"):
                            elements[new_node] =  d.add(elm.Dot(lblofst = 1, lftlabel=label))
                        else:
                            elements[new_node] =  d.add(elm.Dot(lblofst = 1, botlabel=label))
                        
                    if neg == "0" and i == len(node.branches) - 1:
                        d.add(elm.Ground)
                    drawn.append(branch)
            direc = (direc + 1) % 4

    #d.draw()
    d.save('schematics/{}.png'.format(file_name.split("\\")[-1]))
Пример #5
0
	def __init__(self,app):
	
		# App configs:
		self._app = app
	
		# Init the panel:
		wx.Panel.__init__(self, app.frame_main.tabs)
		
		# Add a dummy text label:
		box = wx.BoxSizer(wx.VERTICAL)
		lbl = wx.StaticText(self,-1,style = wx.ALIGN_CENTER)
		lbl.SetLabel("This tab\n is for\n setup of the\n DUT limits\n and connections\n and optional temperature setting.\n\n\n BUTTON to load DUT config file")
		box.Add(lbl,0,wx.ALIGN_CENTER)

		# Add a dummy circuit / symbol:
		self._circuit = schemdraw.Drawing()
		self._circuit.draw(backend='svg')
		self._circuit += elm.Resistor().label('100KΩ')

		logging.debug('Need to figure out how to add the circuit symobol to the wx panel...')
Пример #6
0
def draw(l,port="z11",rs=0,rl=oo):
    #example
    #l=[{type:"r",label:2,dirrection:"right",parallel:False]},{type:"l",label:100,dirrection:"down",parallel:True},{type:"c",label:56,dirrection:"right",parallel:True}] 
    with plt.xkcd():
        d ,F= schemdraw.Drawing(inches_per_unit=.5),0
        if port=='z11':
            a0=d.add(elm.Resistor(d='right', label=str(rs)+'$\Omega$',color="red")) 
        if port=='y22':
            a0=d.add(elm.Resistor(d='up', label=str(rl)+'$\Omega$',color="red"))
            d.add(elm.Line(d="right"))     
        for q in l:
            try:
                if q["label"]==int(q["label"]):
                    q["label"]=int(q["label"])
            except:
                pass        
            if q["dirrection"]=="down" and  q["parallel"]: 
                F=F+1  
                if F<2:
                    d.add(elm.Line(d='right'))
                    d.push()  
            elif q["dirrection"]=="down":
                d.push()
            elif q["parallel"] :
                F=F+1  
                if F<2:
                    d.push()          
            if q["type"]=="r":
                d.add(elm.Resistor(d=q["dirrection"], label=str(q["label"])+'$\Omega$'))
            elif q["type"]=="l":
                d.add(elm.Inductor(d=q["dirrection"], label=str(q["label"])+"H"))
            elif q["type"]=="c":
                d.add(elm.Capacitor(d=q["dirrection"], label=str(q["label"])+'$\mu$F')) 
            elif q["type"]=="w":    
                d.add(elm.Line(d=q["dirrection"]))
            if q["dirrection"]=="down" and  q["parallel"]:              
                if F<2:
                    pass
                else:
                    d.pop()
                    F=0    
            elif q["dirrection"]=="right" and  q["parallel"]:   
                if F<2:
                    d.pop()
                    d.add(elm.Line(d='down'))  
                else:
                    d.add(elm.Line(d='up'))
                    F=0                      
            elif q["dirrection"]=="down": 
                d.add(elm.Line(d='down')) 
                d.pop()
        d.add(elm.Line(d='right'))
        if port=='z11':
            d.add(elm.Resistor(d='down', label=str(rl)+'$\Omega$',color="red")) 
            d.add(elm.Line(d='down'))
            d.add(elm.Line('left', tox=a0.start)) 
            d.add(elm.SourceSin(d='up', label='10V')) 
            d.add(elm.Line(d='up'))
        if port=='y22':
            d.add(elm.Resistor(d='right', label=str(rs)+'$\Omega$',color="red")) 
            d.add(elm.SourceSin(d='down', label='10V')) 
            d.add(elm.Line(d='down'))
            d.add(elm.Line('left', tox=a0.start)) 
            d.add(elm.Line(d='up'))  
        d.draw()
Пример #7
0
''' Test for using schemdraw in a script with interactive pyplot window  '''
import schemdraw
import schemdraw.elements as elm

d = schemdraw.Drawing()
d.add(elm.Resistor(label='1K'))
d.add(elm.Capacitor('d'))

d2 = schemdraw.Drawing()
d2.add(elm.Diode(fill=True))

d2.draw()
d.draw()

Пример #8
0
import schemdraw
import schemdraw.elements as elm

d = schemdraw.Drawing()
V = d.add(elm.Vdd(label='3.3V'))
S = d.add(elm.Button(d='down', label='S'))
d.push()
R1 = d.add(elm.Resistor(d='left', label='R1'))
P = d.add(elm.Tag(d='left', label='GPIO'))
d.pop()
R2 = d.add(elm.Resistor(d='down', label='R2'))
G = d.add(elm.Ground)

d.save('schem-input.svg')

d = schemdraw.Drawing()
V = d.add(elm.Vdd(label='3.3V'))
S = d.add(elm.Button(d='down', label='S'))
R1 = d.add(elm.Resistor(d='left', label='R1'))
P = d.add(elm.Tag(d='left', label='GPIO'))

d.save('schem-floating.svg')

Пример #9
0
# Draw circuit
# https://schemdraw.readthedocs.io/en/latest/index.html
import schemdraw
import schemdraw.elements as elm

#Circuit normal
d = schemdraw.Drawing()
d.add(elm.Line)
d.push()
d.add(elm.Capacitor(d='down', label='$C_0$'))
d.add(elm.Line(d='left'))
d.add(elm.SourceSin(d='up', reverse=True, l=1.5))
d.add(elm.Resistor(d='up', l=1.5, label='$Z_s$'))
d.pop()
d.add(elm.RBox(d='right', label='$R_s$'))
d.add(elm.Inductor(d='down', botlabel='$L$', l=2))
d.add(elm.Capacitor(label='$C_j$', l=1))
d.add(elm.Line(d='left'))

d.draw()
d.save('normal.svg')

#Circuit SD
d = schemdraw.Drawing()
d.add(elm.Line)
d.push()
d.add(elm.Capacitor(d='down', label='$C_0$'))
d.add(elm.Line(d='left'))
d.add(elm.SourceSin(d='up', reverse=True, l=1.5))
d.add(elm.Resistor(d='up', l=1.5, label='$Z_s$'))
d.pop()
Пример #10
0
# pip install schemdraw
# (^ requires python 3.8)

# conda install -c conda-forge pyspice

# draw the schematic

import schemdraw
import schemdraw.elements as elm

d = schemdraw.Drawing()
d.add(elm.Dot().label('evaporator').color('red'))
Reex = d.add(elm.Resistor().down().label('Re,ex'))
d.add(elm.Dot().label('1', loc='left').color('red'))
Rew = d.add(elm.Resistor().down().label('Re,w'))
d.add(elm.Dot().label('2', loc='left').color('red'))
d.add(elm.Resistor().down().label('Re,wk').color('orange'))
d.add(elm.Dot().label('3', loc='left').color('red'))
d.add(elm.Resistor().down().label('Re,inter').color('blue'))
d.add(elm.Dot().label('4', loc='left').color('red'))
d.add(elm.Resistor().right().label('Rv').color('blue'))
d.add(elm.Dot().label('5', loc='bottom').color('red'))
d.add(elm.Resistor().up().label('Rc,inter', loc='bottom').color('blue'))
d.add(elm.Dot().label('6', loc='right').color('red'))
d.add(elm.Resistor().up().label('Rc,wk', loc='bottom').color('orange'))
d.add(elm.Dot().label('7', loc='right').color('red'))
Rcw = d.add(elm.Resistor().up().label('Rc,w', loc='bottom'))
d.add(elm.Dot().label('8', loc='right').color('red'))
Rcex = d.add(elm.Resistor().up().label('Rc,ex', loc='bottom'))
d.add(elm.Dot().label('condensor').color('red'))