summaryrefslogtreecommitdiff
path: root/graphics/pstricks/contrib/pst-am/pst-am.sty
blob: 147f829547998288af16a42d40aa8f85d9cd3b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
%% $Id: pst-am.sty 380 2010-09-04 08:09:34Z herbert $
%%
%% This is file `pst-am.sty',
%%
%% 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.
%%
%% Manuel Luque <Mluque5130 _at_ aol.com> (France)
%% Herbert Voss <hvoss _at_ tug.org (Germany)
%%
%%
%% DESCRIPTION:
%% `pst-am' is a package intended for the representation
%% of the amplitude modulation of the radio waves
%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{pstricks}
\RequirePackage{pst-plot}
\RequirePackage{pst-node}
\RequirePackage{pst-xkey}
\RequirePackage{numprint}
\RequirePackage{multido}
%
\def\filedate{2010/09/04}
\def\fileversion{1.02}
\ProvidesPackage{pst-am}[\filedate\ v\fileversion\ Modulation of radio waves (ml,hv)]
%
\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}{title}{\def\psk@title{#1}}
\define@key[psset]{pst-am}{frequencePorteuse}[2e4]{\def\psk@frequencePorteuse{#1}}
\define@key[psset]{pst-am}{frequenceAudio}[1e3]{\def\psk@frequenceAudio{#1}}
\psset[pst-am]{title={},%{Luc\'e Auguste Fresnel},
  frequencePorteuse=2e4,frequenceAudio=1e3} % les fréquences
%
\define@key[psset]{pst-am}{R}[3300]{\def\psk@resistor{#1}}
\define@key[psset]{pst-am}{C}[3.9e-8]{\def\psk@capacitor{#1}}
\psset[pst-am]{R=3300,C=3.9e-8}
%
\define@key[psset]{pst-am}{U0}[2]{\def\psk@offset{#1}}
\psset[pst-am]{U0=2}
%
\define@key[psset]{pst-am}{Up}[3.5]{\def\psk@Up{#1}}
\define@key[psset]{pst-am}{Um}[1]{\def\psk@Um{#1}}
\psset[pst-am]{Up=3.5,Um=1}
%
\define@key[psset]{pst-am}{k}[0.1]{\def\psk@k{#1}}
\psset[pst-am]{k=0.1} % coefficient multiplicateur
%
\define@key[psset]{pst-am}{timeDiv}[2e-4]{\def\psk@timeDiv{#1}}
\define@key[psset]{pst-am}{voltDivY1}[1]{\def\psk@voltDivA{#1}} % coeff d'amplitude vertical curve Y1
\define@key[psset]{pst-am}{voltDivY2}[1]{\def\psk@voltDivB{#1}} % coeff d'amplitude vertical curve Y2
\psset[pst-am]{timeDiv=2e-4,voltDivY1=1,voltDivY2=1}
%
\define@boolkey[psset]{pst-am}[Pst@]{Centering}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalModule}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalPorteuse}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalRedresse}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalDemodule}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalModulant}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalModule}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{SignalFinal}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{enveloppe}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{XY}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{traceU}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{UMandUm}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{values}[true]{}
\define@boolkey[psset]{pst-am}[Pst@]{BW}[true]{}
\psset[pst-am]{Centering=false}
%
\def\psAM{\pst@object{psAM}}
\def\psAM@i{{%
  \pst@killglue
  \use@par
  \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 % frequence signa modulant
        /Tm {1 Fm div} bind def % periode du signal modulant
        /Am \psk@Um\space def % amplitude signal modulant
        /U0 \psk@offset\space def % decalage
        /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 curve Y1
        /VoltDivY2 \psk@voltDivB\space def % amplitude verticale curve Y2
        /DecalageTemps 0 def
        0 0){MEM}%
\ifPst@BW
 \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
\ifPst@Centering\centering\fi
\pspicture(-0.1,-5)(10.1,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-Demodulation}}
\rput(5,-4.25){\psk@title}
\rput*(2.5,-3.5){\textsf{\large timeDiv:\numprint{\psk@timeDiv} s/div}}
\uput*[0](6,-3.7){\textsf{\large curve 2:\psk@voltDivB V/div}}
\uput*[0](6,-3.3){\textsf{\large curve 1:\psk@voltDivA V/div}}
\psclip{\psframe[linestyle=none](0,-4)(10,4)}
\ifPst@XY
\parametricplot[style=XY]{0}{10}{% duree
        /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}{% duree
        /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}{% duree
        /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 realisee
                             {/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@traceU0
    \psline[linecolor=green,linestyle=dashed](U01)(U02)
    \uput[l](U01){$U_0$}
\fi
\ifPst@UMandUm%
\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@values\par
\tabular{@{} r l @{}}\hline
  Amplitude porteuse & \numprint{\psk@Up}\ V \\ 
  Amplitude audio    & \numprint{\psk@Um}\ V \\ 
  Frequence porteuse & \numprint{\psk@frequencePorteuse}\ Hz \\ 
  Frequence audio    & \numprint{\psk@frequenceAudio}\ Hz\\  
  Decalage($U_0$)    & \numprint{\psk@offset}\ V\\ \hline 
  R                  & \numprint{\psk@resistor}\ $\Omega$ \\
  C                  & \numprint{\psk@capacitor}\ F \\ \hline
\endtabular
\fi
\ifPst@Centering\par\fi
}}
%
\endinput