1

can someone tell me how to write the code that allows me to connect mosfets like the one in the figure using circuitikz?enter image description here

I have managed how to place the transistors but I have problems in connecting them with horizontal and vertical wires.

\begin{circuitikz}
  \ctikzset{transistors/thickness=4}
  \ctikzset{tripoles/mos style=arrows}
  \ctikzset{transistors/arrow pos=end}
  \draw (0,-2) node[pmos,nocircle]{};
  \draw (2,-2) node[pmos,nocircle,xscale=-1]{}; 
  \draw (2,-4) node[nmos,xscale=-1]{};
  \draw (1,-6) node[nmos]{} (1,-7) node[ground]{};
\end{circuitikz}
1
  • please have alook at the answer below -- the lines are drawn as shown for one set -- you will be able to replicate the rest -- use relative positioning as far as possible -- anchor =source needs to be added to the fet for proper alignment with the pins
    – js bibra
    Commented Mar 7, 2021 at 2:38

2 Answers 2

1

Probably you should, as said by @js bibra, use relative coordinates and position MOSes using some reference anchor, but I prepared an answer using (almost) your example, to show how to use anchors to do connections.

You should basically give a name to your nodes, using the node[](my node name) syntax, and then you have all the anchors available under the syntax (my node name.anchor). You can find all the available anchors in the manual.

\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{tikzpicture}[]
  \ctikzset{transistors/thickness=4}
  \ctikzset{tripoles/mos style=arrows}
  \ctikzset{transistors/arrow pos=end}
  % name the MOSes. The text is optional, show the use of the \ctikzflip_ macros
  % relative positioning would be better to be able to "move" and "replicate"
  % the block as a whole
  \draw (0,-2) node[pmos,nocircle](M1){M1};
  \draw (2,-2) node[pmos,nocircle,xscale=-1](M2){\ctikzflipx{M2}}; 
  \draw (2,-4) node[nmos,xscale=-1](M3){\ctikzflipx{M3}};
  \draw (1,-6) node[nmos](M4){M4} (1,-7) (M4.S) node[ground]{};
  % use anchors --- they are a fundamental part of TikZ!
  \draw (M1.S) -- (M2.S);
  \draw (M2.D) -- (M3.D);
  \draw (M1.D) |- (M3.S); % first vertically, the horizontally
  \draw (M4.D) -- (M4.D |- M3.S); % coordinate with M4.D vertical and M3.S horizontal
  % extra example: find the midpoint between two coords
  \draw ($(M2.D)!0.5!(M3.D)$) -- ++(2,0) to[C] ++(0,-2) node[ground]{};
\end{tikzpicture}
\end{document}

enter image description here

0

enter image description here

\documentclass[10pt,a4paper]{article}
%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
\usepackage{circuitikz}
% \renewcommand\theadfont{}

\begin{document}
\begin{circuitikz}
    \ctikzset{transistors/thickness=4}
    \ctikzset{tripoles/mos style=arrows}
    \ctikzset{transistors/arrow pos=end}
    \draw 
    (0,-2) node[pmos,nocircle, anchor=source](a){} 
    to ++(0,1) 
    to ++(2,0)
    to node[pmos,nocircle,xscale=-1, anchor=source](b){} (2,-1) 
%   to node[nmos,xscale=-1, anchor=source](c){} (2,-8)
%   to node[nmos,anchor=source](d){} 
%   to node[ground]{}(1,-7)
;
\end{circuitikz}
\end{document}

You must log in to answer this question.

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