0

See my MWE:

\documentclass{scrartcl}

\usepackage{tikz}

\usetikzlibrary{ positioning, datavisualization.formats.functions } \tikzset{ signal/.style = coordinate, block/.style = { draw, rectangle, minimum height = 4em, minimum width = 5em }, stepp/.style = { block, path picture = { \draw ([ xshift = 5pt, yshift = 5pt ]path picture bounding box.south west) -| ([yshift = -5pt]path picture bounding box.north) -- ([ xshift = -5pt, yshift = -5pt ]path picture bounding box.north east); } }, chirp/.style = { block, path picture = { \datavisualization[ xy Cartesian, visualize as smooth line ] data[format = function] { var x : interval[0 : pi]; func y = sin(2 * pi * (1 + (500 - 1) / 2 / 10 * \value x) * \value x); %u(t) = sin(2pi(f_0 + (f_e - f_0) / 2t_e)t), with %start frequency f_0 in Hz, %end frequency f_e in Hz, %end time t_e in s and %time t in s }; } }, saturation/.style = { block, path picture = { \draw [lightgray] ([yshift = 5pt]path picture bounding box.south) -- ([yshift = -5pt]path picture bounding box.north) ([xshift = 5pt]path picture bounding box.west) -- ([xshift = -5pt]path picture bounding box.east); \draw ([ xshift = 7pt, yshift = 10pt ]path picture bounding box.south west) -- ([ xshift = -5pt, yshift = 10pt ]path picture bounding box.south) -- ([ xshift = 5pt, yshift = -10pt ]path picture bounding box.north) -- ([ xshift = -7pt, yshift = -10pt]path picture bounding box.north east); } }, counter/.style = { block, path picture = { \node at (path picture bounding box.north east) {lim}; \datavisualization[ xy Cartesian, visualize as line ] data { x, y 0, 0 1, 0 1, 1 2, 1 2, 2 3, 2 3, 3 4, 3 4, 0 5, 0 5, 1 6, 1 6, 2 7, 2 7, 3 8, 3 8, 0 }; } } }

\begin{document}

\begin{tikzpicture} %placing the nodes \node[stepp] (step) {}; \node[ saturation, above = of step ] (saturation) {}; \node[ chirp, left = of saturation ] (chirp) {}; \node[ counter, below = of step ] (counter) {}; \node[ signal, right = of step ] (input) {}; \node[ block, right = of input ] (inputInterface) {}; %connecting the nodes \foreach \i/\k in { saturation/1, counter/-1 } { \draw (\i) -| ([yshift = \k15pt]input); \draw [->] ([yshift = \k15pt]input.east) -- ([yshift = \k*15pt]inputInterface.west); } \draw [->] (chirp) -- (saturation); \draw [->] (step) -- (inputInterface); \end{tikzpicture}

\end{document}

And the result:

result

In need for the each of the four blocks on the left side a different figure inside. Here are the given figures: chirpsaturationstepcounter.

I managed to create two of them. The code for the remaining two is functional too, but I didn't achieved the integration of the code into the blocks. The results of the code for the two unfinished blocks should somehow scaled and moved to the correct place within the blocks.

Every solution is welcome! General optimization of my code is very desired (it is very likely there are more efficient and intuitive solutions)!

Thank you for your help and effort in advance!

Su-47
  • 2,508

2 Answers2

2

This is a possible solution. It doesn't use datavisualization but regular draw inside the path picture for the counter bloc.

For the chirp bloc I couldn't manage to adjust the plot function inside the path picture. As al altenative, I've defined a pic which is drawn over an empty block.

\documentclass{scrartcl}

\usepackage{tikz}

\usetikzlibrary{ positioning, datavisualization.formats.functions } \tikzset{ chirppic/.pic={ \draw[scale=.5] plot[domain=0:pi, samples=50, smooth] (\x,{sin(2pi(1+(500-1)/2/10\x)\x)}); }, signal/.style = coordinate, block/.style = { draw, rectangle, minimum height = 4em, minimum width = 5em }, stepp/.style = { block, path picture = {% \draw([shift={(5pt,5pt)}]path picture bounding box.south west) -| ([yshift = -5pt]path picture bounding box.north) -- ([shift ={(-5pt,-5pt)}]path picture bounding box.north east); } }, chirp/.style = { block, % path picture = {% % \draw[scale=.5] (path picture bounding box.west)+
% plot[domain=0:pi, samples=100] % (\x,{sin(2pi(1+(500-1)/2/10\x)\x)}); } }, saturation/.style = {% block, path picture = {% \draw[lightgray] ([yshift = 5pt]path picture bounding box.south) -- ([yshift = -5pt]path picture bounding box.north) ([xshift = 5pt]path picture bounding box.west) -- ([xshift = -5pt]path picture bounding box.east); \draw([shift = {(7pt,10pt)}]path picture bounding box.south west) -- ([shift ={(-5pt,10pt)}]path picture bounding box.south) -- ([shift ={(5pt,-10pt)}]path picture bounding box.north) -- ([shift ={(-7pt,-10pt)}]path picture bounding box.north east); } }, counter/.style = {% block, label={[font=\sffamily\small, anchor=north west]north west:lim}, path picture = {% \draw ([shift={(6pt,6pt)}]path picture bounding box.south west) foreach \x in {1,...,6}{-|++(3pt,4pt)} -|++(3pt,-24pt) foreach \x in {1,...,6}{-|++(3pt,4pt)} -|++(3pt,-24pt); } }
}

\begin{document}

\begin{tikzpicture} %placing the nodes \node[stepp] (step) {}; \node[ saturation, above = of step ] (saturation) {}; \node[ chirp, left = of saturation ] (chirp) {}; \pic at ([xshift=2mm]chirp.west) {chirppic}; \node[ counter, below = of step ] (counter) {}; \node[ signal, right = of step ] (input) {}; \node[ block, right = of input ] (inputInterface) {}; %connecting the nodes \foreach \i/\k in { saturation/1, counter/-1 } { \draw (\i) -| ([yshift = \k15pt]input); \draw [->] ([yshift = \k15pt]input.east) -- ([yshift = \k*15pt]inputInterface.west); } \draw [->] (chirp) -- (saturation); \draw [->] (step) -- (inputInterface); \end{tikzpicture}

\end{document}

enter image description here

Ignasi
  • 136,588
  • Hello @Ignasi! Thank you for your answer! If possible I would prefer a solution with datavisualization. – Su-47 Nov 15 '22 at 16:45
0

I finally found a solution with datavisualization, but with a detour:

\documentclass{scrartcl}

\usepackage{tikz}

\usetikzlibrary{ positioning, datavisualization.formats.functions } \tikzset{ signal/.style = coordinate, block/.style = { draw, rectangle, minimum height = 4em, minimum width = 5em }, stepp/.style = { block, path picture = { \draw ([ xshift = 5pt, yshift = 5pt ]path picture bounding box.south west) -| ([yshift = -5pt]path picture bounding box.north) -- ([ xshift = -5pt, yshift = -5pt ]path picture bounding box.north east); } }, saturation/.style = { block, path picture = { \draw [lightgray] ([yshift = 5pt]path picture bounding box.south) -- ([yshift = -5pt]path picture bounding box.north) ([xshift = 5pt]path picture bounding box.west) -- ([xshift = -5pt]path picture bounding box.east); \draw ([ xshift = 7pt, yshift = 10pt ]path picture bounding box.south west) -- ([ xshift = -5pt, yshift = 10pt ]path picture bounding box.south) -- ([ xshift = 5pt, yshift = -10pt ]path picture bounding box.north) -- ([ xshift = -7pt, yshift = -10pt]path picture bounding box.north east); } } }

\begin{document}

\newsavebox\counter \begin{lrbox}{\counter} \begin{tikzpicture}[scale = .195] \datavisualization[ xy Cartesian, visualize as line ] data {x, y 0, 0 1, 0 1, 1.5 2, 1.5 2, 2.5 3, 2.5 3, 3.5 4, 3.5 4, 0 5, 0 5, 1.5 6, 1.5 6, 2.5 7, 2.5 7, 3.5 8, 3.5 8, 0 }; \end{tikzpicture} \end{lrbox} \newsavebox\chirp \begin{lrbox}{\chirp} \begin{tikzpicture}[scale = .5] \datavisualization[ xy Cartesian, visualize as smooth line ] data[format = function] { var x : interval[0 : pi]; func y = sin(2 * pi * (1 + (500 - 1) / 2 / 10 * \value x) * \value x); %u(t) = sin(2pi(f_0 + (f_e - f_0) / 2t_e)t), with %start frequency f_0 in Hz, %end frequency f_e in Hz, %end time t_e in s and %time t in s }; \end{tikzpicture} \end{lrbox}

\begin{tikzpicture} %placing the nodes \node[stepp] (step) {}; \node[ saturation, above = of step ] (saturation) {}; \node[ block, left = of saturation ] (chirp) {\usebox\chirp}; \node[ block, below = of step, align=left ] (counter) {lim\[.35\baselineskip]\usebox\counter}; \node[ signal, right = of step ] (input) {}; \node[ block, right = of input ] (inputInterface) {}; %connecting the nodes \foreach \i/\k in { saturation/1, counter/-1 } { \draw (\i) -| ([yshift = \k15pt]input); \draw [->] ([yshift = \k15pt]input.east) -- ([yshift = \k*15pt]inputInterface.west); } \draw [->] (chirp) -- (saturation); \draw [->] (step) -- (inputInterface); \end{tikzpicture}

\end{document}

Su-47
  • 2,508