Debian Codegraph @

texmf-dist/doc/latex/tikz-osci/tikz-osci-doc.tex

raw
1 \documentclass[11pt,a4paper,usenames,dvipsnames]{article}
2
3
4
5 \usepackage{../tikz-osci}
6 \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
7 \usepackage[most]{tcolorbox}
8 \usepackage{hyperref}
9 \title{TikZ Oscilloscope Package}
10 \author{Thibault Giauffret}
11 \def\version{0.4.0}
12
13 % Use sans serif font
14 \renewcommand{\familydefault}{\sfdefault}
15
16 % Remove paragraph indentation
17 \setlength{\parindent}{0pt}
18
19 % Listings
20 \newtcblisting{listing}{
21 listing only,
22 hbox,
23 listing options={
24 basicstyle=\small\ttfamily,
25 breaklines=true,
26 columns=fullflexible
27 },
28 }
29
30 \begin{document}
31
32 \begin{tcolorbox}
33 \begin{center}
34 \vspace{0.3cm}
35 {\huge \textbf{TikZ Oscilloscope Package}}\\[0.3cm]
36 {\Large Thibault Giauffret}\\[0.3cm]
37 \textit{Version \version\ of \today}\\[0.3cm]
38 \vspace{0.3cm}
39 \end{center}
40 \end{tcolorbox}
41
42 \section{Introduction}
43
44 \begin{minipage}{0.5\linewidth}
45 \begin{center}
46 \osci[%
47 scale=0.7,
48 sample rate=500,
49 func one=1.78*sin(2*180/0.020*x),
50 horizontal cursor one=-1.78,
51 horizontal cursor two=1.78,
52 ]
53 \end{center}
54 \end{minipage}
55 \begin{minipage}{0.5\linewidth}
56 \begin{center}
57 \osci[%
58 scale=0.7,
59 second channel=1,
60 screen offset one=2,
61 screen offset two=-2,
62 time div=10,
63 voltage div one=4,
64 voltage div two=1,
65 sample rate=400,
66 xy mode=0,
67 func one=(sin(2*180*x/0.02)>0?6:-6),
68 func two=1*sin(2*180/0.020*x)+0.2*sin(2*180/0.040*x),
69 indicators=0,
70 color one=FAC356,
71 color two=C18FFA,
72 color text one = 000000,
73 color text two = 000000,
74 graph back color=3C4A66,
75 info back color=333333,
76 info text color=FFFFFF,
77 main axis color=DDDDDD,
78 grid color=CCCCCC,
79 ]
80 \end{center}
81 \end{minipage}
82
83 \vspace*{0.5cm}
84
85
86 This package is a modest alternative to the \texttt{pst-osci} package (not maintained anymore). It allows you to draw oscilloscope "screen shots" with \LaTeX{}, TikZ and pgfplots.
87
88 \subsection*{Contact}
89
90 Some features are not implemented yet, but the package is already usable for basic representations. I'm doing this for fun and still learning how to make \LaTeX{} packages. Therefore, I'm open to any suggestion or contribution :
91
92 \begin{center}
93 \texttt{
94 contact at ensciences dot fr
95 }
96 \end{center}
97
98 \subsection*{Issues tracker}
99
100 An issues tracker is available at :
101 \begin{center}
102 \url{https://framagit.org/ThibGiauffret/latex_packages/-/issues}.
103 \end{center}
104
105 Feel free to report any bug you find or send suggestions.\\
106
107 \textbf{Important note :} Please indicate the concerned package name in the title of the issue. For example, if you want to report an issue about this package, please use the following title : \texttt{[tikz-osci] My issue report title}.
108
109 \section{Usage}
110
111 The package is loaded with the command \verb|\usepackage{tikz-osci}|. It defines a single command, \verb|\osci|, which takes a list of options as argument. The options allow you to configure and customize the oscilloscope screen view :
112
113 \begin{tcolorbox}[enhanced,breakable,colback=white,colframe=black,width=\textwidth,left=0mm,right=0mm,top=0mm,bottom=0mm,boxsep=0mm]
114 \begin{tabular}{p{0.2\textwidth}|p{0.47\textwidth}|p{0.255\textwidth}}
115 \texttt{scale} & Scale of the oscilloscope (with \texttt{scalebox}). & Default: \texttt{1} \\\hline
116 \texttt{rounded corners} & Radius of the oscilloscope corners (in pt). & Default: \texttt{10} \\\hline
117 \texttt{second channel} & 1 if the second channel is enabled, 0 otherwise. & Default: \texttt{0} \\\hline
118 \texttt{screen offset one} & Vertical screen offset of the first channel. & Default: \texttt{0} \\\hline
119 \texttt{screen offset two} & Vertical screen offset of the second channel. & Default: \texttt{0} \\\hline
120 \texttt{time div} & Time division (in ms). & Default: \texttt{20} \\\hline
121 \texttt{voltage div one} & Voltage division of the first channel (in V). & Default: \texttt{1} \\\hline
122 \texttt{voltage div two} & Voltage division of the second channel (in V). & Default: \texttt{1} \\\hline
123 \texttt{sample rate} & Sample rate. & Default: \texttt{200} \\\hline
124 \texttt{xy mode} & 1 if the oscilloscope is in XY mode (Lissajous curve), 0 otherwise. & Default : 0 \\\hline
125 \texttt{math mode} & 1 for addition, 2 for subtraction, 3 for multiplication, 4 for division, 0 otherwise. xy mode option must be set to 0. & Default: \texttt{0} \\\hline
126 \texttt{math mode hide source} & 0 to display channels CH1 and CH2 with the third channel, 1 to hide them. & Default : \texttt{0} \\\hline
127 \texttt{func one} & Expression of the first channel (pgf maths format). Trigonometric functions are defined in degrees. & Default: \texttt{2*sin(2*180/0.020*x)} \\\hline
128 \texttt{func two} & Expression of the second channel (pgf maths format). Trigonometric functions are defined in degrees. & Default: \texttt{1*sin(2*180/0.020*x) + 0.2*sin(2*180/0.040*x)} \\\hline
129 \texttt{indicators} & 1 if the channel indicators are enabled, 0 otherwise. & Default: \texttt{1} \\\hline
130 \texttt{horizontal cursor one} & Horizontal position of the first cursor (between -4 and 4). \texttt{false} to disable. & Default: \texttt{false} \\\hline
131 \texttt{horizontal cursor two} & Horizontal position of the second cursor (between -4 and 4). \texttt{false} to disable. & Default: \texttt{false} \\\hline
132 \texttt{vertical cursor one} & Vertical position of the first cursor (between -4 and 4). \texttt{false} to disable. & Default: \texttt{false} \\\hline
133 \texttt{vertical cursor two} & Vertical position of the second cursor (between -4 and 4). \texttt{false} to disable. & Default: \texttt{false} \\\hline
134 \texttt{cursor precision} & Number of digits after the decimal point for the cursor values. & Default: \texttt{1} \\\hline
135 \texttt{color one} & Color of the first channel (in hexadecimal). & Default: \texttt{D62626} \\\hline
136 \texttt{color text one} & Text color of the first channel (in hexadecimal). & Default: \texttt{FFFFFF} \\\hline
137 \texttt{color two} & Color of the second channel (in hexadecimal). & Default: \texttt{1053AF} \\\hline
138 \texttt{color text two} & Text color of the second channel (in hexadecimal). & Default: \texttt{FFFFFF} \\\hline
139 \texttt{color three} & Color of the XY mode and the math mode (in hexadecimal). & Default: \texttt{2E8B73} \\\hline
140 \texttt{color text three} & Text color of the XY mode and the math mode (in hexadecimal). & Default: \texttt{FFFFFF} \\\hline
141 \texttt{graph back color} & Background color of the graph (in hexadecimal). & Default: \texttt{FFFFFF} \\\hline
142 \texttt{info back color} & Background color of the information box (in hexadecimal). & Default: \texttt{D6D6D6} \\\hline
143 \texttt{info text color} & Text color of the information box (in hexadecimal). & Default: \texttt{000000} \\\hline
144 \texttt{main axis color} & Color of the main axis (in hexadecimal). & Default: \texttt{000000} \\\hline
145 \texttt{grid color} & Color of the grid (in hexadecimal). & Default: \texttt{CCCCCC}
146 \end{tabular}
147 \end{tcolorbox}
148
149
150 \begin{tcolorbox}[enhanced,breakable,colback=white,colframe=black,width=\textwidth,left=0mm,right=0mm,top=0mm,bottom=0mm,boxsep=0mm]
151 \begin{tabular}{p{0.2\textwidth}|p{0.47\textwidth}|p{0.255\textwidth}}
152
153 \texttt{horizontal cursor color} & Color of the horizontal cursor (in hexadecimal). & Default: \texttt{FFA500} \\\hline
154 \texttt{vertical cursor color} & Color of the vertical cursor (in hexadecimal). & Default: \texttt{800080}\\\hline
155 \texttt{smooth one} & 1 to smooth the first channel, 0 otherwise. & Default: \texttt{0}\\\hline
156 \texttt{smooth two} & 1 to smooth the second channel, 0 otherwise. & Default: \texttt{0}\\\hline
157 \texttt{smooth three} & 1 to smooth the third channel, 0 otherwise. & Default: \texttt{0}
158 \end{tabular}
159 \end{tcolorbox}
160
161
162 A quick documentation in french is available here :
163
164 \begin{center}
165 \url{https://www.ensciences.fr/read.php?article=1220}
166 \end{center}
167
168
169 \section{Examples}
170
171 For more examples, see the \texttt{tikz-osci-example.tex} file.
172
173 \begin{tcblisting}{enhanced,colback=white,colframe=black,width=\textwidth, title=\bfseries Two channels plot with custom background color, sidebyside}
174 \osci[%
175 scale=0.7,
176 second channel=1,
177 screen offset one=2,
178 screen offset two=-2,
179 time div=20,
180 voltage div one=4,
181 voltage div two=1,
182 sample rate=200,
183 xy mode=0,
184 func one=2*sin(2*180/0.020*x),
185 func two=1*sin(2*180/0.020*x) + 0.2*sin(2*180/0.040*x),
186 color one=D62626,
187 color two=1053AF,
188 graph back color=669966,
189 info back color=D6D6D6,
190 grid color=CCCCCC
191 ]
192 \end{tcblisting}
193
194 \begin{tcblisting}{enhanced,colback=white,colframe=black,width=\textwidth, title=\bfseries Lissajous curve (XY mode) and no rounded corner, sidebyside}
195 \osci[%
196 scale=0.7,
197 rounded corners=0,
198 second channel=1,
199 time div=300,
200 voltage div one=1,
201 voltage div two=0.5,
202 sample rate=500,
203 xy mode=1,
204 func one=sin(7*x),
205 func two=sin(2*x),
206 indicators=1,
207 graph back color=FFFFFF,
208 info back color=D6D6D6,
209 info text color=000000,
210 main axis color=000000,
211 grid color=CCCCCC,
212 ]
213 \end{tcblisting}
214
215 \begin{tcblisting}{enhanced,colback=white,colframe=black,width=\textwidth, title=\bfseries Math mode (multiply) with hidden sources and dark mode, sidebyside}
216 \osci[%
217 scale=0.7,
218 second channel=1,
219 time div=10,
220 voltage div one=2,
221 voltage div two=2,
222 sample rate=500,
223 xy mode=0,
224 math mode=3,
225 math mode hide source=1,
226 func one=2*sin(2*180/0.040*x),
227 func two=3*sin(2*180/0.005*x),
228 indicators=0,
229 color three=F0DE25,
230 color text three=000000,
231 graph back color=777799,
232 info back color=333333,
233 info text color=FFFFFF,
234 main axis color=DDDDDD,
235 grid color=CCCCCC,
236 ]
237 \end{tcblisting}
238
239 \begin{tcblisting}{enhanced,colback=white,colframe=black,width=\textwidth, title=\bfseries Common periodic signals,sidebyside}
240 % Square wave function
241 \pgfmathdeclarefunction{square}{4}{%
242 \pgfmathparse{(sin(2*180*x/#2+#4) + #3>0?#1:-#1)}%
243 }
244
245 % Triangle wave function
246 \pgfmathdeclarefunction{triangle}{4}{%
247 \pgfmathparse{#1*asin(sin(2*180/#2*x + #4))/90}%
248 }
249
250 \osci[%
251 scale=0.7,
252 second channel=1,
253 sample rate=1000,
254 time div=100,
255 func one={triangle(2,0.2,0,0)},
256 func two={square(2,0.2,0,0)},
257 smooth one = 1,
258 smooth two = 0,
259 ]
260 \end{tcblisting}
261
262 \begin{tcblisting}{enhanced,colback=white,colframe=black,width=\textwidth, title=\bfseries Vertical and horizontal cursors (values displayed with two digits),sidebyside}
263 \osci[%
264 scale=0.7,
265 second channel=0,
266 time div=100,
267 voltage div one=1,
268 sample rate=200,
269 func one={sin(2*180*x)},
270 vertical cursor one=-2.5,
271 vertical cursor two=2.5,
272 horizontal cursor one=1,
273 horizontal cursor two=-1,
274 cursor precision=2
275 ]
276 \end{tcblisting}
277
278 \section{License}
279
280 This package is distributed under the terms of the \textbf{LaTeX Project Public License} (LPPL), version 1.3c or later. The latest version of this license is available at \url{http://www.latex-project.org/lppl.txt}.
281
282 \section{Credits}
283
284 This package requires the following packages :
285 \begin{itemize}
286 \item \texttt{xcolor} maintained by the \textit{LaTeX3 Project} (license LPPL 1.3c) ;
287 \item tikz maintained by the \textit{TikZ and PGF Project} (license LPPL 1.3c) ;
288 \item pgfkeys maintained by the \textit{Till Tantau} (license LPPL) ;
289 \item pgfplots maintained by the \textit{Christian Feuersänger} (license LPPL).
290 \end{itemize}
291
292 \section{Changelog}
293
294 \begin{itemize}
295 \item \textbf{0.4.0} (2023/10/24) :
296 \subitem Added cursor and smooth options.
297 \subitem Added square and triangle plot examples.
298 \subitem Fixed the pgf keys declaration.
299 \item \textbf{0.3.0} (2023/10/08) :
300 \subitem Implemented XY mode and math (add, subtract, multiply, divide) functionalities.
301 \item \textbf{0.2.0} (2023/10/07) :
302 \subitem Added \texttt{color text one}, \texttt{color text two} and \texttt{color text xy} options.
303 \subitem Added \texttt{indicators} option.
304 \subitem Added \texttt{rounded corners} option.
305 \subitem Fixed the main axis color not being applied.
306 \subitem Reworded the documentation and the example file.
307 \item \textbf{0.1.1} (2023/10/06) :
308 \subitem Renamed \texttt{sub axis color} to \texttt{grid color}.
309 \subitem Renamed \texttt{expr one} and \texttt{expr two} to \texttt{func one} and \texttt{func two}.
310 \subitem Updated package files names.
311 \item \textbf{0.1.0} (2023/10/06) : Initial release. XY mode not implemented yet.
312 \end{itemize}
313
314 \end{document}