LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID self tuning using Fuzzy logic

Hello

I am building a temperature control system using Fuzzy PID toolkit. I am building a self tuning PID gains by a fuzzy logic algorithm, but the problem was that when I connect the fuzzy output to the PID gains to tuned them the PID will not respond and it stop working, and I think the reason that when the PID gains become dynamically changed depending on the Fuzzy controller output then the PID will stop working.

 

Please any one can help me to solve this problem because I need to  connect the PID gains to the fuzzy system output to auto tuned them.

 

Thanks

 Mohammed       

0 Kudos
Message 1 of 8
(6,695 Views)

Mohammed,

 

Here is a couple of things to look. First, your code uses PID parameters as Kp, Ki, Kd (three gains). However, the "PID.vi" uses the process control notation where it uses Kc for proportional gain, Ti for Integral Time in minutes and Td for Derivative time, also in minutes. So, you should revise your rule in Fuzzy to be sure that you are not try to make the system too slow to respond by increasing the values of Ti and Td instead of decreasing. Look at the example "C:\Program Files\National Instruments\LabVIEW 2009\examples\control\pid\prctrlex.llb\Manual-Automatic Control.vi" to find out how to convert from Kp,Ki,Kd (Parallel topology) to Kc,Ti,Td (Academic) by using a VI shipping in the example area.

 

Second, the PID algorithm has bumpless transfers on parameters changes. This means that, every time you try to change the values, the PID will try to change its internal states (the integral component) to keep the output the same. However, if you keep change the values constantly, it is possible that depending on the values, it will remove the I and D components of PID. To avoid that, you can just update the PID gains every so often and allow the PID to work on a higher frequency. In general, 10 times faster should be enough. You can do that by using a case structure around your fuzzy system and update that code every 10th iteration of the while-loop.

 

And last, it is always good to verify if your rules are working as you would expect. The best way to test your system is to develop a model of your plant using the LabVIEW Control Design and Simulation module and try to tune the controller offline before going online. Sometimes, just smiple models of the plant could help on this task.

 

Please let me know if you have more questions.

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 2 of 8
(6,651 Views)

Hello

I tried what you told me but the same problem. And I discovered that the problem in the (Ti), when I put Ti=0 the PID respond to the fuzzy controller but with any value of Ti the PID will not give any response, so I can't tune the integral gain.

 

 

0 Kudos
Message 3 of 8
(6,624 Views)

When you say "the PID won't give any response" that means zero or INF? What is the range of you Ti parameters? What is the sampling time used by your system? Also, which rules are you using for tuning the Ti ? Have you try to use a fixed number on the PID parameters to be sure that at least one parameter is possible to control?

 

Also, do you have the LabVIEW Control Design and Simulation Module? Which version of LabVIEW do you have?

 

Sorry for the questions, but this would help me to better understand the problem you have. Thank you for your reply!

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 4 of 8
(6,579 Views)

Another question: could you send a snapshot of the code you use to decimate the Fuzzy System? Maybe if you also attach the code, I can verify the parameters of it.

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 5 of 8
(6,579 Views)

It seems that the issue Mohammed is describing is the following:

 

The first loop is what Mohammed was describing, where having the Ki value change would result in the output value not responding to changes in the setpoint.  For example if the setpoint is 10, the output is 9, but when changing to 20 the output doesn't change.

 

To me, this seems to be more of a control theory issue than a problem with the software. If you look inside the PID vi, it compares the PID gains to the previous values, so we need to ensure that the gain values are settled for at least 2 iterations, otherwise the VI will behave as we were seeing.

If we use ensure that the PID gains values are settled for at least 2 iterations, that means the PID VI has 2 iterations to settle on a corresponding output. The second loop uses a random number generator as input for my Ki, but ensures that we conduct 10 PID calculations before we change the gain value.  Certainly, Barp may be able to provide additional input on this.

 

21435i983955E607AD1DD5

Tejinder Gill
National Instruments
Applications Engineer
Visit ni.com/gettingstarted for step-by-step help in setting up your system.
0 Kudos
Message 6 of 8
(6,568 Views)

Hello

After this discussion and based on Barp & Tejinder  advice I build my fuzzy logic code in a way that makes the PID VI settled for at least 2 iterations to give the desired output and it works very good and the problem solved, so it was a control problem than a problem with the PID.

I posted my code here so every one can get benefit from it.

 

 

Thanks to all

Mohammed

Download All
Message 7 of 8
(6,532 Views)

thank you so much baraka allah fik for the pic but can you poste the code plz ?

0 Kudos
Message 8 of 8
(4,726 Views)