Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \NeedsTeXFormat{LaTeX2e}[1994/06/01]
- \ProvidesPackage{tikzblocks}[2016/04/08 TikZ Blocks]
- \usetikzlibrary{automata,arrows,calc,intersections,matrix,patterns,positioning,shapes,decorations,decorations.markings,math}
- \def\blockcolor{white}
- \newdimen\blocksize
- \blocksize = 6mm
- \tikzmath{\fontscale = \blocksize/10mm;}
- \newdimen\scaledlinewidth
- \scaledlinewidth = 0.5pt
- \setlength{\scaledlinewidth}{\fontscale\scaledlinewidth}
- \newcommand{\scale}[1]{\scalebox{\fontscale}{#1}}
- \pgfdeclaredecoration{complete sines}{initial}
- {
- \state{initial}[width = +0pt, next state = sine, persistent precomputation = {\pgfmathsetmacro\matchinglength{
- \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)
- }
- \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}}]{}
- \state{sine}[width = \pgfdecorationsegmentlength]{
- \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
- \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
- \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
- \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
- }
- \state{final}{}
- }
- \newcommand{\textdirectcurrent}{%
- \settowidth{\dimen0}{$ = $}%
- \vbox to .85ex {\offinterlineskip
- \hbox to \dimen0{\leaders\hrule\hfill}
- \vskip.35ex
- \hbox to \dimen0{%
- \leaders\hrule\hskip.2\dimen0\hfill
- \leaders\hrule\hskip.2\dimen0\hfill
- \leaders\hrule\hskip.2\dimen0
- }
- \vfill
- }%
- }
- \def\ppbb{path picture bounding box}
- \tikzset{
- auto,
- > = latex',
- anchor = center,
- node distance = \blocksize,
- every node/.style =
- {
- line width = \scaledlinewidth
- },
- every path/.style =
- {
- line width = \scaledlinewidth
- },
- mark red/.style =
- {
- color = red,fill = red!20
- },
- mark blue/.style =
- {
- color = blue,fill = blue!20
- },
- mark yellow/.style =
- {
- color = orange,fill = yellow!20
- },
- mixer/.style =
- {
- draw,
- fill = \blockcolor,
- circle,
- inner sep = 0pt,
- minimum width = 0.5\blocksize,
- path picture =
- {
- \draw
- (\ppbb.north west) -- (\ppbb.south east)
- (\ppbb.south west) -- (\ppbb.north east);
- }
- },
- wave/.style =
- {
- decorate,
- decoration =
- {
- complete sines,
- amplitude = 0.1\blocksize,
- segment length = 0.6\blocksize
- }
- },
- block/.style =
- {
- draw,
- fill = \blockcolor,
- rectangle,
- minimum height = \blocksize,
- minimum width = \blocksize,
- anchor = center,
- inner sep = 0.1\blocksize
- },
- osciwave/.style =
- {
- decorate,
- decoration =
- {
- complete sines,
- amplitude = 0.35\blocksize,
- segment length = 0.4\blocksize
- }
- },
- bpf/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw[wave] ([xshift = -0.3\blocksize, yshift = 0.2\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[wave] ([xshift = -0.3\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[wave] ([xshift = -0.3\blocksize, yshift = -0.2\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[transform canvas = {yshift = 0.2\blocksize}] ([xshift = 0.05\blocksize,yshift = 0.05\blocksize]\ppbb.center) -- ([xshift = -0.05\blocksize,yshift = -0.05\blocksize]\ppbb.center) {};
- \draw[transform canvas = {yshift = -0.2\blocksize}] ([xshift = 0.05\blocksize,yshift = 0.05\blocksize]\ppbb.center) -- ([xshift = -0.05\blocksize,yshift = -0.05\blocksize]\ppbb.center) {};
- }
- },
- bsf/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw[wave] ([xshift = -0.3\blocksize, yshift = 0.2\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[wave] ([xshift = -0.3\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[wave] ([xshift = -0.3\blocksize, yshift = -0.2\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw ([xshift = 0.05\blocksize,yshift = 0.05\blocksize]\ppbb.center) -- ([xshift = -0.05\blocksize,yshift = -0.05\blocksize]\ppbb.center) {};
- }
- },
- lpf/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw[wave] ([xshift = -0.3\blocksize, yshift = 0.1\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[wave] ([xshift = -0.3\blocksize, yshift = -0.1\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[transform canvas = {yshift = 0.1\blocksize}] ([xshift = 0.05\blocksize,yshift = 0.05\blocksize]\ppbb.center) -- ([xshift = -0.05\blocksize,yshift = -0.05\blocksize]\ppbb.center) {};
- }
- },
- hpf/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw[wave] ([xshift = -0.3\blocksize, yshift = 0.1\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[wave] ([xshift = -0.3\blocksize, yshift = -0.1\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw[transform canvas = {yshift = -0.1\blocksize}] ([xshift = 0.05\blocksize,yshift = 0.05\blocksize]\ppbb.center) -- ([xshift = -0.05\blocksize,yshift = -0.05\blocksize]\ppbb.center) {};
- }
- },
- osc/.style =
- {
- draw,
- fill = \blockcolor,
- circle,
- inner sep = 0pt,
- minimum width = 0.8\blocksize,
- path picture =
- {
- \draw[osciwave] ([xshift = -0.2\blocksize]\ppbb.center) -- +(0.4\blocksize,0) {};
- }
- },
- motor/.style =
- {
- draw,
- fill = \blockcolor,
- circle,
- inner sep = 0pt,
- minimum width = 0.8\blocksize,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] (\ppbb.center) {M};
- }
- },
- generator/.style =
- {
- draw,
- fill = \blockcolor,
- circle,
- inner sep = 0pt,
- minimum width = 0.8\blocksize,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] (\ppbb.center) {G};
- }
- },
- osc var/.style =
- {
- osc,
- append after command =
- {
- \pgfextra
- {%
- \draw[->] ([xshift = -0.5\blocksize,yshift = -0.5\blocksize]\tikzlastnode.center) -- +(\blocksize,\blocksize) {};
- }
- },
- path picture =
- {
- \draw[osciwave] ([xshift = -0.2\blocksize]\ppbb.center) -- +(0.4\blocksize,0) {};
- \draw (\ppbb.south west) -- (\ppbb.north east) {};
- }
- },
- integ/.style =
- {
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] at (\ppbb.center) {\scalebox{1.3}{$\int$}};
- }
- },
- integ var/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] at (\ppbb.center) {\scalebox{1.3}{$\int$}$\cdot d#1$};
- }
- },
- differentiator/.style =
- {
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] at (\ppbb.center) {\scalebox{1.3}{$\frac{d}{dt}$}};
- }
- },
- upsampler/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] at (\ppbb.center) {$\uparrow$\,#1};
- }
- },
- downsampler/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] at (\ppbb.center) {$\downarrow$\,#1};
- }
- },
- diode demodulator/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.3\blocksize]\ppbb.center) -- +(0.6\blocksize,0) {};
- \draw ([xshift = 0.15\blocksize]\ppbb.center) -- ([xshift = -0.15\blocksize,yshift = 0.15\blocksize]\ppbb.center) -- ([xshift = -0.15\blocksize,yshift = -0.15\blocksize]\ppbb.center) -- cycle {};
- \draw ([xshift = 0.15\blocksize, yshift = 0.15\blocksize]\ppbb.center) -- +(0,-0.3\blocksize) {};
- }
- },
- amp/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.2\blocksize,yshift = 0.3\blocksize]\ppbb.center) -- ([xshift = 0.3\blocksize]\ppbb.center) -- ([xshift = -0.2\blocksize,yshift = -0.3\blocksize]\ppbb.center) -- cycle {};
- }
- },
- sample and hold/.style =
- {
- draw,
- block,
- path picture =
- {
- \node[anchor = center,scale = \fontscale] at (\ppbb.center) {S\&{}H};
- }
- },
- converter/.style args =
- {from #1 to #2}{
- draw,
- block,
- path picture =
- {
- \draw (\ppbb.south west) -- (\ppbb.north east) {};
- \node[scale = \fontscale, anchor = center] at ([xshift = -0.2\blocksize,yshift = 0.2\blocksize]\ppbb.center) {\small #1};
- \node[scale = \fontscale, anchor = center] at ([xshift = 0.2\blocksize,yshift = -0.2\blocksize]\ppbb.center) {\small #2};
- }
- },
- rectifier/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw (\ppbb.south west) -- (\ppbb.north east) {};
- \node[scale = \fontscale, anchor = center] at ([xshift = -0.2\blocksize,yshift = 0.16\blocksize]\ppbb.center) {$\sim$};
- \node[scale = \fontscale, anchor = center] at ([xshift = 0.2\blocksize,yshift = -0.2\blocksize]\ppbb.center) {\textdirectcurrent};
- }
- },
- transformer/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.3\blocksize,yshift = 0.4\blocksize]\ppbb.center) -- ([xshift = -0.1\blocksize,yshift = 0.4\blocksize]\ppbb.center) -- +(0,-0.8\blocksize) -- ([xshift = -0.3\blocksize,yshift = -0.4\blocksize]\ppbb.center);
- \draw ([xshift = 0.3\blocksize,yshift = 0.4\blocksize]\ppbb.center) -- ([xshift = 0.1\blocksize,yshift = 0.4\blocksize]\ppbb.center) -- +(0,-0.8\blocksize) -- ([xshift = 0.3\blocksize,yshift = -0.4\blocksize]\ppbb.center);
- }
- },
- deadtime/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.3\blocksize,yshift = -0.3\blocksize]\ppbb.center) -- +(0,0.2\blocksize);
- \draw ([xshift = 0.3\blocksize,yshift = -0.3\blocksize]\ppbb.center) -- +(0,0.2\blocksize);
- \draw ([xshift = -0.3\blocksize,yshift = -0.2\blocksize]\ppbb.center) -- +(0.6\blocksize, 0);
- \node[anchor = center,scale = \fontscale] at ([yshift = 0.1\blocksize]\ppbb.center) {#1};
- }
- },
- schmitt trigger/.style =
- {
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.35\blocksize,yshift = -0.3\blocksize]\ppbb.center) -- +(0.35\blocksize,0) -- ([xshift = 0.2\blocksize,yshift = 0.3\blocksize]\ppbb.center) -- +(0.15\blocksize, 0);
- \draw ([xshift = 0.2\blocksize,yshift = 0.3\blocksize]\ppbb.center) -- +(-0.2\blocksize,0) -- ([xshift = -0.2\blocksize,yshift = -0.3\blocksize]\ppbb.center);
- }
- },
- nonlinear fcn/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale,anchor = center] (\ppbb.center) {$#1(\cdot)$};
- }
- },
- zero order hold/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.3\blocksize,yshift = -0.3\blocksize]\ppbb.center) -- +(0.2\blocksize,0) -- +(0.2\blocksize,0.6\blocksize) -- +(0.3\blocksize,0.6\blocksize) -- +(0.3\blocksize,0.4\blocksize) -- +(0.4\blocksize,0.4\blocksize) -- +(0.4\blocksize,0.2\blocksize) -- +(0.5\blocksize,0.2\blocksize) -- +(0.6\blocksize,0.2\blocksize);
- }
- },
- first order hold/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \draw ([xshift = -0.3\blocksize,yshift = -0.3\blocksize]\ppbb.center) -- +(0.2\blocksize,0.1\blocksize) -- +(0.3\blocksize,0.6\blocksize) -- +(0.4\blocksize,0.4\blocksize) -- +(0.5\blocksize,0.2\blocksize) -- +(0.6\blocksize,0.2\blocksize);
- }
- },
- divider/.style args =
- {#1}{
- draw,
- block,
- path picture =
- {
- \node[scale = \fontscale, anchor = center] (\ppbb.center) {$\div #1$};
- }
- },
- delay/.style args =
- {#1}{
- draw,
- block,
- node contents =
- {
- \scalebox{\fontscale}{$z^{-#1}$}
- }
- },
- transfer fcn/.style args =
- {#1}{
- draw,
- block,
- node contents =
- {
- \scalebox{\fontscale}{#1}
- }
- },
- gain/.style =
- {
- fill = \blockcolor,
- text height = 1.5ex,
- text depth = .25ex,
- draw,
- isosceles triangle,
- minimum height = 10mm,
- minimum width = 10mm,
- anchor = center,
- scale = \fontscale
- },
- sum/.style args =
- {#1}{
- draw,
- anchor = center,
- scale = \fontscale,
- fill = \blockcolor,
- circle,
- inner sep = 0.05\blocksize,
- minimum size = 0.15\blocksize,
- node contents =
- {
- \small #1
- }
- },
- junction/.style =
- {
- circle,inner sep = 0pt,
- minimum size = 0.1\blocksize,
- fill = black,
- draw = black,
- node distance = 0.5\blocksize
- },
- inout/.style =
- {
- draw,
- circle,
- inner sep = 0pt,
- minimum size = 0.1\blocksize,
- node distance = 10mm
- },
- mid arrow/.style =
- {
- postaction =
- {
- decorate,
- decoration =
- {
- markings,
- mark = at position .5 with
- {
- \arrow[#1]{latex'}
- }
- }
- }
- },
- shorten <>/.style =
- {
- shorten > = 0.1\blocksize,
- shorten < = 0.1\blocksize
- },
- between/.style args =
- {#1 and #2}{
- at = ($(#1)!0.5!(#2)$)
- },
- intersection of/.style args =
- {#1 and #2}{
- at = (#1 |- #2)
- },
- saturation/.style =
- {
- block,
- path picture =
- {
- \draw[shorten <>] (\ppbb.west) -- (\ppbb.east);
- \draw[shorten <>] (\ppbb.south) -- (\ppbb.north);
- \draw ([shift = (45:0.2\blocksize)]\ppbb.south west) -- ++(0:0.2\blocksize)--(\ppbb.center);
- \draw ([shift = (225:0.2\blocksize)]\ppbb.north east) -- ++(180:0.2\blocksize)--(\ppbb.center);
- },
- },
- dead zone/.style =
- {
- block,
- path picture =
- {
- \draw[shorten <>] (\ppbb.west) -- (\ppbb.east);
- \draw[shorten <>] (\ppbb.south) -- (\ppbb.north);
- \draw ([shift = (45:0.2\blocksize)]\ppbb.south west) -- ([xshift = -0.15\blocksize]\ppbb.center);
- \draw ([shift = (225:0.2\blocksize)]\ppbb.north east) -- ([xshift = 0.15\blocksize]\ppbb.center);
- },
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement