Fuzzy control problem:(1)input 2 expects a value in range [-1.5 1.5], but has a value of 4.36559e+24;
Show older comments
In 'EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller', input 2 expects a value in range [-1.5 1.5], but has a value of 4.36559e+24.
取消组合 1025 相似
显示堆栈跟踪
组件:Simulink | 类别:Model 警告
In 'EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller', no rules fired for Output 1. Defuzzified output value set to its mean range value 0.
取消组合 3075 相似

7 Comments
Sam Chak
on 14 May 2024
Hi @柯
Based on the image you provided, it seems that the 'input 2' to the Fuzzy Logic Controller block is derived from the derivative signal. The very high value you're observing is likely caused by a sudden surge in the signal due to a setpoint jump. This phenomenon is commonly referred to as "derivative kick due to setpoint jump".
The Fuzzy Logic Controller you designed expects the derivative signal to be within the range of
. However, it appears that the Saturation block is unable to effectively constrain the input signal to the upper saturation value. I recommend verifying if the observations I described align with the actual behavior of the system.
Ke
on 15 May 2024
Hi @柯
In order to investigate the issue further, I will need to thoroughly examine both the Simulink model and the Fuzzy Inference System (FIS) files.
If possible, could you please share the Simulink file and the FIS file with me? Please ensure that the '.fis' file is first archived or zipped before sharing it. If you encounter any difficulties in doing so, you can also open the fis file and copy/paste its contents to share them with me.
[System]
Name='Fuzzy_Logic'
Type='sugeno'
Version=2.0
NumInputs=1
NumOutputs=1
NumRules=2
AndMethod='prod'
OrMethod='probor'
ImpMethod='prod'
AggMethod='sum'
DefuzzMethod='wtaver'
[Input1]
Name='input1'
Range=[-0.04 0.04]
NumMFs=2
MF1='mf1':'zmf',[-0.04 0.04]
MF2='mf2':'smf',[-0.04 0.04]
[Output1]
Name='output1'
Range=[0 1]
NumMFs=2
MF1='mf1':'constant',[-1]
MF2='mf2':'constant',[1]
[Rules]
1, 1 (1) : 1
2, 2 (1) : 1
Ke
on 15 May 2024
Edited: Walter Roberson
on 17 May 2024
Sam Chak
on 15 May 2024
Hi @柯
Since your model was incomplete, I had to make some necessary adjustments to get it up and running. However, I made sure not to alter the design of your Fuzzy Inference System (FIS). Based on my findings, it appears that the Derivative block is causing the problem. To resolve the issue, I suggest removing the troublesome block and connecting a time-derivative signal to the ec port instead.
By making this modification, you should be able to address the issue and achieve the desired results.


Ke
on 15 May 2024
Ke
on 15 May 2024
Accepted Answer
More Answers (1)
Sam Chak
on 17 May 2024
0 votes
Hi @柯
This following issue does not affect the original "derivative kick" problem described in this thread. So, it should be treated separately.
On the reason why the number of output membership functions (MFs) should be ideally 13, first, you need to review the If–Then rulebase (see Fig. 1). Look at the yellow boxes - you'll see that many of the output MFs are reused throughout the 49 rules. This causes the Fuzzy Kp surface in Fig. 2 to look a little strange.
Going back to the rulebase, since there are 2 inputs (e and ec) and each input has 7 MFs, there are 7 rule sets of 7 rules (see the 1st rule set in the orange box). However, there were only 4 output MFs in your original Kp design (see Fig. 3). So, for each rule set, you only have 4 output MFs to fill up the 7 rules, and thus, reusing some MFs is inevitable, making the fuzzy rules inflexible and less unique.
To address this issue, you can add another 3 Positive MFs (mf8, mf9, mf10) on top of the existing 4 output MFs (see Fig. 4). Now there will be enough 7 distinct MFs for the 7 rules in the first rule set. If you add another 3 Negative MFs (mf11, mf12, mf13) on the Negative side for Kp, Ki and Kd, there are just enough MFs for the 7 rule sets (all 49 rules). That's why I mentioned ideally there should be "13 MFs for each output"!
Figure 1: Fuzzy If–Then rulebase.

Figure 2: Fuzzy Kp surface

Figure 3: Original Fuzzy Kp output membership functions

Figure 4: Modified Fuzzy Kp output MFs (positive side for demo only)

36 Comments
Ke
on 17 May 2024
Sam Chak
on 17 May 2024
Hi @柯
It is not a "must" to have 13 MFs. There is no right or wrong when designing fuzzy rules because the rules really reflect the human designer's thinking at the time. The fuzzy performance can be either very effective, moderately effective, or less effective. That's why I said "ideally"...
However, it is a relatively common behavior I have seen in many Mamdani Fuzzy Control practitioners, as the unverified fuzzy design knowledge was passed down. You probably created the rules based on a reference (because your research topic is similar), and there is no design work for improvement.
Anyway, no worries at the moment. Please fix the "Derivative Kick" issue. Your Prefilter was placed in the wrong place, and you used my PID controller, which I designed for a Double Integrator. So, I have created a hotfix for you. You can just download, copy and paste the entire fuzzy control model into your Compressor model (which is not shown to me). Hopefully, the "Derivative Kick" issue will be resolved.
Ke
on 20 May 2024
Sam Chak
on 20 May 2024
Hi @柯
Do you have the mathematical model or the differential equations of the system that you are trying to control?
Don't blame yourself. Mamdani fuzzy controllers are never easy to design with in the first place. It often requires a lot of fine-tuning on the gains, the membership functions, or the rules. If this is a second-order system model, I'd tend to limit it to 2 MFs and 4 rules, or 3 MFs and 9 rules.
Hi @柯
Thanks for the info about the Compressor. Since you referred to a pre-designed rule table in a reference, would you be able to provide the document containing that information?
Alternatively, if you cannot share the document directly, could you please provide the title of the document (if it can be searched online), or the DOI number of the publication?
Having access to the relevant source material would greatly assist me in understanding the context and specifics of the rule table you mentioned.

Ke
on 22 May 2024
Sam Chak
on 22 May 2024
Hi @柯
Thank you for sharing the relevant documents regarding the Battery Thermal Management (BTM) system in Electric Vehicles. I have carefully reviewed the provided two PDFs, but I don't have a Tencent Cloud account.
Upon examination, it appears that the authors have utilized a physical modeling approach with Siemens Amesim rather than a conventional mathematical modeling technique. This is an interesting choice, as thermal dynamics are often represented using first-order differential equations.
Regarding your control block diagram, it seems that your primary control objective is to regulate the temperature of the battery pack, rather than the temperature of the compressor. In this case, the compressor fan speed would likely be the actuated variable, and the fuzzy control output would serve as the commanded signal to the fan speed.
Ke
on 23 May 2024
Hi 柯,
Do you have the corresponding tuned PID gain values for the disturbances?
For instance, in Condition 1 ( minimum operating point), you have the specific PID gain values for compensating the disturbance. Then, in Condition 2 ( maximum operating point), you have another set of PID values.
If you possess these two sets of PID values, then fuzzy logic would be a suitable tool for performing interpolation between the two sets, in order to determine the appropriate PID gains for intermediate operating conditions.
Sam Chak
on 23 May 2024
Hi @柯
Can you do me a favor? Let me walk through the steps in a clear and structured manner.
- First, remove the Pre-filter and the Filtered Derivative components from the existing control architecture.
- Next, replace the entire fuzzy PID controller with the built-in PID controller, as suggested.
- then click the "Tune" button to initiate the auto-tuning process, which should determine the optimal values for the P, I, D, and N parameters according to the default setting.
- After completing the auto-tuning, provide the following information:
- A block diagram to demonstrate the correct replacement of the control components.
- The values of the auto-tuned P, I, D, and N parameters.
- A plot that compares the Actual Temperature and the Desired Temperature, allowing us to assess the performance of the new control system.

Ke
on 24 May 2024
Ke
on 24 May 2024
Sam Chak
on 24 May 2024
Since the PID controller output is highly constrained between 0 and 1 (60% of the output is 1), and both the Integral and Derivative terms do not significantly contribute to the saturated control action, I suggest trying to replace the PID controller with this nonlinear control function:
, where k is a relatively large value, maybe between 100 to 1000.
Ke
on 24 May 2024
Hi @柯
Ignore the previous suggestion as ec is not needed. Try this one instead. Replace the PID controller with this block configuration: You can say that this is a nonlinear Proportional Controller, almost similar to what you did with the Fuzzy Logic previously.
Let me know the result.

Ke
on 25 May 2024
Sam Chak
on 26 May 2024
Hi @柯
Thank you for the results. The reason I requested to test the tanh controller is because I wanted to confirm my suspicion that your designed PID Controller block with Internal Saturation [0, 1] may be the culprit that caused the performance bottleneck. The amplitude of a hyperbolic tangent function, tanh(x), is constrained between [-1, 1].
Observation 1:
With both sets of results, I can now compare the Cabin Temperature responses. Both Cabin Temperature responses appear to converge at nearly the same rate, though the response under the tanh controller converged slightly faster.
Observation 2:
In response to the disturbance, the Saturated PID Controller caused the Cabin Temperature to drop lower than the Setpoint (25°C). The occupants inside the Cabin may feel slightly uncomfortable with this offset. Under the tanh Controller, the Cabin Temperature is successfully regulated around the Setpoint (25°C) with very small deviations. The occupants inside the Cabin would likely not have noticed these minor changes in temperature.
Questions:
Before I provide any further recommendations, I would like to better understand the control design requirements.
- Are you satisfied with the Cabin Temperature response converging at around 1,200 seconds?
- If not, what is the desired settling time? For example, would you prefer it to converge around 600 seconds (equivalent to 10 minutes)?
- What is the amplitude of the external disturbance?

Ke
on 27 May 2024
Sam Chak
on 27 May 2024
Hi @柯
This topic is actually called disturbance rejection, and it remains an active area of research due to the various types of disturbances present in many complicated nonlinear systems. Consequently, cost-effective control strategies tailored to different applications are necessary.
Using the integral action in the PID controller to handle external disturbances is akin to treating the symptoms rather than the root cause (治标不治本). If the disturbance load is constant, such as a robot arm picking objects of different fixed weights (
), then the integral action tends to perform relatively well.
In contrast, the fast-switching action of the tanh controller
relies on its control magnitude (the larger
the better) and the switching frequency (how quickly it reacts to changes in the error caused by the disturbance) to overcome the external disturbance. While this approach is effective, as you noticed the fluctuation becomes smaller, it is similar to the Chinese proverb "Kill 1,000 enemy soldiers but lose 800 of your own" (杀敌一千,自损八百). Due to the fast-switching action, some mechanical parts in the control actuator may wear out more quickly and require costly frequent replacement.

Suggestion:
Ideally, if the external disturbance can be accurately measured, either directly or indirectly through observations of changes in the error, then it can be canceled out through the controller. This is treating the the root cause.
Since this is a controlled experiment, it should be possible, at least in simulations, to measure the rapid increase in the positive heat flow into the passenger compartment caused by the sudden closure of the adjacent battery circuit. Once this value is determined, the controller can be used to induce an opposite negative heat flow to counteract the positive heat flow and bring the cabin temperature back to the setpoint (25°C).
Ke
on 27 May 2024
Sam Chak
on 28 May 2024
Hi @柯
I believe your idea of using fuzzy control is feasible, provided you understand the following:
- The estimated mathematical model of the process system being controlled.
- The nature of the disturbance (constant, state-dependent, or time-dependent).
- The strategies employed by controllers to reject the corresponding disturbance.
Unless there are successful examples that you can directly follow, describing the fuzzy controller in the traditional way using Mamdani-type with many triangular membership functions and an abundance of ineffective "human" rules will make it very challenging to achieve the objective of rejecting the disturbance.
For example, dividing the error into 7 regions by creating 7 membership functions is akin to attempting to cut a round cake into 7 equal pieces for 7 people. Unless a special cake-cutting mold is used, an ordinary person cannot precisely cut a round cake into 7 equal pieces. A pastry chef using a 7-piece cake divider tool is analogous to an engineer applying control theory knowledge in fuzzy control design.
Ke
on 28 May 2024
Ke
on 26 Jun 2024
Sam Chak
on 26 Jun 2024
@柯: but [the] running speed is relatively slow ... and its effect is not much different from my PID control.
Response: That's because you clamp the max output of the fuzzy controller to 1. In other words, the controller doesn't have enough "power" to cool the cabin's temperature faster. You didn't tap into the nonlinear control power of fuzzy logic. The concept is similar to charging your mobile phone: a high-power adapter delivers fast charging! Use a high-horsepower conditioner, and you should see immediate improvement.
@柯: but I found that [the] overshoot here is still a bit large, what should I do?
Response: I believe that such a response is completely normal when there is a sudden disturbance, and your controller doesn't have much "power" to compensate for it rapidly. You can try increasing the Derivative gain, but there is no guarantee it will work because the output is clamped at the max value of 1.
@柯: The result I set seems to be still some distance, here I can adjust the I parameter to achieve approximation?
Response: If you are referring to the steady-state error (the difference between black and red curves), then such a very small gap is completely normal in simulation as well as in real scenarios. The observation is similar to water tank level control, where the water level cannot be accurately regulated to the perfect desired level. For example, if the desired level is 10, the steady-state water level will probably maintain at 9.99 or 10.01.
Overall, the performance of the designed fuzzy controller looks fine, and it has the capability of rejecting the effects caused by sudden disturbances.
Ke
on 26 Jun 2024
Sam Chak
on 27 Jun 2024
Hi @柯
A1: I cannot comment on the technical details of the revised control architecture, as I am unable to look inside the "模糊规则" subsystem. However, given that the cabin response appears to be converging sensibly to the setpoint, I believe your overall control design is acceptable.
A2: Limiting the output in a constrained control problem is considered a practical approach. There is nothing inherently wrong with that. However, you should be mindful of the limitations of what your proposed control architecture can achieve. Additionally, I'm afraid I don't fully understand the statement about the "result being unreasonable."
A3: Since you aim to reduce the overshoot, it would be natural for me to advise you to try increasing the derivative gain. However, the side effect of this approach is that it will cause the response to become slower. Ideally, the designer should seek to find the "best" derivative gain that yields the shortest settling time while producing minimal overshoot.
A4: Yes, and this will be the optimization aim as mentioned in the last sentence of A3.
Ke
on 27 Jun 2024
It is now an optimization problem. I believe that MATLAB's built-in fmincon(), ga(), particleswarm() should work in your case. fmincon uses a sequential quadratic programming (SQP) method; ga uses the Genetic Algorithm; and particleswarm uses the PSO algorithm.
Try finding the best value for a single, most influential control parameter first. If successful, then gradually increase the number of parameters that you believe will improve the performance. Why? Because I have seen some inexperienced PhD researchers and postdocs attempt to optimize all parameters of the fuzzy membership functions (both inputs and outputs) at once, with a click of a button, and let the PC run for days.
Imagine one triangular MF has three parameters, thus seven MFs have 21, and two inputs (E & EC) have 42 parameters, excluding the output MFs and other Master PID gains.
If including the full-combination 13 MFs for each fuzzy output (Kfp, Kfi, Kfd) and the Master PID gains, then there will a total of
7*3*2 + 13*3*3 + 3
parameters to be optimized.
Ke
on 28 Jun 2024
Sam Chak
on 28 Jun 2024
Hi @柯
I would suggest that you start by taking the self-paced Optimization Onramp course, which is available at the following link:
This course should help you familiarize yourself with the basics of solving optimization problems in MATLAB. It covers topics such as defining optimization variables, implementing objective functions, and solving both unconstrained and constrained optimization problems.
If you encounter any technical issues in your optimization problem with Simulink, I would recommend posting a new, focused question. This will help prevent the current discussion on the fuzzy control topic from becoming an overly lengthy thread.
Ke
on 28 Jun 2024
Categories
Find more on Fuzzy Logic in Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




























