Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Oscilloscope #176

Closed
nobrl opened this issue Apr 2, 2019 · 5 comments
Closed

Request: Oscilloscope #176

nobrl opened this issue Apr 2, 2019 · 5 comments

Comments

@nobrl
Copy link

@nobrl nobrl commented Apr 2, 2019

If I am not mistaken there is no oscilloscope symbol in the current package. I did find a scope symbol on stackexchange .
Is it possible to add it to the next version of the package?

Here is the code written by Sebastian Golat :

\makeatletter
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}

\newlength{\ResUp} \newlength{\ResDown}
\newlength{\ResLeft} \newlength{\ResRight}
\ctikzset{bipoles/SCOPE/height/.initial=.60}
\ctikzset{bipoles/SCOPE/width/.initial=.60}
\pgfcircdeclarebipole{}
{\ctikzvalof{bipoles/SCOPE/height}}
{SCOPE}
{\ctikzvalof{bipoles/SCOPE/height}}
{\ctikzvalof{bipoles/SCOPE/width}}
{
    \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
    \pgfextracty{\ResUp}{\northeast}    %ResUp make usable
    \pgfextractx{\ResRight}{\northeast} %ResRight make usable
    \pgfextractx{\ResLeft}{\southwest}  %ResLeft make usable
    \pgfextracty{\ResDown}{\southwest}  %ResDown make usable
    \def\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
        \ifnum \pgfcircmathresult > 45 \ifnum \pgfcircmathresult < 135
            \pgftransformrotate{270}
        \fi\fi
        \ifnum \pgfcircmathresult > 135 \ifnum \pgfcircmathresult < 225
            \pgftransformrotate{180}
        \fi\fi
        \ifnum \pgfcircmathresult > 225 \ifnum \pgfcircmathresult < 315
            \pgftransformrotate{90}
        \fi\fi
    \pgfpathmoveto{\pgfpoint{0.75\ResLeft}{0.25\ResDown}}
    \pgfpathlineto{\pgfpoint{0.05\ResLeft}{0.25\ResUp}}
    \pgfpathlineto{\pgfpoint{0.05\ResLeft}{0.25\ResDown}}
    \pgfpathlineto{\pgfpoint{0.65\ResRight}{0.25\ResUp}}
    \pgfpathlineto{\pgfpoint{0.65\ResRight}{0.25\ResDown}}

    \pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\ResUp}}{\pgfpoint{\ResLeft}{0}}
    \pgfusepath{draw}
}
\def\SCOPEpath#1{\TikzBipolePath{SCOPE}{#1}}
\tikzset{SCOPE/.style = {\circuitikzbasekey, /tikz/to path=\SCOPEpath, l=#1}}
\makeatother
@Rmano
Copy link
Collaborator

@Rmano Rmano commented Apr 2, 2019

I am a bit confused about that symbol; I can't really fathom what "insert an oscilloscope in series" can ever mean. Maybe could be better to add a kind of optional "waveform" symbol to the ammeter/voltmeter?
Or having a "probe" symbol (voltage and current) a-la LTSpice?

Anyway, I will try something about it. If you like to propose a PR I'll evaluate it; notice that

  • no ALLCAPS names; scope or oscope is ok;
  • the component must have a description in the manual also.
  • about the ground / hot symbol:
    • I don't think it's general enough (think differential probes);
    • Much better having a couple of anchors and let the user do it (like node[ground, scale=0.5]{} at (myscope.right) or similar.

Thanks!

@nobrl
Copy link
Author

@nobrl nobrl commented Apr 2, 2019

I can't fathom either what "insert an oscilloscope in series" can ever mean. But I found myself in a situation where I needed an oscilloscope symbol. The "waveform" symbol to the ammeter/voltmeter seems a good solution to me (except maybe for differential probes).
image

@Rmano
Copy link
Collaborator

@Rmano Rmano commented Apr 2, 2019

Ok, modifying the ammeter/voltmeter is quite easy. I'll look into it (if you don't beat me) after I am finished with the work on #175.
The only fine thing is to "unrotate" the waveform symbol; the solution here works only for multiple of 90 degrees, but we can use the solution from https://tex.stackexchange.com/questions/473544/unrotate-part-of-a-pgfdeclareshape

@Rmano Rmano mentioned this issue Apr 3, 2019
8 tasks
@Rmano Rmano added this to the release 0.9.0 milestone Apr 8, 2019
@Rmano
Copy link
Collaborator

@Rmano Rmano commented Apr 11, 2019

@nobrl What do you think of this:
image

The graph (apart for the manual description boxes) is obtained with

\begin{circuitikz}
        \foreach \a in {0,45,...,350} {
            \draw (0,0) to[oscope] (\a:3);
        }
        \draw (4,1) to[oscope, fill=green!20!gray, name=O1] ++(3,0);
        \path (O1.right) node[ground, scale=0.5, below right=4pt]{};
        \draw (5,-1) node[oscopeshape, fill=yellow!20!orange](O2){};
        \draw (O2.in 2) to[short, *-] ++(0,-0.5) node[ground]{};
        \draw (O2.in 1) to[short, *-] ++(0,-0.5) -- ++(-1,0) node[currarrow, xscale=-1]{};
\end{circuitikz}

@nobrl
Copy link
Author

@nobrl nobrl commented Apr 11, 2019

That's much more than what I was proposing. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants