2

I have a slight visual disturbance on the connection between the nodes of the opamp and the lines connecting to it.

enter image description here

Maybe it does not get better, or do i have to adjust some line thickness? Thanks for your help!

\begin{figure}[!htbp]
\centering
\ctikzset{voltage/distance from node=.2}% defines arrow's distance from nodes
\ctikzset{voltage/distance from line=.02}% defines arrow's distance from wires
\ctikzset{voltage/bump b/.initial=.1}% defines arrow's curvature
\begin{tikzpicture}

\draw
(0,0) node[ocirc] (A) {}
(0,3) node [ocirc] (B) {}
(11,0) node[ocirc] (C) {}
(11,3.5) node[ocirc] (D) {}
(3,3) node[circ] (E) {}
(6,3) node[circ] (F) {}
(10,3.5) node[circ] (O) {}
(10,5) node[circ] (OT) {}
(8,3.5) node[op amp] (opamp) {}

(B) to [open,v=$u_e(t)$] (A)
(D) to [open, v^=$u_a(t)$] (C)

(A) -- (C)

(B) to[R, l=$R_1$] (E) to[R,l=$R_2$] (opamp.+)
(F) to[C,l=$C_1$] (6,0)

(E) -- (3,6) to[C, l=$C_2$] (10,6) -- (O) -- (opamp.out)
(opamp.-) -- (6,4) -- (6,5) -- (OT)
(O) -- (D)
(opamp.+) node[left] {}
(opamp.-) node[left] {}
(opamp.out) node[right] {}
;
\end{tikzpicture}
\caption{2nd Order Low Pass}
\label{fig:lowpass}

\end{figure}

Rico
  • 55
  • 2
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – BambOo Jul 23 '19 at 09:41
  • Hi! Which PDF viewer are you using? A lot of this cases are due to PDF viewer antialiasing algorithms (for example: okular is horrible, evince is better). Try to print it too. Anyway, I'll check as soon as I can... – Rmano Jul 23 '19 at 09:57

2 Answers2

2

You have to adjust a coordinate, opamp.- isn't at exactly y = 4, so the line isn't horizontal. To avoid explicit x-y coordinates, you can do for example

(opamp.-) -- (opamp.- -| F) |- (OT)

The -|/|- syntax is described in TikZ: What EXACTLY does the the |- notation for arrows do?

The same goes for the other one, you need to somehow make sure that F and opamp.+ is at the same y-coordinate. One way of doing that is to set up the diagram differently, placing F relative to opamp, instead of using explicit coordinates. You can place everything relative to other things if you like, for example:

\documentclass[border=5mm,tikz]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{positioning}
\begin{document}

\ctikzset{voltage/distance from node=.2}% defines arrow's distance from nodes
\ctikzset{voltage/distance from line=.02}% defines arrow's distance from wires
\ctikzset{voltage/bump b/.initial=.1}% defines arrow's curvature

\begin{tikzpicture}

\draw
  node[op amp] (opamp) {}
  node[circ, right=of opamp] (O) {}  
  node[circ, left=of opamp.+] (F) {}
  node[ocirc, right=of O,label=right:D] (D) {}
  node[circ, left=3cm of F] (E) {}
  node[circ, above=of O] (OT) {}
  node[ocirc,left=3cm of E] (B) {}
  node[ocirc, below=3cm of B] (A) {}
  (A -| D) node[ocirc] (C) {}
  % define a few helper coordinates, used below when drawing the connections
  (F |- A) coordinate (tmpC1)
  coordinate[above=of OT] (tmpC2)
  coordinate[left=of opamp.-] (tmpF)

(B) to [open,v=$u_e(t)$] (A)
(D) to [open, v^=$u_a(t)$] (C)

(A) -- (C)

(B) to[R, l=$R_1$] (E) to[R,l=$R_2$] (opamp.+)
(F) to[C,l=$C_1$] (tmpC1)

(E) -- (E |- tmpC2) to[C, l=$C_2$] (tmpC2) -- (O) -- (opamp.out)
(opamp.-) -- (tmpF) |- (OT)
(O) -- (D)
(opamp.+) node[left] {}
(opamp.-) node[left] {}
(opamp.out) node[right] {}
;
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688
  • I got an error with the option "right=of", etc. – jotagah Jul 23 '19 at 11:30
  • 2
    @jotagah Did you add \usetikzlibrary{positioning}? (Forgot to mention that specifically, but it's in my code example.) – Torbjørn T. Jul 23 '19 at 11:30
  • @Torbørn, I had used QTiKz to "run" the circuitikz code only. Using your full example I got an error: "Package PGF Math Error: Unknown function `west' (in 'west')". Maybe anything wrong with my TeXLive 20019 installation. – jotagah Jul 24 '19 at 12:22
  • @jotagah That sounds a bit odd, I would expect that QTikZ uses the same TeX distribution as any other LaTeX editor you have. It works fine for me with TL2019. – Torbjørn T. Jul 24 '19 at 17:30
  • How could i place second opamp so that its input aligns with an existing node? – Rico Aug 07 '19 at 12:41
  • @Rico Try to set the anchor of the opamp to whatever part you want to align with the other node, and positioning it relative to that node. E.g. anchor=+, right=of foo. – Torbjørn T. Aug 07 '19 at 12:46
  • @Torbjorn This node[op amp,anchor=+, right=of stage2in,yscale=-1] (opamp2) {} is not working – Rico Aug 07 '19 at 12:56
  • @Rico I can't test right now, but what does ”not work“ mean? – Torbjørn T. Aug 07 '19 at 12:58
  • It does not move the opamp up, so the alignment would be correct. It seems that the ancher does not have a effekt. – Rico Aug 07 '19 at 13:05
  • @Rico Oh sorry, I made a mistake. The anchor setting has to be placed after the right=, because the latter sets the anchor. – Torbjørn T. Aug 07 '19 at 13:07
  • Thanks this is working! node[op amp, right= 2cm of stage2in, anchor=+, yscale=-1] (opamp2) {} – Rico Aug 07 '19 at 13:47
2

The answer by Torbjørn T. is correct, but also notice that the PDF viewer can play a role in this. The different antialiasing algorithms can show different things. For example, using Torbjørn's code, you have at the same zoom (150%):

  1. In okular (which is great for other things, but... notice the lines and the capacitors)

output from okular

  1. In evince (which I can't use with vimtex with back reference, though renders better on my display)...

output from evince

Rmano
  • 40,848
  • 3
  • 64
  • 125