Monday, August 24, 2015

Paint Flow Control Project, Fuzzy Logic One More Time, 3.16a

I was fairly pleased with the results of my Fuzzy Logic algorithm which used two Look-Up-Tables (LUTs) for the control, simulated of course. I started with the 1989 IEEE Control System magazine article "Development of Fuzzy Algorithms for Servo Systems" by Y.F. Li and C. C. Lau (Li and Lau). Li and Lau used a two stage FL control scheme, a Coarse LUT and a Fine LUT. (I was going to abbreviate the names for the LUTs but feared making an obscene name :-) ) However, I didn't like their LUTs and so I modified them to tighten up the response near Error = 0 for the Coarse LUT and near Error Change = 0 for the Fine LUT. The Coarse LUT was intended to reduce the system error to less than 100 units and then the Fine LUT was intended to further home in on the system Setpoint.

After modifying Li and Lau's LUTs, I got pretty good response with my LUTs. However, I became concerned that the Coarse LUT may not always be able to reduce the Error to less than 100 to allow the Fine LUT to be activated. So after pondering the problem for a few minutes, I decided to add a third LUT that would be activated in between the Coarse and Fine LUTs. I decided to simply try using my Coarse LUT as an Intermediate LUT (ILUT), changing the scale factors and have the ILUT activated when the Coarse LUT reduced the Error value to less than 173. So if the Error was greater than 300, the Coarse LUT would be used, when the Error is less than 300 but greater than 173 the ILUT would be used and finally for Errors less than 100 the Fine LUT would be used. I also established new scale factors for the ILUT, starting with the Coarse LUT scale factors, adjusting the scale factors accordingly.

I ran some simulations and found that this three-stage scheme worked well, getting to the Setpoint a little faster than the two-stage scheme, and I believe it should be safe since the Coarse LUT always reduced the Error to much less than 173 and probably to less than 100.

First I ran simulations with the original Time Constant of 0.28 sec and then I changed the Time Constant to 1.0 sec, closer to what I believe is the Paint Flow System Time Constant, and I ran some more simulations. With Python, it was easy to modify my code to insert the ILUT and set up the various scale factors. So here are my simulation charts:

Simulation of Three-Stage Fuzzy Logic LUT Scheme with TC=0.28s, Sample Rate=0.25s.

Then I decided to change the system Time Constant to 1.0 sec, about what I figure the Paint Flow System time constant to be. The chart below is with a Sample Rate of 0.25 sec, four times the Time Constant. It shows pretty good response and accuracy with a tiny bit of overshoot.

Simulation of Three-Stage Fuzzy Logic LUT Scheme with TC=1.0s, Sample Rate=0.25s.
The next chart is for a Sample Rate of 0.125 sec, or eight times the Time Constant, and the overshoot is evident but the simulation Error comes down to about the same values as the other three LUT simulations.

Simulation of Three-Stage Fuzzy Logic LUT Scheme with TC=1.0s, Sample Rate=0.125s.
Then I tried a Sample Rate of 0.5 sec which resulted in good response and low Error with only a slight overshoot.

Simulation of Three-Stage Fuzzy Logic LUT Scheme with TC=1.0s, Sample Rate=0.5s.

For the final simulation, I set the Sample Rate at 0.9 sec. The results are also good.

Simulation of Three-Stage Fuzzy Logic LUT Scheme with TC=0.9s, Sample Rate=0.5s.
I mistakenly tried a Sample Rate of 2.0 sec and got a very strange chart that looked like a growing oscillation. Then I realized that my implementation of the Low-Pass Filter for the system response would not allow a Sample Rate greater than the Time Constant. My formula for the system response is below, where k=Sample_Rate/Time_Constant and v is the output of the controller:

Sim_Flow = k*v + (1-k)*Prev_Sim_Flow

So k must be less than 1.0 for the formula to be legitimate.

Anyhow, this three-LUT scheme is now working well and with the Intermediate LUT to be activated when the Coarse LUT reduces the Error to 173, I can be sure that the control system won't be stalled with an error a little over 100: the ILUT will take over and reduce the Error to less than 100 for the Fine LUT to finish reducing the Error.

Another note: I thought that Li and Lau were employing some trickery in their use of a Sample Rate of 0.25 sec for the Time Constant of 0.28 sec but I now realize that the system time constant must be known or measured in order for the Fuzzy Logic control system to operate properly and also that the Sample Rate must be less than the system Time Constant. Sample Time values of 0.25 to 0.5 times the Time Constant seem to produce good response and accuracy.

Thanks again to Y.F. Li and C. C. Lau and their very useful and helpful paper in the IEEE Control System magazine, 1989 IEEE Control System magazine article "Development of Fuzzy Algorithms for Servo Systems."

No comments:

Post a Comment