2

how do I draw this schematic on latex?

enter image description here

So far I have tried drawing from this link which was supposed to produce

enter image description here

but when i complied, i got this

enter image description here

% set basic rectangular shape of IC
\tikzstyle{icdev}=[draw, text width=6em, minimum height=8em]
\begin{tikzpicture}[every node/.style = {font \footnotesize},european]
\draw (0,4) node[left]{$V_{cc}$}  % from top Vcc to bottom Gnd
to[short,o-] (0.8,4)
to[/tikz/circuitikz/bipoles/length=0.7cm,R] (0.8,2) % set bipole 
%device size
to[/tikz/circuitikz/bipoles/length=0.7cm,C] (0.8,1.8) -- (0.8,0)
to[short,-o] (0,0) node[left]{GND}
;
\node (digichip) [icdev,xshift=3cm,yshift=2cm] {}; % position IC %device body
% top terminal lines/pins - 4 RESET, 8 Vcc
\path [draw](0.8,4) -| (2.5,3.4) node[below]{RESET} node[above left]{4};
\path [draw](2.5,4) -| (3.5,3.4) node[below]{$V_{cc}$} node[above left] {8};
% bottom terminal lines/pins - 1 GND, 5 CTRL
\path [draw](0.8,0) -| (2.5,0.6) node[above]{GND} node[below left]{1};
\path [draw](2.5,0) -- (3.5,0)
to[/tikz/circuitikz/bipoles/length=0.7cm,C](3.5,0.6) 
node[above]{CTRL} node[below left]{5}; % C = 10nf
% leftside terminal lines/pins - 7 DIS, 6 THR, 2 TRG
\draw (0.8,2.5) -- (1.83,2.5) node[right]{DIS} node[above left]{7}
(1.2,2.5) |- (1.83,2) node[right]{THR} node[above left]{6}
(1.1,1.5) -- (1.83,1.5) node[right]{TRG} node[above left]{2};
% rightside terminal line/pin - 3 out
\draw (4.17,2) node[left]{Out} -- (4.8,2) node[above left]{3};
\end{tikzpicture}
  • 9
    Welcome to the site. However, I'm sorry, the purpose of the site is not to request others to do your work for you, but to answer specific LaTeX questions. You should explain what you've tried so far and provide a small compiling example of how far you have gone in that quest. Then, the specific difficulty or misunderstanding can become apparant and addressed by the community. As a start, you should investigate the tikz package. – Steven B. Segletes Jun 5 '18 at 12:44
  • @JohnMiller just put the example code, that serves other users to correct some errors that may be in your code, is very appreciated by the community and will not hesitate to provide the solution you need. – J Leon V. Jun 5 '18 at 14:00
4

Your code is a good attempt but it would be better to align yourself with good practices. Here is a code that can be used as a framework for your circuits, here is how to create new components and use them as if they were components in CAD editors of circuits, based on the one made by Henry Henri Menke. Another solution that he used was that of Claudio Fiandrino to be able to place the identifier of the diode and the type of component.

In the MWE, Two tikz objects are created that can be placed and identified as the components in schematic editors such as proteus or eagle, pins will be identified by coordinate names using the macro coordinate; for the drawing of circuits, I use the structure according to the circuitikz manual, it is important to structure the code to make it readable; intentionally, each macro \draw is assigned draw option for color (blue), change it to other colors so you can identify which parts of the circuit they draw; you can use the TikzEdt editor to visualize every change you make instantly.

I support your question since there are only 2 on the subject and perhaps encourage many to choose how powerful tikz can be.

RESULT: enter image description here

MWE:

% By J. Leon V.  coded based on the BSD, MIT, Beerware licences.
\documentclass[border=20pt]{standalone}
\usepackage{tikz} 
\usepackage{siunitx}
\renewcommand*\familydefault{\sfdefault} % Serif Font
\usepackage[american]{circuitikz} % Paquete especializado en circuitos eléctricos.
\usetikzlibrary{calc,arrows}
%%%%%%%%%%%%%%%%%%%%
% This code is from Claudio Fiandrino https://tex.stackexchange.com/a/65792/154390
% Ads new label styles to allow aditional labels like two line descriptions.
\makeatletter
\ctikzset{lx/.code args={#1 and #2}{ 
  \pgfkeys{/tikz/circuitikz/bipole/label/name=\parbox{1cm}{\centering #1  \\ #2}}
    \ctikzsetvalof{bipole/label/unit}{}
    \ifpgf@circ@siunitx 
        \pgf@circ@handleSI{#2}
        \ifpgf@circ@siunitx@res 
            \edef\pgf@temp{\pgf@circ@handleSI@val}
            \pgfkeyslet{/tikz/circuitikz/bipole/label/name}{\pgf@temp}
            \edef\pgf@temp{\pgf@circ@handleSI@unit}
            \pgfkeyslet{/tikz/circuitikz/bipole/label/unit}{\pgf@temp}
        \else
        \fi
    \else
    \fi
}}

\ctikzset{lx^/.style args={#1 and #2}{ 
    lx=#2 and #1,
    \circuitikzbasekey/bipole/label/position=90 } 
}

\ctikzset{lx_/.style args={#1 and #2}{ 
    lx=#1 and #2,
    \circuitikzbasekey/bipole/label/position=-90 } 
}
\makeatother


\begin{document}
\ctikzset{bipoles/length=1cm} % Controls bipoles scale

\begin{tikzpicture}[
        %Global Config
        font=\small
    ]

%You can create an smart objet like Henri Menke in this post http://www.texample.net/tikz/examples/4-bit-counter/
% Variables: 1: Position 2: ID.
 \def\TIMER555(#1)#2{%
  \begin{scope}[shift={(#1)}]
    \draw[fill=blue!10] (-1.5,-2) rectangle (1.5,2); % The body of IC
    % Label and component identifier.
    \draw[blue] (2,2.5) node []{\large \bf U - #2}; % IC LABEL
    \draw[blue] (0,0.5) node [align=center]{\large NE-555\\TIMER}; % IC LABEL
    % Draw the pins
    % Some that you have to learn about label nodes, draw lines, and name coordinates in Tikz
    \draw (0.9,-2) node [above]{GND} -- +(0,-0.5) node [anchor=-45]{1} coordinate (#2 GND); % Pin 1 GND
    \draw (-1.5,-1.5) node [right]{TRG} -- +(-0.5,0) node [anchor=-135]{2} coordinate (#2 TRG); % Pin 2 TRG
    \draw (1.5,0) node [left]{OUT} -- +(0.5,0) node [anchor=-45]{3} coordinate (#2 OUT); % Pin 3 OUT  
    \draw (0.9,2) node [below]{RESET} -- +(0,0.5) node [anchor=45]{4} coordinate (#2 RESET); % Pin 4 RESET
    \draw (0,-2) node [above]{CTRL} -- +(0,-0.5) node [anchor=-45]{5} coordinate (#2 CTRL); % Pin 5 CTRL
    \draw (-1.5,-.5) node [right]{THR} -- +(-0.5,0) node [anchor=-135]{6} coordinate (#2 THR); % Pin 6 THR
    \draw (-1.5,1.5) node [right]{DIS} -- +(-0.5,0) node [anchor=-135]{7} coordinate (#2 DIS); % Pin 7 DIS
    \draw (0,2) node [below]{$\mathsf{V_{CC}}$} -- +(0,0.5) node [anchor=45]{8} coordinate (#2 VCC); % Pin 8 VCC
  \end{scope}
}

%This is mine
% Variables: 1: Position 2: ID.
 \def\SPEAKER(#1)#2{%
  \begin{scope}[shift={(#1)}]
    \draw[fill=green!40!black!50] (-.2,.3) rectangle (.2,-.3); % The body of IC
    \draw[fill=green!40!black!30] (.2,.3) -- ++(.2,.3) -- ++(0,-1.2) -- (.2,-0.3) -- (.2,.3); % The body of IC
    % Label and component identifier.
    \draw[blue] (-1,0.2) node []{\large \bf E - #2}; % IC LABEL
    \draw[blue] (-1,-.2) node [align=center]{\large Speaker}; % IC LABEL
    % Draw the pins
    % Some that you have to learn about label nodes, draw lines, and name coordinates in Tikz
    \draw (0,.3)  -- +(0,0.5) node [anchor=45]{1} coordinate (#2 S1); % Pin 1 
    \draw (0,-0.3)  -- +(0,-0.5) node [anchor=-45]{2} coordinate (#2 S2); % Pin 2 

  \end{scope}
}

% Start drawing the circuit: Example "Dee-Dah" Siren

% Place the IC's in position
\TIMER555(0,0){1}
\TIMER555(6,0){2}
\SPEAKER(10,-3){1}

% Start conecting 
\draw[color=blue!50] (-4,3.5) % Start point
    node [anchor=east]{$\mathsf{V_{CC}}$}
    to [short, o-] ++(1,0) coordinate (NOD1) % Use auxiliar coordinate (NOD1)
    to [R, l^=68k\si{\ohm},*-*] (1 DIS -| NOD1) % to the point in the intersection between NOD1 and 1 DIS
    to [R,l^=68k\si{\ohm},*-*] (1 THR -| NOD1)% idem
    to [short, *-*] (1 TRG -| NOD1)
    to [eC,l^=10\si{\mu}F,*-*] (-3,-5)
    to [short,*-o] ++(-1,0) coordinate (GND)
    node [anchor=east]{GND};

\draw[color=blue] (1 DIS)
    to [short,-] (1 DIS -| NOD1)
    to [short,-] ++(-.7,0) coordinate (NOD2)
    to [D,lx_=D1 and IN4148] (1 THR -| NOD2) % Here is used Fiandrino macro!
    to [short,-] (1 THR);

\draw[color=blue!50] (NOD1) 
    to [short, -*] ++(6,0) coordinate (NOD3) % Use auxiliar coordinate (NOD1)
    to [R, l^=68k\si{\ohm},*-*] (1 DIS -| NOD3) % to the point in the intersection between NOD3 and 1 DIS
    to [R,l^=68k\si{\ohm},*-*] (1 THR -| NOD3)% idem
    to [short, *-*] (1 TRG -| NOD3)
    to [short,-] ++(0,-2)
    to [eC,l^=100nF,-*] (NOD3 |- GND) coordinate (NOD4)
    to [short,-] (GND);

\draw[color=blue] (1 OUT)
    to[R,l=10k\si{\ohm},label/align=rotate] ++(0,-3) coordinate (NOD5)
    to [short] (2 CTRL |- NOD5)
    to [short] (2 CTRL);    

\draw[color=blue] (2 OUT)
    to[pC,l^=100\si{\mu}F,invert] (2 OUT -| 1 S1)
    to [pR,l^=Rx] (1 S1); 

%Conect U-1
\draw[color=blue] (1 VCC) to [short, -*] (1 VCC |- NOD1);
\draw[color=blue] (1 RESET) to [short, -*] (1 RESET |- NOD1);
\draw[color=blue] (1 TRG) to [short, -*] (1 TRG -| NOD1);
\draw[color=blue] (1 CTRL) to [eC,l_=0.01nF, -*] (1 CTRL |- GND);
\draw[color=blue] (1 GND) to [short, -*] (1 GND |- GND);

%Conect U-2
\draw[color=blue] (2 VCC) to [short, -*] (2 VCC |- NOD3);
\draw[color=blue] (2 RESET) to [short, -] (2 RESET |- NOD3) to [short] (NOD3);
\draw[color=blue] (2 TRG) to [short, -*] (2 TRG -| NOD3);
\draw[color=blue] (2 GND) to [short, -*] (2 GND |- GND);
\draw[color=blue] (2 DIS) to [short] (2 DIS -| NOD3);
\draw[color=blue] (2 THR) to [short] (2 THR -| NOD3);

% Conect E - 1
\draw[color=blue] (1 S2) |- (NOD3 |- GND);

% Decorate ground and VCC
\draw[color=blue] (GND -| NOD3) -- ++(0,-0.2)node[ground]{};
\draw[color=blue] (NOD3) -- ++(0,0.2) node[vcc]{Vcc (+5 to 15V)};

\end{tikzpicture}
\end{document}
  • A very nice and helpful answer! – Steven B. Segletes Jun 5 '18 at 19:08
  • 1
    If you think that, I would appreciate it if you accept this answer as the best answer, by clicking on the green checkmark next to the answer. – J Leon V. Jun 6 '18 at 14:41
7

I agree with Steven B. Segletes --- this is not a "do it for me". But I have a sample circuit that could be useful as a starting point, so I am posting this here.. It will require quite a lot of work to adapt, but I think the idea is here.

\documentclass[border=0.5cm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\usepackage[siunitx]{circuitikz}
\usepackage{calc}
%\usepackage{color}
\newcommand{\micro}{PIC32MX230F064D} % Micro usado

\begin{document}

\begin{circuitikz}[american]
%%% in this scope we draw the chip
\begin{scope}[xshift=4cm, yshift=10cm]
   \pgfmathsetmacro\ancho{6}
   \pgfmathsetmacro\alto{6}
   \pgfmathsetmacro\pines{44}
   \pgfmathsetmacro\pinw{0.3}
   \pgfmathsetmacro\pinf{0.7}
   \pgfmathsetmacro\offset{0.6}
   % don't touch from here 
   \pgfmathsetmacro\qp{\pines/4}
   \draw (0,0)  rectangle ++(\ancho, -\alto);
   \draw (\offset,-\offset) node[draw,circle,fill=black,minimum size=5pt]{};
   \node [rotate=0, font=\Large] at (0.5*\ancho, -0.5*\alto) {\micro};
   \foreach \p in {1,..., \qp} {
       \pgfmathsetmacro\yc{\offset + (\p-1)*(\alto-2*\offset)/(\qp-1)}
       \pgfmathsetmacro\xc{\offset + (\p-1)*(\ancho-2*\offset)/(\qp-1)}
       % Draw left column of pins
       \draw (-\pinw, -\yc) coordinate (pin\p) -- ++(0, \pinf*\alto/\pines) -- ++(\pinw, 0)
             (-\pinw, -\yc)  -- ++(0, -\pinf*\alto/\pines) -- ++(\pinw, 0) 
             (0, -\yc) node [right] { \p};
       % Draw bottom rown of pins
       \pgfmathtruncatemacro{\lowp}{\qp+\p};
       \draw (\xc, -\alto-\pinw) coordinate (pin\lowp) -- ++(-\pinf*\ancho/\pines, 0) -- ++(0, \pinw)
             (\xc, -\alto-\pinw) -- ++(\pinf*\ancho/\pines,0) -- ++(0,\pinw)
             (\xc, -\alto) node [above] { \lowp};
       % Draw right column of pins
       \pgfmathtruncatemacro{\simp}{\pines-\qp-\p+1}
       \draw (\ancho+\pinw, -\yc) coordinate (pin\simp) -- ++(0, -\pinf*\alto/\pines) -- ++(-\pinw, 0)
             (\ancho+\pinw, -\yc)  -- ++(0, \pinf*\alto/\pines) -- ++(-\pinw, 0) 
             (\ancho, -\yc) node [left] { \simp};
       % Draw top row of pins
       \pgfmathtruncatemacro{\topp}{\pines-\p+1};
       \draw (\xc, +\pinw) coordinate (pin\topp) -- ++(-\pinf*\ancho/\pines, 0) -- ++(0, -\pinw)
             (\xc, +\pinw) -- ++(\pinf*\ancho/\pines,0) -- ++(0,-\pinw)
             (\xc, 0) node [below] { \topp};
} 
\end{scope}
\draw (pin6) node[above left]{RB2} --++(-2,0) coordinate(topc) ;
\draw (topc) to [C, l=\SI{100}{nF}, *-] ++(0,-2) node [ground]{};
\draw (topc) -- ++(-2,0) coordinate(toppb);
\draw (toppb) to[R, l=\SI{100}{k\ohm}, *-] ++(0,2) -- ++(0,0.5) node [vcc]{+3.3 V};;
\draw (toppb) ++(0,-2) node[ground]{} to[push button, l=T2] (toppb);
\draw (pin24) node[above right]{RB13} -- ++(2,0) ++(0,02) coordinate (topd)  to[leD*] ++(0,-2);
\draw (topd) to[R, l_=\SI{270}{\ohm}] ++(0,2) -- ++(0,0.5) node [vcc]{+3,3V};
\end{circuitikz}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.