root/branches/maintenance/2.2.1/Modelica/Blocks/Sources.mo

Revision 1183, 94.5 kB (checked in by otter, 4 weeks ago)

Blocks.KinematicPTP: Fixed tiny bug using forgotten "each"
Thermal: replaced undefined "ln(..)" by "log(..)"

Line 
1package Sources "Signal source blocks generating Real and Boolean signals" 
2  block RealExpression "Set output signal to a time varying Real expression" 
3    Blocks.Interfaces.RealOutput y=0.0 "Value of Real output" 
4      annotation (extent=[100, -10; 120, 10], Dialog(group=
5            "Time varying output signal"));
6   
7    annotation (
8      Coordsys(
9        extent=[-100, -100; 100, 100],
10        grid=[2, 2],
11        component=[20, 20]),
12      Window(
13        x=0.29,
14        y=0.23,
15        width=0.6,
16        height=0.6),
17      Icon(
18        Rectangle(extent=[-100,40; 100,-40],   style(
19            color=0,
20            fillColor=30,
21            fillPattern=11)),
22        Text(
23          extent=[-96,15; 96,-15],
24          string="%y",
25          style(
26            color=0,
27            fillColor=2,
28            fillPattern=1)), Text(extent=[-150,90; 140,50],     string="%name")),
29      Diagram,
30      Documentation(info="<html>
31
32</html>"));
33   
34  end RealExpression;
35 
36  block IntegerExpression
37    "Set output signal to a time varying Integer expression" 
38    Blocks.Interfaces.IntegerOutput y=0 "Value of Integer output" 
39      annotation (extent=[100, -10; 120, 10], Dialog(group=
40            "Time varying output signal"));
41   
42    annotation (
43      Coordsys(
44        extent=[-100, -100; 100, 100],
45        grid=[2, 2],
46        component=[20, 20]),
47      Window(
48        x=0.29,
49        y=0.23,
50        width=0.6,
51        height=0.6),
52      Icon(
53        Rectangle(extent=[-100,40; 100,-40],   style(
54            color=0,
55            fillColor=30,
56            fillPattern=11)),
57        Text(
58          extent=[-96,15; 96,-15],
59          string="%y",
60          style(
61            color=0,
62            fillColor=2,
63            fillPattern=1)), Text(extent=[-150,90; 140,50],     string="%name")),
64      Diagram,
65      Documentation(info="<html>
66
67</html>"));
68   
69  end IntegerExpression;
70 
71  block BooleanExpression
72    "Set output signal to a time varying Boolean expression" 
73    Blocks.Interfaces.BooleanOutput y=false "Value of Boolean output" 
74      annotation (extent=[100, -10; 120, 10], Dialog(group=
75            "Time varying output signal"));
76   
77    annotation (
78      Coordsys(
79        extent=[-100, -100; 100, 100],
80        grid=[2, 2],
81        component=[20, 20]),
82      Window(
83        x=0.29,
84        y=0.23,
85        width=0.6,
86        height=0.6),
87      Icon(
88        Rectangle(extent=[-100,40; 100,-40],   style(
89            color=0,
90            fillColor=30,
91            fillPattern=11)),
92        Text(
93          extent=[-96,15; 96,-15],
94          string="%y",
95          style(
96            color=0,
97            fillColor=2,
98            fillPattern=1)), Text(extent=[-150,90; 140,50],     string="%name"),
99  Polygon(points=[100,10; 120,0; 100,-10; 100,10],
100             style(color=DynamicSelect(5, if y > 0.5 then 2 else 5),
101              fillColor=DynamicSelect(7, if y > 0.5 then 2 else 7)))),
102      Diagram,
103      Documentation(info="<html>
104
105</html>"));
106   
107  end BooleanExpression;
108  import Modelica.Blocks.Interfaces;
109  import Modelica.SIunits;
110      extends Modelica.Icons.Library;
111 
112      annotation(preferedView="info",
113        Coordsys(
114          extent=[0, 0; 430, 442],
115          grid=[1, 1],
116          component=[20, 20]),
117        Window(
118          x=0.06,
119          y=0.1,
120          width=0.43,
121          height=0.65,
122          library=1,
123          autolayout=1),
124        Documentation(info="<HTML>
125<p>
126This package contains <b>source</b> components, i.e., blocks which
127have only output signals. These blocks are used as signal generators
128for Real, Integer and Boolean signals.
129</p>
130
131<p>
132All Real source signals (with the exception of the Constant source)
133have at least the following two parameters:
134</p>
135
136<table border=1 cellspacing=0 cellpadding=2>
137  <tr><td><b>offset</b></td>
138      <td>Value which is added to the signal</td>
139  </tr>
140  <tr><td><b>startTime</b></td>
141      <td>Start time of signal. For time &lt; startTime,
142                the output y is set to offset.</td>
143  </tr>
144</table>
145
146<p>
147The <b>offset</b> parameter is especially useful in order to shift
148the corresponding source, such that at initial time the system
149is stationary. To determine the corresponding value of offset,
150usually requires a trimming calculation.
151</p>
152</HTML>
153", revisions="<html>
154<ul>
155<li><i>October 21, 2002</i>
156       by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>
157       and <a href=\"http://www.robotic.dlr.de/Christian.Schweiger/\">Christian Schweiger</a>:<br>
158       Integer sources added. Step, TimeTable and BooleanStep slightly changed.</li>
159<li><i>Nov. 8, 1999</i>
160       by <a href=\"mailto:clauss@eas.iis.fhg.de\">Christoph Clau&szlig;</a>,
161       <A HREF=\"mailto:schneider@eas.iis.fhg.de\">schneider@eas.iis.fhg.de</A>,
162       <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
163       New sources: Exponentials, TimeTable. Trapezoid slightly enhanced
164       (nperiod=-1 is an infinite number of periods).</li>
165<li><i>Oct. 31, 1999</i>
166       by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
167       <a href=\"mailto:clauss@eas.iis.fhg.de\">Christoph Clau&szlig;</a>,
168       <A HREF=\"mailto:schneider@eas.iis.fhg.de\">schneider@eas.iis.fhg.de</A>,
169       All sources vectorized. New sources: ExpSine, Trapezoid,
170       BooleanConstant, BooleanStep, BooleanPulse, SampleTrigger.
171       Improved documentation, especially detailed description of
172       signals in diagram layer.</li>
173<li><i>June 29, 1999</i>
174       by <a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a>:<br>
175       Realized a first version, based on an existing Dymola library
176       of Dieter Moormann and Hilding Elmqvist.</li>
177</ul>
178</html>"));
179      block Clock "Generate actual time signal " 
180        parameter Real offset=0 "Offset of output signal";
181        parameter SIunits.Time startTime=0 
182      "Output = offset for time < startTime";
183        extends Interfaces.SO;
184   
185        annotation (
186          Coordsys(
187            extent=[-100, -100; 100, 100],
188            grid=[1, 1],
189            component=[20, 20]),
190          Window(
191            x=0.26,
192            y=0,
193            width=0.36,
194            height=0.52),
195          Icon(
196            Ellipse(extent=[-80, 80; 80, -80], style(color=9)),
197            Line(points=[0, 80; 0, 60], style(color=9)),
198            Line(points=[80, 0; 60, 0], style(color=9)),
199            Line(points=[0, -80; 0, -60], style(color=9)),
200            Line(points=[-80, 0; -60, 0], style(color=9)),
201            Line(points=[37, 70; 26, 50], style(color=9)),
202            Line(points=[70, 38; 49, 26], style(color=9)),
203            Line(points=[71, -37; 52, -27], style(color=9)),
204            Line(points=[39, -70; 29, -51], style(color=9)),
205            Line(points=[-39, -70; -29, -52], style(color=9)),
206            Line(points=[-71, -37; -50, -26], style(color=9)),
207            Line(points=[-71, 37; -54, 28], style(color=9)),
208            Line(points=[-38, 70; -28, 51], style(color=9)),
209            Line(points=[0, 0; -50, 50], style(color=0, thickness=2)),
210            Line(points=[0, 0; 40, 0], style(color=0, thickness=2)),
211            Text(
212              extent=[-150, -150; 150, -110],
213              string="startTime=%startTime",
214              style(color=0))),
215          Diagram(
216            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
217                   fillColor=8)),
218            Line(points=[-80, 68; -80, -80], style(color=8)),
219            Line(points=[-80, 0; -10, 0; 60, 70], style(color=0, thickness=2)),
220            Line(points=[-90, -70; 82, -70], style(color=8)),
221            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(
222                color=8,
223                fillColor=8,
224                fillPattern=1)),
225            Polygon(points=[-34, 0; -37, -13; -30, -13; -34, 0], style(
226                color=8,
227                fillColor=8,
228                fillPattern=1)),
229            Line(points=[-34, -13; -34, -70], style(
230                color=8,
231                pattern=1,
232                thickness=1,
233                arrow=0)),
234            Polygon(points=[-34, -69; -37, -56; -31, -56; -34, -69; -34, -69],
235                style(
236                color=8,
237                fillColor=8,
238                fillPattern=1)),
239            Text(
240              extent=[-81, -25; -35, -43],
241              string="offset",
242              style(color=9)),
243            Text(
244              extent=[-33, -71; 13, -89],
245              string="startTime",
246              style(color=9)),
247            Text(
248              extent=[-66, 92; -25, 72],
249              string="y",
250              style(color=9)),
251            Text(
252              extent=[70, -80; 94, -100],
253              string="time",
254              style(color=9)),
255            Line(points=[-10, 0; -10, -70], style(color=8, pattern=2)),
256            Line(points=[-10, 0; 50, 0], style(color=8, pattern=2)),
257            Line(points=[50, 0; 50, 60], style(color=8, pattern=2)),
258            Text(
259              extent=[35, 33; 50, 23],
260              string="1",
261              style(color=9)),
262            Text(
263              extent=[14, 13; 32, 1],
264              string="1",
265              style(color=9))),
266      Documentation(info="<html>
267
268</html>"));
269   
270      equation 
271        y = offset + (if time < startTime then 0 else time - startTime);
272      end Clock;
273 
274      block Constant "Generate constant signal of type Real" 
275        parameter Real k=1 "Constant output value";
276        extends Interfaces.SO;
277   
278        annotation (defaultComponentName="const",
279          Coordsys(
280            extent=[-100, -100; 100, 100],
281            grid=[2, 2],
282            component=[20, 20]),
283          Window(
284            x=0.29,
285            y=0.19,
286            width=0.6,
287            height=0.6),
288          Icon(
289            Line(points=[-80, 68; -80, -80], style(color=8)),
290            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
291                   fillColor=8)),
292            Line(points=[-90, -70; 82, -70], style(color=8)),
293            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(color=8,
294                   fillColor=8)),
295            Line(points=[-80, 0; 80, 0], style(color=0)),
296            Text(
297              extent=[-150, -150; 150, -110],
298              string="k=%k",
299              style(color=0))),
300          Diagram(
301            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
302                   fillColor=8)),
303            Line(points=[-80, 68; -80, -80], style(color=8)),
304            Line(points=[-80, 0; 80, 0], style(color=0, thickness=2)),
305            Line(points=[-90, -70; 82, -70], style(color=8)),
306            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(color=8,
307                   fillColor=8)),
308            Text(
309              extent=[-75, 94; -22, 76],
310              string="y",
311              style(color=9)),
312            Text(
313              extent=[70, -80; 94, -100],
314              string="time",
315              style(color=9)),
316            Text(
317              extent=[-101, 8; -81, -12],
318              string="k",
319              style(color=9))),
320      Documentation(info="<html>
321
322</html>"));
323      equation 
324        y = k;
325      end Constant;
326 
327      block Step "Generate step signal of type Real" 
328        parameter Real height=1 "Height of step";
329        extends Interfaces.SignalSource;
330        annotation (
331          Coordsys(
332            extent=[-100, -100; 100, 100],
333            grid=[1, 1],
334            component=[20, 20]),
335          Window(
336            x=0.38,
337            y=0.11,
338            width=0.6,
339            height=0.6),
340          Icon(
341            Line(points=[-80, 68; -80, -80], style(color=8)),
342            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
343                   fillColor=8)),
344            Line(points=[-90, -70; 82, -70], style(color=8)),
345            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(color=8,
346                   fillColor=8)),
347            Line(points=[-80, -70; 0, -70; 0, 50; 80, 50], style(color=0)),
348            Text(
349              extent=[-150, -150; 150, -110],
350              string="startTime=%startTime",
351              style(color=0))),
352          Diagram(
353            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
354                   fillColor=8)),
355            Line(points=[-80, 68; -80, -80], style(color=8)),
356            Line(points=[-80, -18; 0, -18; 0, 50; 80, 50], style(color=0,
357                  thickness=2)),
358            Line(points=[-90, -70; 82, -70], style(color=8)),
359            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(color=8,
360                   fillColor=8)),
361            Text(
362              extent=[70, -80; 94, -100],
363              string="time",
364              style(color=9)),
365            Text(
366              extent=[-21, -72; 25, -90],
367              string="startTime",
368              style(color=9)),
369            Line(points=[0, -17; 0, -71], style(color=8, pattern=2)),
370            Text(
371              extent=[-68, -36; -22, -54],
372              string="offset",
373              style(color=9)),
374            Line(points=[-13, 50; -13, -17], style(
375                color=8,
376                pattern=1,
377                thickness=1,
378                arrow=0)),
379            Polygon(points=[2, 50; -19, 50; 2, 50], style(color=8, pattern=2)),
380            Polygon(points=[-13, -17; -16, -4; -10, -4; -13, -17; -13, -17],
381                style(
382                color=8,
383                fillColor=8,
384                fillPattern=1)),
385            Polygon(points=[-13, 50; -16, 37; -9, 37; -13, 50], style(
386                color=8,
387                fillColor=8,
388                fillPattern=1)),
389            Text(
390              extent=[-68, 26; -22, 8],
391              string="height",
392              style(color=9)),
393            Polygon(points=[-13, -69; -16, -56; -10, -56; -13, -69; -13, -69],
394                style(
395                color=8,
396                fillColor=8,
397                fillPattern=1)),
398            Line(points=[-13, -18; -13, -70], style(
399                color=8,
400                pattern=1,
401                thickness=1,
402                arrow=0)),
403            Polygon(points=[-13, -18; -16, -31; -9, -31; -13, -18], style(
404                color=8,
405                fillColor=8,
406                fillPattern=1)),
407            Text(
408              extent=[-72, 100; -31, 80],
409              string="y",
410              style(color=9))),
411      Documentation(info="<html>
412
413</html>"));
414   
415      equation 
416        y = offset + (if time < startTime then 0 else height);
417      end Step;
418 
419      block Ramp "Generate ramp signal" 
420        parameter Real height=1 "Height of ramps";
421        parameter Real duration(min=Modelica.Constants.small) = 2 
422      "Durations of ramp";
423        parameter Real offset=0 "Offset of output signal";
424        parameter SIunits.Time startTime=0 
425      "Output = offset for time < startTime";
426        extends Interfaces.SO;
427   
428        annotation (
429          Coordsys(
430            extent=[-100, -100; 100, 100],
431            grid=[1, 1],
432            component=[20, 20]),
433          Window(
434            x=0.19,
435            y=0.02,
436            width=0.59,
437            height=0.77),
438          Icon(
439            Line(points=[-80, 68; -80, -80], style(color=8)),
440            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
441                   fillColor=8)),
442            Line(points=[-90, -70; 82, -70], style(color=8)),
443            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(
444                color=8,
445                fillColor=8,
446                fillPattern=1)),
447            Line(points=[-80, -70; -40, -70; 31, 38], style(color=0)),
448            Text(
449              extent=[-150, -150; 150, -110],
450              string="duration=%duration",
451              style(color=0)),
452            Line(points=[31, 38; 86, 38], style(color=0))),
453          Diagram(
454            Polygon(points=[-80, 90; -88, 68; -72, 68; -80, 90], style(color=8,
455                   fillColor=8)),
456            Line(points=[-80, 68; -80, -80], style(color=8)),
457            Line(points=[-80, -20; -20, -20; 50, 50], style(color=0, thickness=
458                    2)),
459            Line(points=[-90, -70; 82, -70], style(color=8)),
460            Polygon(points=[90, -70; 68, -62; 68, -78; 90, -70], style(
461                color=8,
462                fillColor=8,
463                fillPattern=1)),
464            Polygon(points=[-40, -20; -42, -30; -37, -30; -40, -20], style(
465                color=8,
466                fillColor=8,
467                fillPattern=1)),
468            Line(points=[-40, -20; -40, -70], style(
469                color=8,
470                pattern=1,
471                thickness=1,
472                arrow=0)),
473            Polygon(points=[-40, -70; -43, -60; -38, -60; -40, -70; -40, -70],
474                style(
475                color=8,
476                fillColor=8,
477                fillPattern=1)),
478            Text(
479              extent=[-80, -33; -41, -49],
480              string="offset",
481              style(color=9)),
482            Text(
483              extent=[-40, -70; 6, -88],
484              string="startTime",
485              style(color=9)),
486            Text(
487              extent=[-66, 92; -25, 72],
488              string="y",
489              style(color=9)),
490            Text(
491              extent=[70, -80; 94, -100],
492              string="time",
493              style(color=9)),
494            Line(points=[-20, -20; -20, -70], style(color=8, pattern=2)),
495            Line(points=[-19, -20; 50, -20], style(
496                color=8,
497                pattern=1,
498                thickness=1,
499                arrow=0)),
500            Line(points=[50, 50; 101, 50], style(color=0, thickness=2)),
501            Line(points=[50, 50; 50, -20], style(
502                color=8,
503                pattern=1,
504