plc fuzzy

Document Sample
plc fuzzy Powered By Docstoc
					                                       plc fuzzy - 26.1




26. FUZZY LOGIC

           <TODO - Find an implementation platform and add section>



                  Topics:
                       • Fuzzy logic theory; sets, rules and solving
                       •

                  Objectives:
                       • To understand fuzzy logic control.
                       • Be able to implement a fuzzy logic controller
                                                                     .




26.1 INTRODUCTION


           Fuzzy logic is well suited to implementing control rules that can only be
    expressed verbally, or systems that cannot be modelled with linear differential equations.
    Rules and membership sets are used to make a decision. A simple verbal rule set is
    shown in A Fuzzy Logic Rule Set. These rules concern how fast to fill a bucket, based
    upon how full it is.




                   1. If (bucket is full) then (stop filling)
                   2. If (bucket is half full) then (fill slowly)
                   3. If (bucket is empty) then (fill quickly)


    Figure 26.1    A Fuzzy Logic Rule Set



             The outstanding question is "What does it mean when the bucket is empty, half
    full, or full?" And, what is meant by filling the bucket slowly or quickly. We can define
    sets that indicate when something is true (1), false (0), or a bit of both (0-1), as shown in
                                     plc fuzzy - 26.2


Fuzzy Sets. Consider the bucket is full set. When the height is 0, the set membership is 0,
so nobody would think the bucket is full. As the height increases more people think the
bucket is full until they all think it is full. There is no definite line stating that the bucket
is full. The other bucket states have similar functions. Notice that the angle function
relates the valve angle to the fill rate. The sets are shifted to the right. In reality this
would probably mean that the valve would have to be turned a large angle before flow
begins, but after that it increases quickly.




            1                                                    1
                                  bucket is full                                    stop filling
            0                                                    0

              1                                                  1
                                    bucket is half full                                    fill slowly
              0                                                  0

              1                                                  1
                          bucket is empty                                                   fill quickly
              0                                                  0
                                          height                                                   angle


Figure 26.2       Fuzzy Sets



        Now, if we are given a height we can examine the rules, and find output values, as
shown in Fuzzy Rule Solving. This begins be comparing the bucket height to find the
membership for bucket is full at 0.75, bucket is half full at 1.0 and bucket is empty at 0.
Rule 3 is ignored because the membership was 0. The result for rule 1 is 0.75, so the 0.75
membership value is found on the stop filling and a value of a1 is found for the valve
angle. For rule 2 the result was 1.0, so the fill slowly set is examined to find a value. In
this case there is a range where fill slowly is 1.0, so the center point is chosen to get angle
a2. These two results can then be combined with a weighted average to get
           0.75  a1  + 1.0  a2 
                                                    -
angle = ---------------------------------------------
                   0.75 + 1.0                         .
                                   plc fuzzy - 26.3



         1. If (bucket is full) then (stop filling)
           1                                                 1
                                 bucket is full                               stop filling
           0                                                 0
                                         height                                              angle
                                                                              a1
         2. If (bucket is half full) then (fill slowly)
              1                                              1
                                   bucket is half full                                  fill slowly
              0                                              0
                                         height                                    a2        angle

         3. If (bucket is empty) then (fill quickly)

              1                                              1
                          bucket is empty                                                fill quickly
              0                                              0
                                         height                                              angle


Figure 26.3       Fuzzy Rule Solving



        An example of a fuzzy logic controller for controlling a servomotor is shown in A
Fuzzy Logic Servo Motor Controller [Lee and Lau, 1988]. This controller rules examines
the system error, and the rate of error change to select a motor voltage. In this example
the set memberships are defined with straight lines, but this will have a minimal effect on
the controller performance.
                                               plc fuzzy - 26.4



            vdesired                 verror      Fuzzy      Vmotor Motor                                               vactual
                                                                             Imotor
                                                 Logic             Power                                Servo
                       +                                                                                Motor
                                 -               Controller        Amplifier


                                                     a
              The rules for the fuzzy logic controller re;
                       1.   If   verror   is   LP and d /dt verror is any then Vmotor is LP.
                       2.   If   verror   is   SP and d/dt verror is SP or ZE then V            .
                                                                                      motor is SP
                       3.   If   verror   is   ZE and d/dt verror is SP then V motor is ZE.
                       4.   If   verror   is   ZE and d/dt verror is SN then V motor is SN.
                       5.   If   verror   is   SN and d/dt verror is SN then V  motor is SN.
                       6.   If   verror   is   LN and d/dt verror is any then V motor is LN.

              The sets for v , d/dt verror , and Vmotor are;
                           error
                                                                       d
                            verror                                         /dt verror                         Vmotor

                   1                                        1                                       1

                   0                                        0                                       0
            LN                                        rps                                   rps/s                                V
                       -100 -50 0 50 100                          -6   -3       0 3     6                 0     6   12 18 24

                   1                                        1                                       1

            SN     0                                  rps   0                               rps/s   0                            V
                       -100 -50 0 50 100                          -6   -3       0 3     6                 0     6   12 18 24

                   1                                        1                                       1

            ZE     0                                  rps   0                               rps/s   0                            V
                       -100 -50 0 50 100                          -6   -3       0 3     6                 0     6   12 18 24

                   1                                        1                                       1
            SP     0
                                                      rps
                                                            0
                                                                                            rps/s
                                                                                                    0
                                                                                                                                 V
                       -100 -50 0 50 100                          -6   -3       0 3     6                 0     6   12 18 24

                   1                                        1                                       1
            LP
                   0                                  rps   0                               rps/s   0                            V
                       -100 -50 0 50 100                          -6   -3       0 3     6                 0     6   12 18 24




Figure 26.4      A Fuzzy Logic Servo Motor Controller



        Consider the case where verror = 30 rps and d/dt verror = 1 rps/s. Rule 1to 6 are
calculated in Rule Calculation.
                               plc fuzzy - 26.5



                            d
      1. If verror is LP and /dt verror is any then V          .
                                                     motor is LP




      1                                   1                                                1

      0                             rps   0                                      rps/s     0                                      V
          -100 -50 0 50 100                     -6    -3      0 3        6                        0        6       12 18 24
                                                            A
                                                     ANY V LUE
                    30rps                            (so ignore)                                                           17V
                                                                                                                           (could also
                        This has about 0.6 (out of 1) membership                                                           have chosen
                                                                                                                           some value
                                                                                                                           above 17V)



                          d
    2. If v                                            motor is SP
           error is SP and /dt verror is SP or ZE then V         .
                                                                                                 the AND means take the
                                              the OR means take the                              lowest of the two
                                              highest of the two                                 memberships
                                              memberships

1                               1                                   1                                  1
                         rps                               rps/s                                                                       V
0                               0                                   0                          rps/s   0
    -100 -50 0 50 100               -6 -3 0 3 6                          -6 -3 0 3 6                           0       6    12 18 24
                                          1rps/s
                    30rps                                                     1rps/s                                           14V
                        This has about 0.4 (out of 1) membership




                            d
      3. If verror is ZE and /dt verror is SP then Vmotor is ZE.




           1                                     1                                                 1
                                                                                         rps/s
           0                              rps    0                                                 0                                   V
               -100 -50 0 50 100                       -6      -3       0 3      6                         0       6       12 18 24
                                                                                           the lowest results in 0 set
                    30rps                                               1rps/s             membership
                        This has about 0.0 (out of 1) membership
                                    plc fuzzy - 26.6




                                    d
              4. If verror is ZE and /dt verror is SN then Vmotor is SN.



              1                                     1                                                          1

              0                         rps         0                                              rps/s       0                                      V
                  -100 -50 0 50 100                         -6        -3        0 3       6                            0       6       12 18 24
                                                             1rps/s                                        the lowest results in 0 set
                            30rps
                                                                                                           membership
                             This has about 0.0 (out of 1) membership




                                    d
              5. If verror is SN and /dt verror is SN then Vmotor is SN.



                  1                                     1                                                          1

                  0                           rps       0                                             rps/s        0                                      V
                      -100 -50 0 50 100                          -6        -3    0 3          6                            0       6    12 18 24
                                                                       1rps
                            30rps
                             This has about 0.0 (out of 1) membership




                                    d
              6. If verror is LN and /dt verror is any then Vmotor is LN.




              1                                 1                                                          1

              0                                 0                                                          0                                      V
                                        rps                                                       rps/s
                  -100 -50 0 50 100                     -6        -3        0 3       6                            0       6       12 18 24

                                                             ANY VA LUE
                            30rps
                             This has about 0 (out of 1) membership


Figure 26.5   Rule Calculation



      The results from the individual rules can be combined using the calculation in
                                              plc fuzzy - 26.7


       Rule Results Calculation. In this case only two of the rules matched, so only two terms
       are used, to give a final motor control voltage of 15.8V.




                                                 n
                                                 V motor   membershipi 
                                                                         i

                               V motor =      i=1                                                                 -
                                              ---------------------------------------------------------------------
                                                            n

                                                            membershipi 
                                                        i=1



                              V motor = 0.6 17V  + 0.4 14V  = 15.8V
                                        ---------------------------------------------------
                                                       0.6 + 0.4


       Figure 26.6    Rule Results Calculation




26.2 COMMERCIAL CONTROLLERS


               At the time of writing Allen Bradley did not offer any Fuzzy Logic systems for
       their PLCs. But, other vendors such as Omron offer commercial controllers. Their
       controller has 8 inputs and 2 outputs. It will accept up to 128 rules that operate on sets
       defined with polygons with up to 7 points.



               It is also possible to implement a fuzzy logic controller manually, possible in
       structured text.




26.3 REFERENCES

Li, Y.F., and Lau, C.C., “Application of Fuzzy Control for Servo Systems”, IEEE International
   Conference on Robotics and Automation, Philadelphia, 1988, pp. 1511-1519.
                                             plc fuzzy - 26.8



26.4 SUMMARY

                • Fuzzy rules can be developed verbally to describe a controller.
                • Fuzzy sets can be developed statistically or by opinion.
                • Solving fuzzy logic involves finding fuzzy set values and then calculating a
                   value for each rule. These values for each rule are combined with a weighted
                   average.



26.5 PRACTICE PROBLEMS



26.6 PRACTICE PROBLEM SOLUTIONS



26.7 ASSIGNMENT PROBLEMS


1. Find products that include fuzzy logic controllers in their designs.

2. Suggest 5 control problems that might be suitable for fuzzy logic control.

3. Two fuzzy rules, and the sets they use are given below. If verror = 30rps, and d/dtverror = 3rps/s,
   find Vmotor.
                                            plc fuzzy - 26.9


                                       d
                    error is ZE) and ( /dt verror is ZE) then (V
             1. If (v                                            motor is ZE).
                                    d
                    error is SP) or ( /dt verror is SP) then (V
             2. If (v                                          motor is SP).

                                                 d
                 verror                              /dt verror                       Vmotor

         1                              1                                     1

   SN    0                        rps   0                             rps/s   0                      V
             -100 -50 0 50 100              -6   -3       0 3     6               0   6   12 18 24

         1                              1                                     1

   ZE    0                        rps   0                             rps/s   0                      V
             -100 -50 0 50 100              -6   -3       0 3     6               0   6   12 18 24

         1                              1                                     1
   SP                             rps                                 rps/s                          V
         0                              0                                     0
             -100 -50 0 50 100              -6   -3       0 3     6               0   6   12 18 24


4. Develop a set of fuzzy control rules adjusting the water temperature in a sink.

5. Develop a fuzzy logic control algorithm and implement it in structured text. The fuzzy rule set
   below is to be used to control the speed of a motor. When the error (difference between
   desired and actual speeds) is large the system will respond faster. When the difference is
   smaller the response will be smaller. Calculate the outputs for the system given errors of 5, 20
   and 40.
                                  plc fuzzy - 26.10




        100%

Big Error

                                                                error
             0%
                                 10                   30

        100%

Small Error

                                                                error
             0%
                                 10                   30
              20

Big Output

                                                                error
                                                           50



Small Output
           5
                                                                error
                                                           50
             if (big error) then (big output)
             if (small error) then (small output)

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:14
posted:9/29/2012
language:Unknown
pages:10