Insert Minimum, Maximum, Slew Rate, and Mean Signal Operators
You can insert a number of signal operators using the scripting function plotSignalOperator .
Note:
You can use this scripting function to apply signal operators also on curves that are plotted against independent variables other than time, if the independent variables are rising over time.
Before you begin:
-
Display curves in a plotter.
-
Display the
Modelica Scripting window.
-
In the
input command line of Modelica Scripting window, use the scripting function
plotSignalOperator(variablePath, signalOperator, startTime, stopTime, id, result);
The function plots a signal operator in the active plotter. - Set
variablePath to the name of the variable to have the signal operator. Example: "J1.a" . - Set
signalOperator to the name of the signal operator. Possible values are:SignalOperator.Min SignalOperator.Max SignalOperator.ArithmeticMean SignalOperator.RectifiedMean SignalOperator.RMS SignalOperator.ACCoupledRMS SignalOperator.SlewRate
-
Set
startTime
to the start of the range where the signal operator is applied. -
Set
stopTime
to the end of the range where the signal operator is applied. - Optional:
Set
id to the identity of the plotter.
By default, the value is 0, meaning the last plotter.
-
Press Enter
to execute the function.
The function is executed, and - The signal operator is plotted in the plotter.
- The result is output in
result in the plotSignalOperator function.
Insert Discrete Difference Signal Operators
You can insert discrete difference signal operators using the scripting function plotSignalDifference .
Note:
You can use this scripting function to apply the signal operator also on curves that are plotted against independent variables other than time, if the independent variables are rising over time.
Before you begin:
-
Display curves in a plotter.
-
Display the
Modelica Scripting window.
-
In the
input command line of Modelica Scripting window, use the scripting function
plotSignalDifference(variablePath, startTime, stopTime, axis, id);
The function plots a signal operator in the active plotter. - Set
variablePath to the name of the variable to have the signal operator. Example: "J1.a" .
-
Set
startTime
to the start of the range where the signal operator is applied. -
Set
stopTime
to the end of the range where the signal operator is applied. -
Set
axis
to 0 to use the left axis, and 1 to use the axis to the right.
By default, the value is 0, meaning the left axis.
- Optional:
Set
id to the identity of the plotter.
By default, the value is 0, meaning the last plotter.
-
Press Enter
to execute the function.
The function is executed, and the signal operator is plotted in the plotter.
Insert Moving Average Signal Operators
You can insert moving average signal operators using the scripting function
plotMovingAverage .
Note:
You can use this scripting function to apply the signal operator also on curves that are
plotted against independent variables other than time, if the independent variables are
rising over time.
Before you begin:
- Display curves in a plotter.
- Display the Modelica Scripting window.
-
In the input command line of Modelica Scripting window, use the
scripting function
plotMovingAverage(variablePath, startTime, stopTime,
intervalLength, order, id);
The function plots a signal operator in the active chart.
-
Set
variablePath to the name of the variable to have the signal
operator. Example: "J1.a" .
-
Set
startTime to the start of the range where the signal
operator is applied.
-
Set
stopTime to the end of the range where the signal operator
is applied.
-
Set
intervalLenght to specify the averaging inteval
length.
- Optional:
Set
order to 1 if first-order derivatives
should be computed and displayed.
By default, the value is 0, meaning this option is not activated.
- Optional:
Set
id to the identity of the plotter.
By default, the value is 0, meaning the last plotter.
-
Press Enter to execute the function.
The function is executed, and the signal operator is plotted in the plotter.
Insert First Harmonic and Total Harmonic Distortion Signal Operators
You can use the scripting function plotSignalOperatorHarmonic
to handle first harmonic, and total harmonic distortion signal operators.
-
In the
input command line of Modelica Scripting window, use the scripting function
plotSignalOperatorHarmonic(variablePath, signalOperator, startTime, stopTime, period, intervalLength, window, harmonicNo, id, result);
The function plots a signal operator in the active plotter. - Set
variablePath to the name of the variable to have the signal operator. Example: "J1.a" . - Set
signalOperator to the name of the signal operator. Possible values are:SignalOperator.FirstHarmonic SignalOperator.THD
-
Set
startTime
to the start of the range where the signal operator is applied. -
Set
stopTime
to the end of the range where the signal operator is applied. - Set
period to the period length. - Set
intervalLength to the sampling interval length. - Set
window to the windowing function for the underlying FFT. Possible values are:SignalOperators.Windows.Windowing.Rectangular (default value)SignalOperators.Windows.Windowing.Hamming SignalOperators.Windows.Windowing.Hann SignalOperators.Windows.Windowing.FlatTop
- Set
harmonicNo to the relevant harmonic number. - Optional:
Set
id to the identity of the plotter.
By default, the value is 0, meaning the last plotter.
-
Press Enter
to execute the function.
The function is executed, and - The signal operator is plotted in the plotter.
- The result is output in
result in the plotSignalOperatorHarmonic function.
Insert Fast Fourier Transform (FFT) Signal Operators
You can use create a Fast Fourier Transform (FFT) signal operator for a signal by scripting.
One function is needed to compute the values for plotting, one function to perform the plotting. In this scenario, you create a FFT signal operator on the signal J1.a from the simulation of the demo Coupled Clutches.
- From the Behavior Tools section of the action bar, click Coupled Clutches .
The Coupled Clutches demo appears. - From the Behavior Authoring section of the action bar, click Execute .
The Coupled Clutches demo simulates. - From the Behavior Tools section of the action bar, click Show/Hide the Scriptig Window .
The Modelica Scripting window appears. -
The scripting function
(freqpart, powers) = SignalOperators.Fourier.calculateFFT(resultFile, vars[:], tmin, tmax, npoints, maxfrequency=1e100, windowing=SignalOperators.Windows.Windowing.Rectangular) is used to compute the values that can be used for plotting. For the final function to be typed in the command input line of the Modelica Scripting window, see the result of this step.
The first part (freqpart, powers) contains the result. - Set
resultFile to the name of the result file. Example: "CoupledClutches.mat" . - Set
vars[:] to the variables to be plotted. Example: {"J1.a"} . - Set
tmin and tmax to the start time and stop time of the range where the signal operator should be applied. Use the values 0 and 1.5 . - Set
npoints to the number of points. Use the value 1501 here. - Optional:
Set
maxFrequency to the maximum frequency. The default value is 1e+100 . - Optional:
Set
window to the windowing function for the underlying FFT. Possible values are:SignalOperators.Windows.Windowing.Rectangular (default value)SignalOperators.Windows.Windowing.Hamming SignalOperators.Windows.Windowing.Hann SignalOperators.Windows.Windowing.FlatTop
The result to be typed in the input command line of the Modelica Scripting window is now: (freqpart, powers) = SignalOperators.Fourier.calculateFFT("CoupledClutches.mat", {"J1.a"}, 0, 1.5, 1501, 1e+100, SignalOperators.Windows.Windowing.Rectangular); -
Press Enter
to execute the function.
The function is executed, and the result is computed.
- In the
Modelica Scripting window, use the scripting function
plotArrays(x[:], y[size(x, 1), :], legend[:], id, title, colors[size(y, 2), 3], patterns[size(y, 2)], markers[size(y, 2), thicknesses[size(y, 2)]) to plot the Fast Fourier Transform signal operator.- Set
x[:] to freqPart . - Set
y[size(x, 1), :] to powers . - Set
legend[:] to legend={"J1.a"} . - Set
id=1 to create the plot in a new plotter. - For the rest of the parameters, you need not to change the default values in this scenario.
The result in the input command line of the Modelica Scripting window is now: plotArrays(freqpart, powers, legend={"J1.a"}, id=1); -
Press Enter
to execute the function.
The function is executed, and the signal operator is plotted in a plotter.
|