Announcement

Collapse
No announcement yet.

Example Click PID

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • #16
    Ok I kinda follow what you are saying but my issue is I`m very new to this I have no idea where to start with the numbers for example I need to put in a value for df8 df5 and so on I have no experience as to where to start.

    Comment



    • #17
      OK I changed all the addresses df101-114 then went back changed df101 becomes my df1 input, then df104 changed to my df3 output. So do I do a copy command to 108,105,106,107,and 109. Thanks very much I`m under the gun here.

      Comment



      • #18
        If you have changed the tags in the PID program from DF1-DF14 to DF101-DF114 and copied the lines of code to your new program, then utilize the tags in the same manner in your program.

        Old DF1 - New DF101 - Process Variable
        Old DF2 - New DF102 - Setpoint
        Old DF3 - New DF103 - Error
        Old DF4 - New DF104 - Control variable
        Old DF5 - New DF105 - Current Integrator
        Old DF6 - New DF106 - Int Max
        Old DF7 - New DF107 - Int Min
        Old DF8 - New DF108 - Proportional Gain
        Old DF9 - New DF109 - Integral Gain
        Old DF10 - New DF110 - Derivative Gain
        Old DF11 - New DF111 - Proportional Term
        Old DF12 - New DF112 - Integral term
        Old DF13 - New DF113 - Derivative Term
        Old DF14 - New DF114 - Current Derivative

        Comment



        • #19
          Ok I have it working heres what I finally had different
          df1 = process v
          df115= set point
          df3 = control variable

          I copied
          df108=5
          df105=2
          df107=4
          df109=2
          I scaled the output df3 7-700
          I have some hardware issues solenilds stuck working them out now. Looks like she might work at least as I move set point around it appearslike it will work. Hey many Thanks to you and especially to B Carlton for the sharing of his hard work. I will plan to do same for next guy if Im capable. Thanks again everyone.

          Comment



          • #20
            OK I`m controlling pretty good at top set point 225 hit 225 then drop to 175 back to 225 what numbers should I change to increase my lower area of error. Thanks guess I will play with them.

            Comment



            • #21
              In my experience with PID in heating, the "D" is not necessary. Not sure what value it should be to have no effect. My experience with PID is with the P2K. from its help file:

              Derivative (rate) time:
              In many cases this parameter is not required to achieve stable Loop operation and is highly sensitive to noise in the Error Term. This value is directly Proportional to the control effect, meaning that the higher the Derivative Term setting, the quicker the Error will be removed.
              Why worry? If you've done the best you can, worrying won't make it any better

              - Walt Disney

              Comment



              • #22
                Resurrecting an old thread.

                So I've done PID in an P2K, but now I'm tasked to do it in a Click because of the savings in PLC cost. I'm controlling an electrical heater to reach a specific temperature, and just stay at that temperature. So, I use the time proportional logic as shown in help topic P167 in Productivity Suite. But how do I do the preset of timer 2, when there is no scale command in Click? Is there a
                better way? I'm all ears!
                Click image for larger version

Name:	Scale linear.png
Views:	256
Size:	120.6 KB
ID:	123634
                Why worry? If you've done the best you can, worrying won't make it any better

                - Walt Disney

                Comment



                • #23
                  Scaling is just math and the CLICK does math pretty well. For your 0-65535 converted to 0-1000, just divide by either 65 or 66, or use floats and divide by 65.535 I believe the CLICK rounds (as opposed to truncate) when converting back to an integer, and one does need an integer for a timer preset

                  Comment



                  • #24
                    Iím not gonna talk much about my own servo controller method. Only to mention that my controller works on a time base and attempts to assess the location, the direction of motion and the speed of the process value relative to the set value. Itís an approach to assess a process inertia on the spot, considering that changes in inertial behaviour of any process is what throws the control system off course. Is also a work in progress, destined to either succeed or fail. The reason Iíve mentioned it here is to show that PID is nothing else than a brute-force solver for an integral-differential equation too difficult to solve via numerical methods and that PID falls short at countering sudden changes which are obvious for a human observer.

                    the only question I could take from the previous paragraph is what do I mean by failing to counter sharp turns that are obvious to a human observer.
                    a control system can not take a sudden change of magnitude and direction for the process vector, because it makes no sense. For example a heater controller will continue to max its values given that temperature doesnít pick up fast enough to fall in the controlling envelope.

                    here I talk from my own experience: we had hot melt heaters working fine all week long. However, in weekend we would shut them down and on cold restart, the heaters will end up burning the hot melt, for being unable to control the temperature spike. My solution at the time, which made me regard myself as a wizard, was to shut down the heater with the temperature half way up. Then wait. The temperature will climb to almost set value, then stabilize for a little while. Easy guess: I would power the heater back up, giving the controller an easy task at controlling a temperature close to set value. Without this wizardry, the controller will heat too much, then wait too much to cool down, then reheat too much, and this may or may not lead to set temperature.

                    this is what I mean easy picking for the human observer, while for the automated controller an impossible task.

                    a servo drive relies on a PID controller to maintain the speed or ramp accordingly. What makes it work is the correct configuration overlapped on high-speed encoder input: the high speed input gives it a tremendous processing speed, allowing the controller to know how far off course and what speed it moves. The controller then determines the system inertia and if it falls within control limits, will react; if not then will attempt an emergency shutdown.

                    a regular motor drive doesnít have that awareness. It will only produce the speed upon request, not knowing ever wether the shaft achieved it or not. There is a minimal control via the current absorbed by the motor, but not enough to work out the rpm; this overload current can be used to protect the drive though, and I have always used it as a redundancy to magneto-thermal breakers.

                    which drives me to the next topic: what is a fuse? I have met so many people who believe the fuse is protection against power grid that I wouldnít be surprised to find them here as well. So letís play: a fuse is a means to protect the power supply against a failed device. In the previous example, we use thermal breakers to protect the motor driver in case the motor shorts. However, we do change motors and not for weaker but for more powerful ones, and since the breaker was already over-dimensioned, I had the surprise to find the AC drive damaged, until I have set the overload current parameter. Then whenever the motor misbehaved, the drive just stopped instead of burning.

                    my days at actually building automation are getting shorter now. You guys have a lifetime of fun ahead of you. Just make sure youíve got the fundamentals right, they are your circuit breakers. Understand those circuit breakers correctly. The rest is just hobby time: discovery and fun. Enjoy!

                    Comment



                    • #25
                      Originally posted by bcarlton View Post
                      This is a Click program (the 'Main' is actually empty) with a PID calculation in the interrupt subroutine. It is called based on a timed interrupt. This is set up according to the PDF referenced in this posting

                      You may want to check the claculation of the error in the first math box. Different types of PID (forward versus reverse acting) will calculate this in the opposite manner.
                      Bernie, just curious as to the why you placed the PID in a timed interrupt? Is it a scan time saver?
                      Why worry? If you've done the best you can, worrying won't make it any better

                      - Walt Disney

                      Comment



                      • #26
                        Or maybe an attempt to minimize the impact of scan-time variations
                        Last edited by kewakl; 07-20-2019, 02:03 PM.

                        Comment



                        • #27
                          I don't have a satisfactory answer for why a timed interrupt. I think I was trying to answer a post back then about PID loops missing in the Click. I had read the article I based it on and knew that conceptually the loop is just a few ordinary math functions. I never actually used that in any real applications. It's kind of like people worried about scaling when it's so simple.

                          You can do wonders with just add, subtract, multiply and divide. In fact, fairly early on in my PLC programming career a teacher from a local school brought an advanced math class through our plant. We were programming microprocessor based controllers at the assembly language level. He asked, for the class, what level of math we were using expecting trig or calculus. I relied with add, subtract, multiply and divide. He seemed disappointed.
                          thePLCguy

                          Bernie

                          Comment



                          • #28
                            Well, I've borrowed your PID to use in a project, as I've relied on built-in PID when using higher end PLCs. But now I work for an OEM who sells in volume, and the cost of the PLC is a big deal (even $100 makes a difference), so I'm tasked on certain products to do as much as possible with the Ethernet Click as the CPU has its own I/O (which is a space saver over P1K).

                            I ask about timed interrupts as I've never used them, and I like learning something new when coding. Since the explanation in the Click manual doesn't say much, I guess timed interrupts are for time critical applications? (I see the Click manual mentions high speed inputs).

                            Thanks for your explanation, Bernie, I appreciate it.
                            Why worry? If you've done the best you can, worrying won't make it any better

                            - Walt Disney

                            Comment



                            • #29
                              Hi Bernie,
                              I took your PID example and made a demonstration using Factory IO. This will show the level of water in a tank using your PID calculations to control.
                              Click PLC PID using Factory IO - Video
                              Thank you,
                              Garry
                              Click image for larger version

Name:	Click PLC PID using Factory IO 010-min.png
Views:	47
Size:	85.8 KB
ID:	125583

                              Comment

                              Working...
                              X