在此示例中,您可以使用Simscape™ Electrical™blocks and customSimscape Electricalblocks, and then look at the voltage at the wave generator output.
You use a classic circuit configuration consisting of an integrator and a noninverting amplifier to generate the triangle wave, and use datasheets to specify block parameters. For more information, seeParameterizing Blocks from Datasheets。
To see the completed model, open theTriangle Wave Generatorexample.
首先,您选择以表示输入信号,三角波发生器和输出信号显示的块。
您可以用一组物理块对三角波发生器进行建模。波发电机由:
Two operational amplifier blocks
电阻和与操作放大器合作的电容器,以创建积分器和非启动放大器
Simulink-PS Converter和PS-Simulink Converterblocks whose function is to bridge the physical part of the model, which uses physical signals, and the rest of the model, which uses Simulink®signals.
You have a manufacturer datasheet for the two operational amplifiers you want to model. Later in the example, you use the datasheet to parameterize theSimscape ElectricalBand-Limited Op-Ampblock.
The following table describes the role of the blocks that represent the system components.
Block |
Description |
---|---|
Sine Wave | Generates a sinusoidal signal that controls the resistance of the Variable Resistor block |
Scope | Displays the triangular output wave |
Simulink-PS Converter | Converts the sinusoidal Simulink signal to a physical signal |
Solver Configuration | Defines solver settings that apply to all physical modeling blocks |
PS-Simulink Converter | Converts the output physical signal to a Simulink signal |
Capacitor | 与一个运算放大器和电阻block to create the integrator |
Resistor | Works with the operational amplifier and capacitor blocks to create the integrator and noninverting amplifier |
Variable Resistor | Supplies a time-varying resistance that adjusts the gain of the integrator, which in turn varies the frequency and amplitude of the generated triangular wave |
DC Voltage Source | Generates a DC reference signal for the operational amplifier block of the noninverting amplifier |
Voltage Sensor | Converts the electrical voltage at the output of the integrator into a physical signal proportional to the current |
电气Reference | Provides the electrical ground |
Band-Limited Op-Amp | Works with the capacitor and resistor to create an integrator and a noninverting amplifier |
Diode | Limits the output of the Band-Limited Op-Amp block, to make the output waveform independent of supply voltage |
Create a Simulink model, add blocks to the model, and connect the blocks.
Create a new model.
Add to the model the blocks listed in this table. The Library Path column of the table specifies the hierarchical path to each block.
Block |
Library Path |
数量 |
---|---|---|
Sine Wave | 金宝app>Sources | 1 |
Scope | 金宝app>Commonly Used Blocks | 1 |
Simulink-PS Converter | Simscape>Utilities | 1 |
Solver Configuration | Simscape>Utilities | 1 |
PS-Simulink Converter | Simscape>Utilities | 1 |
Capacitor | Simscape>Foundation Library>电气>电气Elements | 1 |
Resistor | Simscape>Foundation Library>电气>电气Elements | 3 |
Variable Resistor | Simscape>Foundation Library>电气>电气Elements | 1 |
电气Reference | Simscape>Foundation Library>电气>电气Elements | 2 |
DC Voltage Source | Simscape>Foundation Library>电气>电气Sources | 1 |
Voltage Sensor | Simscape>Foundation Library>电气>电气Sensors | 1 |
Band-Limited Op-Amp | Simscape>电气>集成电路 |
2 |
Diode | Simscape>电气>Semiconductor & Converters |
2 |
Note
You can use the Simscape functionssc_new
with a domain type ofelectrical
to create a Simscape model that contains these blocks:
Simulink-PS Converter
PS-Simulink Converter
Scope
Solver Configuration
电气Reference
Rename and connect the blocks as shown in the diagram. The blocks in the triangle wave generator circuit are organized in two stages. The Comparator Stage contains a comparator constructed from aBand-Limited Op-Ampblock and twoResistorblocks. The Integrator Stage contains an integrator constructed from anotherBand-Limited Op-Ampblock, aResistor, aCapacitor, and电气Reference。
Specify these parameters to represent the behavior of the system components:
These blocks specify model information that is not specific to a particular block:
Solver Configuration
电气Reference
As with Simscape models, you must include aSolver Configuration块在each topologically distinct physical network. This example has a single physical network, so use one Solver Configuration block with the default parameter values.
You must include an电气Reference块在eachSimscape Electricalnetwork. This block does not have any parameters.
Generate the sinusoidal control signal using the Sine Wave block.
设置Sine Waveblock parameters as follows:
Amplitude—0.5e4
Bias—1e4
Frequency—pi/5e-4
配置模拟生成三角波的物理系统的块:
Integrator stage — Band-Limited Op-Amp, Capacitor, and Resistor block R3
Comparator stage — Band-Limited Op-Amp1, Resistor blocks R1 and R2
Variable Resistor
Diode and Diode1
Simulink-PS Converter and PS-Simulink Converter blocks that bridge the physical part of the model and the Simulink part of the model.
Accept the default parameters for the Simulink-PS Converter block. These parameters establish the units of the physical signal at the block output such that they match the expected default units of the Variable Resistor block input.
设置two Band-Limited Op-Amp block parameters for the LM7301 device with a +–20V power supply:
The datasheet gives the gain as 97 dB, which is equivalent to 10 ^ ( 97 / 20 ) = 7.1e4. Set theGain, Aparameter to7.1e4
。
The datasheet gives input resistance as 39 Mohms. SetInput resistance, Rinto39e6
。
SetOutput resistance, Routto0
欧姆。该数据表并不引用dout的值,但是与驱动的输出电阻相比,该术语微不足道。
Set minimum and maximum output voltages to –20 V and +20 V, respectively.
数据表的最大振荡速率为1.25 v/μs。设置Maximum slew rate, Vdotparameter to1.25e6
V/s.
设置bandwidth to4e6
。
为4.3 V Zener二极管设置两个二极管块参数。要建模BZX384-B4V3,请按以下方式设置块参数:
On the主要的tab, setDiode modeltoPiecewise Linear
。这选择了简化的齐纳二极管模型,该模型足以测试该电路的正确操作。
Leave the向前电压as 0.6 V — this is a typical value for most diodes.
The datasheet gives the forward current as 250 mA when the forward voltage is 1V. So that the Diode block matches this, set theOn resistanceto (1 V – 0.6 V) / 250 mA =1.6
欧姆。
The datasheet gives the reverse leakage current as 3 μA at a reverse voltage of 1 V. Therefore, set theOff conductanceto 3 μA / 1 V =3e-6
S.
The datasheet gives the reverse voltage as 4.3 V. On the Breakdown tab, set theReverse breakdown voltage Vzto4.3
V.
设置齐纳抗性RZ适当的数字。数据表引用了5 MA的反向电流的齐纳电压。对于代表真实设备的二极管块,模拟的反向电压应接近5ma时的4.3V。由于RZ趋于零,因此反向故障电压趋于VZ,无论电流如何,随着电压电流梯度变得无限。但是,对于良好的数值属性,不得使RZ变得太小。如果说,如果在5 mA处允许在齐纳电压上出现0.01 V误差,则RZ为0.01 V / 5 mA = 2欧姆。设置Zener resistanceparameter to this value.
The Voltage Sensor block does not have any parameters.
Accept the default parameters for the Variable Resistor block. These parameters establish the units of the physical signal at the block output such that they match the expected default units of the Variable Resistor block input.
设置Capacitor block parameters as follows:
电容—2.5e-9
Capacitor voltage—0.08
This value starts the oscillation in the feedback loop. It is found in the变量tab.
Series resistance—0
设置DC Voltage Sourceblock恒压parameter to0
。
设置Resistor R3 blockResistanceparameter to10000
。
设置Resistor R1 blockResistanceparameter to1000
。
设置Resistor R2 blockResistanceparameter to10000
。
Accept the default parameters for the PS-Simulink Converter block. These parameters establish the units of the physical signal at the block output such that they match the expected default units of the Scope block input.
Specify the parameters of the Scope block to display the triangular output signal.
Double-click the Scope block and then click theView>Configuration Propertiesto open the Scope Configuration Properties dialog box. On theLoggingtab, clear theLimit data points to lastcheck box.
Configure the solver parameters to use a continuous-time solver.Simscape Electricalmodels only run with a continuous-time solver when the SimscapeSolver Configurationblock has itsLocal Solver参数清除。您还可以更改仿真结束时间,从而拧紧相对公差以进行更准确的模拟,并删除模拟数据点Simulink Saves的限制。金宝app
In the model window, selectModeling>Model Settingsto open the Configuration Parameters dialog box.
In theSolvercategory in the tree on the left side of the dialog box:
Enter2000e-6
为了Stop timeparameter value.
Selectode23t (Mod. stiff/Trapezoidal)
from theSolverlist.
Enter4 e-5
为了Max step sizeparameter value.
Enter1e-6
为了Relative toleranceparameter value.
In theData Import/Exportcategory in theSelecttree, clear theLimit data points to lastcheck box.
Click好的。
For more information about configuring solver parameters, seeSimulating an Electronic, Mechatronic, or Electrical Power System。
Run the simulation and plot the results.
In the model window, select模拟>Runto run the simulation.
To view the triangle wave in the Scope window, double-click the Scope block. You can do this before or after you run the simulation.
以下图显示了电压波形。随着可变电阻块的电阻增加,输出波形的幅度增加,频率降低。
三角波形电压