Simulink/source
Second, function
The pulse generator module generates square wave pulses at fixed intervals. The waveform parameters amplitude, pulse width, period and phase delay of the module determine the shape of the output waveform. The following figure illustrates the influence of each parameter on the waveform.
The pulse generator module can generate scalar, vector or matrix signals of any real number type. To generate scalar signals, use scalars to specify waveform parameters. To generate vector or matrix signals, specify waveform parameters with vector or matrix respectively.
Each element of the waveform parameter will affect the corresponding element of the output signal. For example, the first element of the amplitude vector parameter determines the amplitude of the first element of the output pulse vector. After scalar expansion, all waveform parameters must have the same dimension. The data type of the output is the same as that of the amplitude parameter.
The module output can be generated based on time or sampling mode, depending on the pulse type parameters.
2. 1 time base mode
In the time-based mode, Simulink only calculates the module output when the output actually changes. Using this method, the calculation amount of obtaining the module output in the simulation period is less. This mode can be activated by setting the pulse type parameter to be time-based.
This module does not support a time-based configuration that generates a constant output signal. Simulink will return an error if the parameter pulse width and period meet any of the following conditions:
According to the characteristics of pulse waveform, the time interval of module output change may be different. Therefore, the time-based pulse generator module has variable sampling time.
Simulink can't use the fixed step solver to calculate the output of the time-base pulse generator. If a fixed step solver is specified for the model containing the time-based pulse generator, Simulink will calculate the fixed sampling time of the time-based pulse generator. Then the time-based pulse generator will be simulated in the sampling-based mode.
If the resolver with fixed step size is used and the pulse type is based on time, the step size is selected so that the period, phase delay and pulse width (seconds) are equal to integer multiples of the resolver step size. For example, suppose the period is 4 seconds, the pulse width is 75% (that is, 3 seconds), and the phase delay is 1 second. In this case, the calculated sampling time is 1 sec. Therefore, please choose a fixed step size 1 or a number that can divide 1 exactly (such as 0.25). To ensure this setting, select Automatic in the Solver pane of the Configuration Parameters dialog box.
2.2 Sampling-based mode
In the sampling-based mode, the module calculates its output at specified fixed time intervals. This mode can be activated by setting the pulse type parameter to sample-based.
Time-based mode: module output is based on simulation time;
Sampling-based mode: the module output only depends on the simulation start time, regardless of the simulation time used.
In the sampling-based mode, this module supports resetting semantics. For example, if the pulse generator module is in a resettable subsystem, if the subsystem triggers a reset trigger, the module output will be reset to its initial state.
Third, the parameter introduction
Double-click the pulse generator module in the figure below.
Get the parameter configuration interface as shown below.
Pulse type: select pulse type according to time mode and sampling mode;
Time: time, unit s.
Specifies whether to use analog time or external signal as the source of the output pulse time variable value. If an external signal source is specified, the module will display an input port to connect the external signal source. The output pulses are different as follows:
"Use Analog Time": The module generates an output pulse whose time variable is equal to the analog time.
"Use external signal": the module generates an output pulse whose time variable is equal to the value of the input port (which may be different from the analog time).
Amplitude: amplitude
Period: Period, in seconds. If the pulse type is time-based, specify the pulse period in seconds. If the pulse type is based on sampling, the pulse period is specified by the number of sampling times.
Pulse width: pulse width. Duty cycle, if the pulse type is time-based, it is specified as the ratio when there is a signal in the pulse period; If it is based on sampling, it is the number of samples designated as having a signal.
Phase delay: Phase delay in seconds. Pre-pulse delay, if the pulse type is time-based, the delay time before the pulse is generated is specified in seconds; If based on sampling, please specify the number of samples before generating the pulse.
Vector parameter 1D:
If the calculation result of amplitude, period, pulse width or phase delay parameters is a row vector or a column vector containing n elements, then selecting this check box will output a vector with a length of n. ..
If the calculation result of any value parameter is a row or column vector containing n elements, when this check box is selected, the system will output a vector of length n ... For example, the module will output a matrix of 1 times n dimension or n times 1 dimension.
If any value parameter evaluates to a row or column vector containing n elements, the module will not output a vector of length n when this check box is cleared.