In phasor simulation mode, is it possible to dynamically change the frequency?

2 次查看(过去 30 天)
Hello everyone,
I have a simple model with SimPowerSystems components and a powergui blockset that is set to run in phasor simulation mode.
In the model, I added a S-Function which uses the get_param and set_param functions to modify successfully the Phasor frequency in the powergui/configuration_parameters mask while the simulation is running.
The issue is, although the frequency appears to be changed when I check the configuration parameters at the end of the simulation, the change has not be reflected in the results of the simulation.
For example, using a voltage source, and a standard RLC filter, I start the simulation with an initial frequency of 50Hz and modify it on the fly while the simulation is running. The output voltage magnitude should be modified as I change the frequency, but it is not and I get a constant output corresponding to whatever the output would be with the starting frequency being constant.
The line of code I used in the S-Function are as follow, Test0001 being the name of the model:
% Pause Simulation
set_param('Test0001','SimulationCommand','pause');
% Read current frequency value
f=str2num(get_param('Test0001/powergui','Frequency'));
% Output frequency value read to be displayed in a scope
block.OutputPort(1).Data = f;
% Write modified frequency value (here, increased by 10 Hz)
set_param('Test0001/powergui','Frequency',num2str(f+10));
% Update the model (??)
set_param('Test0001', 'SimulationCommand', 'update');
% Resume simulation
set_param('Test0001','SimulationCommand','continue');
Am I missing something that would effectively reflect the frequency change on the whole circuit?
Or, is there any other way of doing this?
Using Phasor simulation mode and being able to modify the frequency on the fly are necessary, I am not just trying to get a frequency response so available frequency analysis tools are not suitable.
Thank you. (MATLAB R2009b)
Dalil

回答(1 个)

Sabin
Sabin 2023-10-3
编辑:Sabin 2023-10-3
The phasor technique gives the solution only at one particular frequency. Probably best to try fast restart if simulation at different frequencies is needed.

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by