3

I'm trying to draw a multiple emitter npn transistor and multiple collector pnp transistor. I'm using tikz to draw all my electric circuits but there is nothing about it in the documentation nor this site.

I need to draw something like Q1 in this image: Multiple emitter transistor

2
  • 1
    The easy way is to take a normal BJT and add a few extra lines I have a tutorial on creating circuitiz components (easier than tikz). See elfsoft2000.com/projects/index.htm Nov 30, 2015 at 23:19
  • Thank you, I thought it should be something made. I tried to add some lines extra, but it doesn't look pretty good. Anyway I did read your guides and those are nice for what I'm doing. Dec 1, 2015 at 15:36

1 Answer 1

3

Revised solution moved E2 to the right of E. Also corrected compass anchors to reflect larger size than all the other transistors. B,C,E are still aligned with the center anchor.

\documentclass[border=1pt]{standalone}
\usepackage{circuitikz}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% two emitter npn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ctikzset{tripoles/npn2/height/.initial=1.1}% before expansion
\ctikzset{tripoles/npn2/width/.initial=.6}% before expansion
\ctikzset{tripoles/npn2/gate height/.initial=.45}
\ctikzset{tripoles/npn2/gate height 2/.initial=.15}
\ctikzset{tripoles/npn2/base height/.initial=.4}
\ctikzset{tripoles/npn2/step/.initial=.15}% both vertical and horizontal separation
\ctikzset{tripoles/npn2/slope/.initial=.6}% (height - height 2) / (gate width)
\ctikzset{tripoles/npn2/gate width/.initial=.5}
\ctikzset{tripoles/npn2/curr direction/.initial=1}

\pgfcircdeclaretransistor{npn2}{
  \savedanchor{\southeast}{% \northeast is actually north (x=0pt)
    \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/step}\pgf@circ@Rlen
    \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/height}\pgf@circ@Rlen
    \pgf@y=-.5\pgf@y
    \advance\pgf@y by -\pgf@x
  }
% redefine anchors for larger size
  \anchor{north east}{
    \southeast
    \pgf@circ@res@temp=\pgf@x
    \northeast
    \pgf@x=\pgf@circ@res@temp
  }
  \anchor{south east}{\southeast}
  \anchor{east}{
    \southeast
    \pgf@y=0pt
  }
  \anchor{south}{
    \southeast
    \pgf@x=0pt
  }
  \anchor{south west}{
    \southeast
    \pgf@circ@res@temp=\pgf@y
    \left
    \pgf@y=\pgf@circ@res@temp
  }
  \anchor{text}{
    \northeast
    \pgfpoint{.333em}{0.6\pgf@y}
  }

  \anchor{C}{\northeast}
  \anchor{collector}{\northeast}

  \anchor{B}{\left}
  \anchor{base}{\left}

  \anchor{E}{
    \southeast
    \pgf@x=-0pt
  }
  \anchor{emitter}{
    \southeast
    \pgf@x=-0pt
  }

  \anchor{E2}{\southeast}
}{%
    \southeast
    \pgf@circ@res@right=\pgf@x
    \pgf@circ@res@down=\pgf@y
    \pgf@circ@res@step=\pgf@circ@res@right

    \pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0pt}
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up}}
    \pgfusepath{draw}

      \pgfscope
     \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/base height}\pgf@circ@res@up
     \pgfpathmoveto{\pgfpoint
        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
        {\pgf@circ@res@temp}}
     \advance\pgf@circ@res@temp by \pgf@circ@res@step
      \pgfpathlineto{\pgfpoint
       {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
       {-\pgf@circ@res@temp}}
      \pgfsetlinewidth{2\pgflinewidth}
      \pgfusepath{draw}
      \endpgfscope

      \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
      {-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/slope}\pgf@circ@res@step
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}      
    \pgfusepath{draw}

    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgf@circ@res@step
    \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
      {-\pgf@circ@res@temp}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgf@circ@res@step
    \pgfpathlineto{\pgfpoint{0pt}{-\pgf@circ@res@temp}}%
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}%
    \pgfusepath{draw}

    \pgfscope
      \pgfslopedattimetrue
      \pgfallowupsidedownattimetrue
      \pgfresetnontranslationattimefalse
      \pgftransformlineattime{.5}{%
        \pgfpoint%
          {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}%
          {-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up}%
      }{\pgfpoint{0pt}{-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up}}%
      \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
    \endpgfscope

    \pgfscope
      \pgfslopedattimetrue
      \pgfallowupsidedownattimetrue
      \pgfresetnontranslationattimefalse

      \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up
      \advance\pgf@circ@res@temp by \pgf@circ@res@step
      \pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up
      \advance\pgf@circ@res@other by \pgf@circ@res@step

      \pgftransformlineattime{.5}{%
        \pgfpoint%
          {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}%
          {-\pgf@circ@res@temp}%
      }{\pgfpoint{0pt}{-\pgf@circ@res@other}}%
      \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
    \endpgfscope

    \pgfpathmoveto{\pgfpoint
        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
        {0pt}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
    \pgfusepath{draw}
}
% create Tnpn2 to-path style
\pgf@circ@definetranspath{npn2}
\makeatother

\begin{document}
\begin{circuitikz}
\draw (0,0) node[npn2] (Q1) {npn2};
\node[above] at (Q1.C) {C};
\node[left] at (Q1.B) {B};
\node[below] at (Q1.E) {E};
\node[below right] at (Q1.E2) {E2};
%\draw[red] (Q1.north) -- (Q1.north east) -- (Q1.east) -- (Q1.south east) --
%  (Q1.south) -- (Q1.south west) -- (Q1.west) -- (Q1.north west) -- cycle;
\path (2,0);
\end{circuitikz}
\end{document}

two emitter npn

6
  • @JohnKormylov, are you add this solution in your collection of TikZ elements in your home page? Very nice solution!
    – Zarko
    Dec 1, 2015 at 17:20
  • @zark0 - Naturellement! At least once it's done. Dec 1, 2015 at 17:23
  • That is exactly what I was looking for!! I hope to see this element on your home page in the future! thanks a lot! Dec 1, 2015 at 17:41
  • @JohnKormylo I receive five errors when I try to compile your source directly. Three of them are "Missing number, treated as zero. \draw (0,0) node[npn2] (Q1){npn2};". The others are "Illegal unit of measure (pt inserted). \draw (0,0) node[npn2] (Q1){npn2};" and "Missing = inserted for \ifnum. \draw (0,0) node[npn2] (Q1){npn2};". I tried compiling with Latex, PdfLatex XeLatex and LuLatex. It didn't solve it.
    – C.Koca
    Feb 9, 2018 at 21:05
  • 1
    @C.Koca - Old solution. Circuitikz has completely revised how it draws transistors. This will take a while. Feb 9, 2018 at 21:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .