3

I am using LaTeX with CircuiTikZ to create circuit diagrams. Using the CircuiTikZ documentation and many of questions and answers on this community, I have been able to navigate it pretty well.

I have to recreate an 8 pin DIP chip containig an amplifier symbol connected internally to the pins. I have been able to create it using this code:

\begin{tikzpicture}
  % DIP chip
  \draw (0,0) node[dipchip,
        num pins=8,
        external pins width=0.3,
        external pad fraction=3,
        hide numbers](C){};
 
  % amplifier
  \draw (C) node[op amp, scale=0.571](OA){};
  % amplifier connection to the chip pins
  \draw (OA.-) |- (C.bpin 2)
        (OA.+) |- (C.bpin 3)
        (OA.out) |- (C.bpin 6);
\end{tikzpicture}

The result is exactly what I wanted:

The main objective in the creation of this image was the alignment between the dipchip pins and the amplifier + and - inputs. I accomplished this by manually resizing the amplifier (as shown by scale=0.571 in the code), until its inputs were perfectly aligned. Being this a quite tedious trial and error task, i was wondering if there is any easier (and possibly more elegant) method to accomplish the same result.
Thank you

3
  • No, there is not an "easy" way to do it without digging a bit into the internals of circuitikz. If I have a bit of time I'll try to show an example (basically, you have to retrieve the keys that define the two lengths and calculate the scale automatically).
    – Rmano
    Commented Sep 28, 2020 at 10:41
  • You can find the magic number with: \pgfmathsetmacro{\myscale}{\ctikzvalof{multipoles/dipchip/pin spacing}/ (\ctikzvalof{tripoles/op amp/height}*\ctikzvalof{tripoles/op amp/input height})} ;-)
    – Rmano
    Commented Sep 28, 2020 at 13:14
  • I tried it and the value that \myscale outputs is 0.57143, so I was pretty close with my estimation :) I guess that's a bit more complicated then what I was hoping for, but very useful nevertheless. Thank you!
    – PF98
    Commented Sep 28, 2020 at 14:17

1 Answer 1

4

The dimension in TikZ are relative to a basic length (which is not accessible easily, which is a bit of a pity), but each element has normally a different way to use the various parameters. So for example the distance between pins in chips is multipoles/dipchip/pin spacing; and the distance between the inputs of an op amp is tripoles/op amp/input height but it is relative to the height of the component (tripoles/op amp/height); this is basically historical.

Then, the components can be scaled by styles (amplifiers/scale and chips/scale)...

So this is what you can have to have the distance between the small amplifiers input match the chips:

\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
% \ctikzset{amplifiers/scale=1.5} % this will change the relative sizes
\begin{document}
\begin{tikzpicture}
    \pgfmathsetmacro{\myscale}{
        \ctikzvalof{multipoles/dipchip/pin spacing}*
        \ctikzvalof{chips/scale} /
        (\ctikzvalof{tripoles/op amp/height}*
        \ctikzvalof{tripoles/op amp/input height}*
        \ctikzvalof{amplifiers/scale})
    }
    \draw (0,2) node[]{\myscale}; % show the magic number
    % DIP chip
    \draw (0,0) node[dipchip,
        num pins=8,
        external pins width=0.3,
        external pad fraction=3,
        hide numbers](C){};

    % amplifier --- position it relative to the chip
    %(so I can move it around)
    \draw (C.bpin 2) node[op amp, scale=\myscale, anchor=-](OA){};
    % amplifier connection to the chip pins
    \draw (OA.-) |- (C.bpin 2)
        (OA.+) |- (C.bpin 3)
        (OA.out) |- (C.bpin 6);
\end{tikzpicture}

\end{document}

Notice also that I used relative positioning for the internal op-amp symbol so that you can move the main chip around without changing anything.

enter image description here

You must log in to answer this question.

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