function outputs as input control variant in simulink

I have a variant subsystem containing two blocks " charge" and "decharge" and a function block with two output "charge_sig" and "decharge"sig". how can i make these outputs as input control variants? i need to activate "charge" block when charge_sig=1 && decharge_sig=0 and to activate "decharge" block when charge_sig=0 && decharge_sig=1.

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2018년 8월 23일

1 개 추천

It sounds like "variant subsystem" should not be used. Instead, "conditionally executed subsystem" should be used. In this case, use the "Enabled subsystem". Use the two signals to enable/disable the "charge" and "decharge" blocks. Use the "Merge" block to merge their common outputs.

댓글 수: 5

I tried the "enabled system" but it not works because when one subsystem is enabled he should begin simulation with the last other subsystem outputs values as initial condition. this is not possible because when the other block is disabled, it cannot deliver its outputs values to the enabled one.Thus the enabled block begin the simulation with the latest output values that are stored in the integrator contained in it during its previous "enable" process. any help please?
It is hard to answer that without more details. It it is to simulate the state of charge of a battery system, I would put the "charge" and "discharge" algorithm into two "conditionally executed subsystems" and calculate the charge/discharge power or current. The simulation of the state of charge is put in a common system.
the model simulate the state of charge and discharge of a compressed air reservoir. a function block read all input variables (wind power,compressors power,load,etc...) and return 2 variable signals: charge_sig and discharge_sig. if charge_sig =1 and discharge_sig=0 then the charge block should be enabled. if charge_sig=0 and discharge_sig=1 then the discharge block should be enabled. the charge and the discharge blocks contain integrator and other many Simulink objects. The simulation begin with discharge mode;the discharge block calculate and return continuously the pressure and the volume of compressed air in the reservoir.Lets say for example that the pressure was 5 bars and the volume 100 m^3 when the discharge mode is turned off. The charge block should begin simulating with these values (5 bars and 100 m^3)as initial conditions.The problem is that the enabled block (charge) begin the simulation with another values.it begin simulating with the latest values that are stored in the integrator contained in it during its previous "enable" process. the problem is same when passing from charge mode to discharge mode. any ideas?
I would move the integrator to the outside of the "charge" and "discharge" system. It represents the only reservoir and shouldn't exist in both the "charge" and "discharge" system. You can construct the model to make the output of the "charge" and "discharge" system to be the air flow, positive means charge and negative means discharge or vice versa.
i have reconstructed the model with "air flow" as output. Now it works well.. thank you Mr Fangjun Jiang for your help. You gived me a great idea..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Functions에 대해 자세히 알아보기

제품

릴리스

R2015a

질문:

2018년 8월 23일

댓글:

2018년 9월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by