Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions Modelica/Blocks/Sources.mo
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ variable <strong>y</strong> is both a variable and a connector.
extends Interfaces.SignalSource;

equation
y = offset + (if time < startTime then 0 else time - startTime);
y = offset + smooth(0, (if time < startTime then 0 else time - startTime));
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
Expand Down Expand Up @@ -294,10 +294,17 @@ If parameter duration is set to 0.0, the limiting case of a Step signal is achie
annotation(Dialog(groupImage="modelica://Modelica/Resources/Images/Blocks/Sources/Sine.png"));
parameter SI.Frequency f(start=1) "Frequency of sine wave";
parameter SI.Angle phase=0 "Phase of sine wave";
parameter Boolean continuous = false "Make output continuous by starting at offset + amplitude*sin(phase)"
annotation(Evaluate=true);
extends Interfaces.SignalSource;
equation
y = offset + (if time < startTime then 0 else amplitude*Modelica.Math.sin(2
*pi*f*(time - startTime) + phase));
if continuous then
y = offset + amplitude*smooth(0, (if time < startTime then Modelica.Math.sin(phase)
else Modelica.Math.sin(2*pi*f*(time - startTime) + phase)));
else
y = offset + (if time < startTime then 0 else amplitude*Modelica.Math.sin(2
*pi*f*(time - startTime) + phase));
end if;
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
Expand Down Expand Up @@ -340,10 +347,17 @@ The Real output y is a sine signal:
annotation(Dialog(groupImage="modelica://Modelica/Resources/Images/Blocks/Sources/Cosine.png"));
parameter SI.Frequency f(start=1) "Frequency of cosine wave";
parameter SI.Angle phase=0 "Phase of cosine wave";
parameter Boolean continuous = false "Make output continuous by starting at offset + amplitude*cos(phase)"
annotation(Evaluate=true);
extends Interfaces.SignalSource;
equation
y = offset + (if time < startTime then 0 else amplitude*Modelica.Math.cos(2
*pi*f*(time - startTime) + phase));
if continuous then
y = offset + smooth(0, amplitude*(if time < startTime then Modelica.Math.cos(phase)
else Modelica.Math.cos(2*pi*f*(time - startTime) + phase)));
else
y = offset + (if time < startTime then 0 else amplitude*Modelica.Math.cos(2
*pi*f*(time - startTime) + phase));
end if;
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
Expand Down Expand Up @@ -593,12 +607,19 @@ and that the parameter <code>startTime</code> is omitted since the voltage can b
parameter Real amplitude=1 "Amplitude of sine wave"
annotation(Dialog(groupImage="modelica://Modelica/Resources/Images/Blocks/Sources/Sinc.png"));
parameter SI.Frequency f(start=1) "Frequency of sine wave";
parameter Boolean continuous = false "Make output (continuously) differentiable by starting at offset + amplitude rather than just offset"
annotation(Evaluate=true);
extends Interfaces.SignalSource;
protected
SI.Angle x=2*pi*f*(time - startTime);
equation
y = offset + (if time < startTime then 0 else amplitude*
(if noEvent(time - startTime < eps) then 1 else (sin(x))/x));
if continuous then
y = offset + amplitude*smooth(1, (if time < startTime then 1 else
(if noEvent(time - startTime < eps) then 1 else (sin(x))/x)));
else
y = offset + (if time < startTime then 0 else amplitude*
(if noEvent(time - startTime < eps) then 1 else (sin(x))/x));
end if;
annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
Expand Down