{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import schemdraw\n",
"from schemdraw import elements as elm"
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAHEAAABVCAYAAAB+QwvwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFWklEQVR4nO2dbYgVVRjHf8+uu1KJqbW0ltYWIbGUkVgE9cHFsDKzD0F9aYkg+qAg9EGCCqN33Iwg8kP0whKSSAWBuBhFBhJBUtGuayClwi66roa9mW2+PH2Y57LjZe/dcebOvXdOzw8Os3PmmfM8Z/73zJk5Z2ZWVBWn2LQ0OgAnOy5iALiIAeAiBoCLGAAuYgC4iAHgItYAEekXEbV0WkTGRWSXiKwVkTazaRORjSIyKCInReSIiHwoIldn9e8i1o4vgPlAF7AC2A48D+wWkUuAi4ElwMu2fABYCOwUkRlZHIuP2GRHRPqBy1V1VVn+jcD3wKuq+twU+3UDw8BiVR1K699bYo6o6l5gJ/BgBZPZtjyRxY+LmD/7gOvKM0WkHXgd2K6qo1kcZDoXO4kQ4Lw+y/rALcAcYHVWBy5i/nQDB0orJuBW4CZgmar+mtWBn05zxC5s7gE+tvU2YBuwGOhR1bFa+PGWWDtmikgnUcPoAJYDTwPfAZusBX4E3ArcD6jZA/yuqqfSOvZbjBpgtxiP2upZ4DdgL/AJ8Laq/isiXcDBCkU8pqr9qf27iMXH+8QAcBEDwEUMABcxAFzEAHARA8BFDAAXMQBcxABIJKKI7Ig9Q5ImjeddkWbGnrlJc9x2JCm/Xi2xo05+mpVc65/72KmIKICqSq6Ompi8j4H3iQHgIgaAixgALmIAuIgB4CIGgIsYAC5iALiIAeAiBoCLGACFegJcRNYCtwODwJClw/o/f3i2UCIC1wCPlOW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ORK5CYII=\n",
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
"<__main__.DiodeOptocoupler at 0x7ff215993c70>"
]
},
"execution_count": 123,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"class DiodeOptocoupler(schemdraw.elements.compound.ElementCompound):\n",
" def __init__(self, *args, **kwargs):\n",
" unit = 1.5\n",
" super().__init__(*args, unit=unit, **kwargs)\n",
"\n",
" box = kwargs.get('box', True)\n",
" boxfill = kwargs.get('boxfill', False)\n",
" bpad = kwargs.get('boxpad', .2)\n",
" label1, label2 = kwargs.get('label1'), kwargs.get('label2')\n",
" rev1, rev2 = kwargs.get('reverse1', False), kwargs.get('reverse2', False)\n",
"\n",
" D1 = self.add(elm.Diode(d='down', reverse=rev1))\n",
" D2 = self.add(elm.Diode(d='down', reverse=rev2, at=[2, 0]))\n",
" if label1:\n",
" self.segments.append(schemdraw.segments.SegmentText(D1.start + (0, 0.5), label1))\n",
" if label2:\n",
" self.segments.append(schemdraw.segments.SegmentText(D2.start + (0, 0.5), label2))\n",
" \n",
" self.add(elm.Arrow('r', at=[.6, -unit/2 + .2], l=.4, headwidth=.15, headlength=.4))\n",
" self.add(elm.Arrow('r', at=[.6, -unit/2 - .2], l=.4, headwidth=.15, headlength=.4))\n",
"\n",
" bbox = self.get_bbox()\n",
" if box:\n",
" self.add(elm.Rect(\n",
" 'r', at=[0, 0],\n",
" corner1=[bbox.xmin-bpad, bbox.ymin-bpad],\n",
" corner2=[bbox.xmax+bpad, bbox.ymax+bpad],\n",
" fill=boxfill, zorder=0))\n",
"\n",
" A = self.add(elm.Line('r', at=D2.start, l=bpad*2))\n",
" B = self.add(elm.Line('r', at=D2.end, l=bpad*2))\n",
" C = self.add(elm.Line('l', at=D1.start, tox=bbox.xmin-bpad))\n",
" D = self.add(elm.Line('l', at=D1.end, tox=bbox.xmin-bpad))\n",
" self.anchors['anode1'] = C.end\n",
" self.anchors['cathode1'] = D.end\n",
" self.anchors['anode2'] = B.end\n",
" self.anchors['cathode2'] = A.end\n",
"DiodeOptocoupler(box=False, reverse2=True, label2='D2')"
]
},
{
"cell_type": "code",
"execution_count": 177,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4oAAAEgCAYAAADylY1ZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAvmklEQVR4nO3dd7xsVXn/8c8XEI2ggkpTg2BBwYb+sMSoWFARFHsBNcGIJtEEIyr2HgtiN3aNJEZUsEW9iIhgTSyoCFiwYgWliERA6vP7Y+3xzhzPvffce8+ZPeXzfr3mdc7svWb2M/fumTPPXms9K1WFJEmSJEkDm/QdgCRJkiRpspgoSpIkSZJGmChKkiRJkkaYKEqSJEmSRpgoSpIkSZJGmChKkiRJkkaYKEqSJEmSRpgoSpIkSZJGbNZ3AJI0DZL8Ftim7zgkSdKfHFNV+/YdxKyyR1GSlsYkUZIkzQ17FCVpPVRV+o5BkiRppdmjKEmSJEkaYaIoSZIkSRphoihJkiRJGmGiKEmSJEkaYaIoSZIkSRphoihJkiRJGmGiKEmSJEkaYaIoSZIkSRphoihJkiRJGmGiKEmSJEkaYaIoSZIkSRphoihJkiRJGmGiKEmSJEkaYaIoSZIkSRphoihJkiRJGmGiKEmSJEkaYaIoSZIkSRphoihJkiRJGmGiKEmSJEkaYaIoSZIkSRphoihJmjhJtkvyhiQ/TnJJkl8l+VSSfbr9T0xyYpLzk1SSnXoOWZKkmbJZ3wFIkjSsS/q+DPwf8Gzg27QLm/cC3gbsCFwdOA74b+B1vQQqSdIMS1X1HYMkTbwkBVBV6TuWWZfkGGB3YJeq+sOCfVtX1e+G7u8BfB3YuarOGGeckiTNMoeeSpImRpJrA3sD/7YwSQQYThIlSdLKMVGUJE2SmwABvtd3IJIkzTMTRUnSJHForyRJE8BEUZI0SX4I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3sUZQkSZIkjTBRlCRJkiSNMFGUJEmSJI0wUZQkSZIkjTBRlCRJkiSNmNp1FAeV9CRJkiRJy2saexTP7jsAaYL4fpAkSdKym7p1FCVJ08N1FCVJmk7T2KMoSZIkSVpBJoqSJEmSpBEmipIkSZKkESaKkiRJkqQRJoqSJEmSpBEmipIkSZKkESaKkiRJkqQRJoqSJEmSpBEmipIkSZKkESaKkiRJkqQRJoqSJEmSpBEmipIkSZKkESaKkiRJkqQRJoqSJEmSpBEmipIkSZKkESaKkiRJkqQRm/UdgCRp9iWpvmOQJEkAHFNV+66rkT2KkqSVdHbfAUiSpPWXKi/ySpIkSZJWs0dRkiRJkjTCRFGSJEmSNMJEUZIkSZI0wkRRkiRJkjTCRFGSJEmSNMJEUZIkSZI0wkRRkiRJkjTCRFGSJEmSNOL/A0vfn4Tk5U+7AAAAAElFTkSuQmCC\n",
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"execution_count": 177,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d = schemdraw.Drawing()\n",
"V1 = d.add(elm.SourceV(label='5V'))\n",
"d.add(elm.Line(d='right', l=d.unit*2))\n",
"d.add(elm.Resistor(d='down', label='R1'))\n",
"coupler = d.add(DiodeOptocoupler(d='right', box=False, label1='D1', label2='D2', anchor='anode1', reverse2=True))\n",
"d.here = coupler.cathode1\n",
"Q1 = d.add(elm.BjtNpn(d='right', anchor='collector', label='Q1'))\n",
"d.add(elm.Line(xy=Q1.emitter, d='down', l=d.unit*0.25))\n",
"d.add(elm.Line(d='left', tox=V1.start))\n",
"d.add(elm.Line(d='up', toy=V1.start))\n",
"d.add(elm.Resistor(xy=Q1.base, d='left', label='R2'))\n",
"d.add(elm.Dot(open=True, lftlabel='TX in'))\n",
"\n",
"d.add(elm.Line(xy=coupler.cathode2, d='up', toy=V1.end + d.unit*0.5))\n",
"vbus = d.add(elm.Line(d='right', l=d.unit*5))\n",
"\n",
"d.add(elm.Line(xy=coupler.anode2, d='right', l=d.unit*0.5))\n",
"j1 = d.add(elm.Dot())\n",
"d.add(elm.Line(l=d.unit*0.5))\n",
"amp1 = d.add(elm.Opamp(d='right', anchor='in1'))\n",
"\n",
"d.add(elm.Line(xy=j1.xy, d='up', l=d.unit))\n",
"j2 = d.add(elm.Dot())\n",
"\n",
"d.add(elm.Resistor(label='R3', d='right'))\n",
"d.add(elm.Line(l=d.unit*0.5))\n",
"j3 = d.add(elm.Dot())\n",
"d.add(elm.Line(d='down', toy=amp1.out))\n",
"j4 = d.add(elm.Dot())\n",
"d.add(elm.Line('left', tox=amp1.out))\n",
"\n",
"d.add(elm.Line('up', xy=j2.xy, l=d.unit*0.5))\n",
"d.add(elm.Capacitor(label='C1', d='right'))\n",
"d.add(elm.Line(tox=j3.xy))\n",
"d.add(elm.Line(d='down', toy=j3.xy))\n",
"\n",
"d.add(elm.Line(d='left', xy=amp1.in2, l=d.unit*0.2))\n",
"d.add(elm.Line(d='down', l=d.unit*0.5))\n",
"vgnd_bus = d.add(elm.Line(d='right', l=d.unit*5))\n",
"\n",
"d.draw()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}