Retour

Source de pst-am.tex

Fichier TeX
%%
%% This is file `pst-am.tex',
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%% `pst-am' is a package intended for the representation
%% of the amplitude modulation of the radio waves
\csname PSTamLoaded\endcsname
\let\PSTamLoaded\endinput
% Requires PSTricks, pst-node, pst-plot,pst-xkey
\ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
\ifx\PSTplotLoaded\endinput\else\input pst-plot.tex\fi
\ifx\PSTnodesLoaded\endinput\else\input pst-node.tex\fi
\ifx\PSTXKeyLoaded\endinput\else\input pst-xkey.tex \fi
% Requires numprint
\RequirePackage{numprint}
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\def\fileversion{1.0}
\def\filedate{2007/04/28}
\message{`PST-am' v\fileversion, \filedate}
%
\pst@addfams{pst-AM}
\SpecialCoor
\definecolor{Bleu}{cmyk}{1,1,0,0.3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpsstyle{cadre}{framearc=0.05,linecolor=black}
\newpsstyle{screen}{fillstyle=solid,fillcolor=yellow!70!white!30}
\newpsstyle{signalModulant}{plotpoints=1000,linecolor=green,linewidth=2\pslinewidth}
\newpsstyle{signalPorteuse}{plotpoints=2000,linecolor=blue}
\newpsstyle{signalRedresse}{plotpoints=2000,linecolor=Bleu}
\newpsstyle{signalDemodule}{plotpoints=4000,linecolor=red}
\newpsstyle{signalModule}{plotpoints=4000,linecolor=blue}
\newpsstyle{XY}{plotpoints=4000,linecolor=blue}
%
\define@key[psset]{pst-AM}{frequencePorteuse}{\def\psk@frequencePorteuse{#1}}
\define@key[psset]{pst-AM}{frequenceAudio}{\def\psk@frequenceAudio{#1}}
\psset[pst-AM]{frequencePorteuse=2e4,frequenceAudio=1e3} % les fréquences
%
\define@key[psset]{pst-AM}{R}{\def\psk@resistor{#1}}
\define@key[psset]{pst-AM}{C}{\def\psk@capacitor{#1}}
\psset[pst-AM]{R=3300,C=3.9e-8}
%
\define@key[psset]{pst-AM}{U0}{\def\psk@offset{#1}}
\psset[pst-AM]{U0=2}
%
\define@key[psset]{pst-AM}{Up}{\def\psk@Up{#1}}
\define@key[psset]{pst-AM}{Um}{\def\psk@Um{#1}}
\psset[pst-AM]{Up=3.5,Um=1}
%
\define@key[psset]{pst-AM}{k}{\def\psk@k{#1}}
\psset[pst-AM]{k=0.1} % coefficient multiplicateur
%
\define@key[psset]{pst-AM}{timeDiv}{\def\psk@timeDiv{#1}}
\define@key[psset]{pst-AM}{voltDivY1}{\def\psk@voltDivA{#1}} % coeff d'amplitude vertical voie Y1
\define@key[psset]{pst-AM}{voltDivY2}{\def\psk@voltDivB{#1}} % coeff d'amplitude vertical voie Y2
\psset[pst-AM]{timeDiv=2e-4,voltDivY1=1,voltDivY2=1}
%
%
\newif\ifPst@SignalModule%
\define@key[psset]{pst-AM}{SignalModule}[true]{\@nameuse{Pst@SignalModule#1}}
%
\newif\ifPst@SignalPorteuse%
\define@key[psset]{pst-AM}{SignalPorteuse}[true]{\@nameuse{Pst@SignalPorteuse#1}}
%
\newif\ifPst@SignalRedresse%
\define@key[psset]{pst-AM}{SignalRedresse}[true]{\@nameuse{Pst@SignalRedresse#1}}
%
\newif\ifPst@SignalDemodule%
\define@key[psset]{pst-AM}{SignalDemodule}[true]{\@nameuse{Pst@SignalDemodule#1}}
%
\newif\ifPst@SignalModulant%
\define@key[psset]{pst-AM}{SignalModulant}[true]{\@nameuse{Pst@SignalModulant#1}}
%
\newif\ifPst@SignalModule%
\define@key[psset]{pst-AM}{SignalModule}[true]{\@nameuse{Pst@SignalModule#1}}
%
\newif\ifPst@SignalFinal%
\define@key[psset]{pst-AM}{SignalFinal}[true]{\@nameuse{Pst@SignalFinal#1}}
%
\newif\ifPst@Enveloppe%
\define@key[psset]{pst-AM}{enveloppe}[true]{\@nameuse{Pst@Enveloppe#1}}
%
\newif\ifPst@XY%
\define@key[psset]{pst-AM}{XY}[true]{\@nameuse{Pst@XY#1}}
%
\newif\ifPst@Offset%
\define@key[psset]{pst-AM}{traceU0}[true]{\@nameuse{Pst@Offset#1}}
%
\newif\ifPst@pourcalculm%
\define@key[psset]{pst-AM}{UM&Um}[true]{\@nameuse{Pst@pourcalculm#1}}
%
\newif\ifPst@valeurs%
\define@key[psset]{pst-AM}{valeurs}[true]{\@nameuse{Pst@valeurs#1}}
%
\newif\ifPst@NB%
\define@key[psset]{pst-AM}{N&B}[true]{\@nameuse{Pst@NB#1}}
%
\def\psAM{\@ifnextchar[{\psAM@i}{\psAM@i[]}}
\def\psAM@i[#1]{{%
\pst@killglue
\psset{#1}
\pnode(!%
        1 setlinejoin
        /PI 3.14159 def
        /Tp {1 \psk@frequencePorteuse\space div} bind def % période du signal modulés
        /Ap \psk@Up\space def % amplitude porteuse
        /Fm \psk@frequenceAudio\space def % fréquence signa modulant
        /Tm {1 Fm div} bind def % période du signal modulant
        /Am \psk@Um\space def % amplitude signal modulant
        /U0 \psk@offset\space def % décalage
        /k \psk@k\space def
        /R \psk@resistor\space def
        /C \psk@capacitor\space def
        /m {Am U0 div} bind def
        /Umin {k Ap mul U0 mul 1 m sub mul} bind def
        /Umax {k Ap mul U0 mul 1 m add mul} bind def
        /composanteContinue {Umax Umin add 2 div} bind def
        /Tau {R C mul} bind def
        /TimeDiv \psk@timeDiv\space def % base de temps
        /VoltDivY1 \psk@voltDivA\space def % amplitude verticale voie Y1
        /VoltDivY2 \psk@voltDivB\space def % amplitude verticale voie Y2
        /DecalageTemps 0 def
        0 0){MEM}%
\ifPst@NB
 \newpsstyle{signalModulant}{plotpoints=1000,linewidth=2\pslinewidth}
 \newpsstyle{signalPorteuse}{plotpoints=2000}
 \newpsstyle{signalRedresse}{plotpoints=2000}
 \newpsstyle{signalDemodule}{plotpoints=4000}
 \newpsstyle{signalModule}{plotpoints=4000}
 \newpsstyle{XY}{plotpoints=4000}
\fi
\pspicture(0,-5)(10,5)
\psframe[style=cadre](-0.1,-4.5)(10.1,4.5)
\psframe[style=screen](0,-4)(10,4)
\rput(5,4.25){\textsf{\large modulation-démodulation}}
\rput(5,-4.25){\textsf{\large Lycée Augustin Fresnel}}
\rput(2.5,-3.5){\textsf{\large timeDiv:\numprint{\psk@timeDiv} s/div}}
\uput[0](6,-3.7){\textsf{\large voie 2:\psk@voltDivB V/div}}
\uput[0](6,-3.3){\textsf{\large voie 1:\psk@voltDivA V/div}}
\psclip{\psframe[linestyle=none](0,-4)(10,4)}
\ifPst@XY
\parametricplot[style=XY]{0}{10}{% durée
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /FonctionPorteuse Ap 360 Tp div temps mul cos mul def
        /SignalModule FonctionPorteuse SignalModulant mul k mul def
         SignalModulant VoltDivY1 div 5 add SignalModule VoltDivY2 div}
\else
  \ifPst@SignalModule
   \parametricplot[style=signalModule]{0}{10}{% durée
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /FonctionPorteuse Ap 360 Tp div temps mul cos mul def
        /SignalModule FonctionPorteuse SignalModulant mul k mul def
         t SignalModule VoltDivY2 div }
  \ifPst@Enveloppe
    \parametricplot[style=signalModulant]{0}{10}{%
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /enveloppeSup Ap SignalModulant mul k mul def
       t enveloppeSup VoltDivY2 div }
    \parametricplot[style=signalModulant]{0}{10}{%
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /enveloppeInf Ap SignalModulant mul k mul neg def
        t enveloppeInf VoltDivY2 div }
  \fi
 \fi
  \ifPst@SignalRedresse
   \parametricplot[style=signalRedresse]{0}{10}{% durée
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /FonctionPorteuse Ap 360 Tp div temps mul cos mul def
        /SignalModule FonctionPorteuse SignalModulant mul k mul def
       SignalModule 0 le {/SignalRedresse 0 def} {/SignalRedresse SignalModule def} ifelse
        t SignalRedresse VoltDivY2 div }
  \fi
 \ifPst@SignalDemodule
  \parametricplot[style=signalDemodule]{0}{10}{%
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /FonctionPorteuse Ap 360 Tp div temps mul cos mul def
        /SignalModule FonctionPorteuse SignalModulant mul k mul def
        SignalModule 0 le {/SignalRedresse 0 def} {/SignalRedresse SignalModule def} ifelse
        /Uc U0 Ap mul
            1
            m DecalageTemps 360 mul Tm div cos mul
            add
            mul 2.718 temps DecalageTemps sub Tau div neg exp mul k mul def
        Uc SignalRedresse ge {/SignalDemodule Uc def} % si condition réalisée
                             {/SignalDemodule SignalRedresse def
                              /DecalageTemps temps Tp div floor Tp mul def}
         ifelse
        t SignalDemodule VoltDivY2 div }
 \fi
 \ifPst@SignalModulant%
  \parametricplot[style=signalModulant]{0}{10}{%
    % 1 div=0.2 ms
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        t SignalModulant VoltDivY1 div }
 \fi
 \ifPst@SignalPorteuse
   \parametricplot[style=signalPorteuse]{0}{10}{% durée
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /FonctionPorteuse Ap 360 Tp div temps mul cos mul def
         t FonctionPorteuse VoltDivY1 div }
 \fi
\fi
\ifPst@SignalFinal
  \parametricplot[style=signalDemodule]{0}{10}{%
        /temps t TimeDiv mul def % t est en s
        /SignalModulant temps Fm mul 360 mul cos Am mul U0 add def
        /FonctionPorteuse Ap 360 Tp div temps mul cos mul def
        /SignalModule FonctionPorteuse SignalModulant mul k mul def
        SignalModule 0 le {/SignalRedresse 0 def} {/SignalRedresse SignalModule def} ifelse
        /Uc U0 Ap mul
            1
            m DecalageTemps 360 mul Tm div cos mul
            add
            mul 2.718 temps DecalageTemps sub Tau div neg exp mul k mul def
        Uc SignalRedresse ge {/SignalDemodule Uc def} % si condition réalisée
                             {/SignalDemodule SignalRedresse def
                              /DecalageTemps temps Tp div floor Tp mul def}
         ifelse
        t SignalDemodule composanteContinue sub VoltDivY2 div }
\fi

\pnode(!  0 Umax VoltDivY2 div){UM1}
\pnode(! 10 Umax VoltDivY2 div){UM2}
\pnode(!  0 Umin VoltDivY2 div){Um1}
\pnode(! 10 Umin VoltDivY2 div){Um2}
\pnode(!  0 U0 VoltDivY1 div){U01}
\pnode(! 10 U0 VoltDivY1 div){U02}
\endpsclip
\psgrid[gridlabels=0,subgriddiv=0,gridwidth=0.5\pslinewidth,subgridwidth=0.2\pslinewidth,gridcolor=black,subgridcolor=black](0,-4)(10,4)
\psline[linestyle=dotted,linecolor=black](0,2.5)(10,2.5)
\psline[linestyle=dotted,linecolor=black](0,-2.5)(10,-2.5)
\multido{\nxDiv=0.0+0.2}{50}{%
\psline[linecolor=black,linewidth=0.5\pslinewidth](\nxDiv,-.1)(\nxDiv,0.1)}
% ajout 29 janvier 2003
\multido{\nxDiv=0.0+0.2}{50}{%
\psline[linecolor=black,linewidth=0.5\pslinewidth](\nxDiv,-2.05)(\nxDiv,-1.95)}
\multido{\nxDiv=0.0+0.2}{50}{%
\psline[linecolor=black,linewidth=0.5\pslinewidth](\nxDiv,2.05)(\nxDiv,1.95)}
%
\multido{\nyDiv=-4.0+0.2}{40}{%
\psline[linecolor=black,linewidth=0.5\pslinewidth](4.9,\nyDiv)(5.1,\nyDiv)}
\ifPst@Offset
    \psline[linecolor=green,linestyle=dashed](U01)(U02)
    \uput[l](U01){$U_0$}
\fi
\ifPst@pourcalculm%
\psline[linecolor=blue,linestyle=dashed](UM1)(UM2)
\psline[linecolor=blue,linestyle=dashed](Um1)(Um2)
    \uput[l](Um1){$U_m$}
    \uput[l](UM1){$U_M$}
\fi
\endpspicture%

\ifPst@valeurs
\begin{tabular}{|l|l|}
  \hline
  Amplitude porteuse & \numprint{\psk@Up}\ V \\ \hline
  Amplitude audio & \numprint{\psk@Um}\ V \\ \hline
  Fréquence porteuse & \numprint{\psk@frequencePorteuse}\ Hz \\ \hline
  Fréquence audio & \numprint{\psk@frequenceAudio}\ Hz\\  \hline
  Décalage($U_0$) & \numprint{\psk@offset}\ V\\  \hline
  \multicolumn{1}{|c|}{R} & \numprint{\psk@resistor}\ $\Omega$ \\ \hline
  \multicolumn{1}{|c|}{C} & \numprint{\psk@capacitor}\ F \\ \hline
\end{tabular}
\fi
}}
%
\catcode`\@=\PstAtCode\relax
%
%% END: pst-am.tex
\endinput