PID controller tuningCan an ASP.NET MVC controller return an Image?Port 80 is being used by SYSTEM (PID 4), what is that?How to get PID of background process?Downloading a file from spring controllersWhat is a .pid file and what does it contain?How to create separate AngularJS controller files?get pid in shell (bash)PID controller affect on a differential driving robot when the parameters (Kp, Ki, and Kd) are increased individually. [full Q written below]fsolve mismatch shape error when nonlinear equations solver called from ODE solverIntegral only control (as opposed to PI or PID)

Would there be balance issues if I allowed opportunity attacks against any creature, not just hostile ones?

Do index funds really have double-digit percents annual return rates?

Can an intercepting fighter jet force a small propeller aircraft down without completely destroying it?

How to check status of Wi-Fi adapter through command line?

What percentage of the mass/energy of the universe is in the form of electromagnetic waves?

Why not use futuristic pavise ballistic shields for protection?

Received email from ISP saying one of my devices has malware

How can I design a magically-induced coma?

Why do modes sound so different, although they are basically the same as a mode of another scale?

A question about dihedral group

Why did the VIC-II and SID use 6 µm technology in the era of 3 µm and 1.5 µm?

Does the Scrying spell require you to have a clear path to the target in order to work?

FHE: What is the difference between multiplicative depth and multiplicative level?

Is there anything in the universe that cannot be compressed?

What is a "fat pointer" in Rust?

Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code

Divide Numbers by 0

Can my UK debt be collected because I have to return to US?

Can there be plants on the dark side of a tidally locked world?

Sum of Infinite series with a Geometric series in multiply

Punishment in pacifist society

Does the size of capers influence their taste?

Visiting girlfriend in the USA

What is the significance of 104%?



PID controller tuning


Can an ASP.NET MVC controller return an Image?Port 80 is being used by SYSTEM (PID 4), what is that?How to get PID of background process?Downloading a file from spring controllersWhat is a .pid file and what does it contain?How to create separate AngularJS controller files?get pid in shell (bash)PID controller affect on a differential driving robot when the parameters (Kp, Ki, and Kd) are increased individually. [full Q written below]fsolve mismatch shape error when nonlinear equations solver called from ODE solverIntegral only control (as opposed to PI or PID)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am currently optimizing a PID controller based on the gain (Kc), integral time constant (tauI), derivative time constant (tauD) and the filter derivative time constant (tauC). The problem requested is to optimize the controller in a way that the error is close to zero (average_error = 0).



The smallest error I can get is around 15 (base values) while I know I should be able to get below 1. The parameters used for this are when Kc = 1, tauI = 1, tauD = 1 and tauC = 1. This is found by using iterations, widgets, and trial and error. I'm really at a loss as to how I should code this in order to obtain the smallest possible parameters. It seems as if any change in the parameters cause a significant change in the error at this minimum value. Any help is greatly appreciated.



import sys
import control
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Pull data from CSV

file = 'profiledata.csv'
data = pd.read_csv(file,sep=',')
T_i = data.values

# Universal Variables

time_array = np.linspace(0,59,60)
perf = np.linspace(1,1,100)
average_perf = np.linspace(1,1,100)
Kc = 1
tI = 1
tD = 1
tC = 1

# Functions

for i in range(len(perf)):

s = control.tf([1,0],[0,1])
Gp = 1/(s**2 + s + 1)
Gd = (s+1)/(s**2+s+1)
Gc = Kc*(1+1/(tI*s) + tD*s/(tC*s + 1))
sys_D = Gd/(1+Gp*Gc)
_,T,_ = control.forced_response(sys_D, time_array, T_i[:,i])

# Compute output based on disturbance closed loop TF sys_D

_,Q,_ = control.forced_response(-Gc, time_array, T) # Compute input

perf[i] = sum(abs(T) + (0.2)*abs(Q))

# Calculate the average error from the parameters

average_perf = sum(perf)/100

print(average_perf)


The expected result is when average_perf = 0. The data file read are disturbance profiles with 100 columns and 60 rows. Is there anyway to test the optimal parameters, hold that parameter and then test the other parameters with that parameter fully optimized for the smallest error? Or am I just looking at this completely wrong. Also new to coding, so I'm not sure how to efficiently do this. The transfer functions are inputted in the for loop.










share|improve this question
































    0















    I am currently optimizing a PID controller based on the gain (Kc), integral time constant (tauI), derivative time constant (tauD) and the filter derivative time constant (tauC). The problem requested is to optimize the controller in a way that the error is close to zero (average_error = 0).



    The smallest error I can get is around 15 (base values) while I know I should be able to get below 1. The parameters used for this are when Kc = 1, tauI = 1, tauD = 1 and tauC = 1. This is found by using iterations, widgets, and trial and error. I'm really at a loss as to how I should code this in order to obtain the smallest possible parameters. It seems as if any change in the parameters cause a significant change in the error at this minimum value. Any help is greatly appreciated.



    import sys
    import control
    import numpy as np
    import matplotlib.pyplot as plt
    import pandas as pd

    # Pull data from CSV

    file = 'profiledata.csv'
    data = pd.read_csv(file,sep=',')
    T_i = data.values

    # Universal Variables

    time_array = np.linspace(0,59,60)
    perf = np.linspace(1,1,100)
    average_perf = np.linspace(1,1,100)
    Kc = 1
    tI = 1
    tD = 1
    tC = 1

    # Functions

    for i in range(len(perf)):

    s = control.tf([1,0],[0,1])
    Gp = 1/(s**2 + s + 1)
    Gd = (s+1)/(s**2+s+1)
    Gc = Kc*(1+1/(tI*s) + tD*s/(tC*s + 1))
    sys_D = Gd/(1+Gp*Gc)
    _,T,_ = control.forced_response(sys_D, time_array, T_i[:,i])

    # Compute output based on disturbance closed loop TF sys_D

    _,Q,_ = control.forced_response(-Gc, time_array, T) # Compute input

    perf[i] = sum(abs(T) + (0.2)*abs(Q))

    # Calculate the average error from the parameters

    average_perf = sum(perf)/100

    print(average_perf)


    The expected result is when average_perf = 0. The data file read are disturbance profiles with 100 columns and 60 rows. Is there anyway to test the optimal parameters, hold that parameter and then test the other parameters with that parameter fully optimized for the smallest error? Or am I just looking at this completely wrong. Also new to coding, so I'm not sure how to efficiently do this. The transfer functions are inputted in the for loop.










    share|improve this question




























      0












      0








      0








      I am currently optimizing a PID controller based on the gain (Kc), integral time constant (tauI), derivative time constant (tauD) and the filter derivative time constant (tauC). The problem requested is to optimize the controller in a way that the error is close to zero (average_error = 0).



      The smallest error I can get is around 15 (base values) while I know I should be able to get below 1. The parameters used for this are when Kc = 1, tauI = 1, tauD = 1 and tauC = 1. This is found by using iterations, widgets, and trial and error. I'm really at a loss as to how I should code this in order to obtain the smallest possible parameters. It seems as if any change in the parameters cause a significant change in the error at this minimum value. Any help is greatly appreciated.



      import sys
      import control
      import numpy as np
      import matplotlib.pyplot as plt
      import pandas as pd

      # Pull data from CSV

      file = 'profiledata.csv'
      data = pd.read_csv(file,sep=',')
      T_i = data.values

      # Universal Variables

      time_array = np.linspace(0,59,60)
      perf = np.linspace(1,1,100)
      average_perf = np.linspace(1,1,100)
      Kc = 1
      tI = 1
      tD = 1
      tC = 1

      # Functions

      for i in range(len(perf)):

      s = control.tf([1,0],[0,1])
      Gp = 1/(s**2 + s + 1)
      Gd = (s+1)/(s**2+s+1)
      Gc = Kc*(1+1/(tI*s) + tD*s/(tC*s + 1))
      sys_D = Gd/(1+Gp*Gc)
      _,T,_ = control.forced_response(sys_D, time_array, T_i[:,i])

      # Compute output based on disturbance closed loop TF sys_D

      _,Q,_ = control.forced_response(-Gc, time_array, T) # Compute input

      perf[i] = sum(abs(T) + (0.2)*abs(Q))

      # Calculate the average error from the parameters

      average_perf = sum(perf)/100

      print(average_perf)


      The expected result is when average_perf = 0. The data file read are disturbance profiles with 100 columns and 60 rows. Is there anyway to test the optimal parameters, hold that parameter and then test the other parameters with that parameter fully optimized for the smallest error? Or am I just looking at this completely wrong. Also new to coding, so I'm not sure how to efficiently do this. The transfer functions are inputted in the for loop.










      share|improve this question
















      I am currently optimizing a PID controller based on the gain (Kc), integral time constant (tauI), derivative time constant (tauD) and the filter derivative time constant (tauC). The problem requested is to optimize the controller in a way that the error is close to zero (average_error = 0).



      The smallest error I can get is around 15 (base values) while I know I should be able to get below 1. The parameters used for this are when Kc = 1, tauI = 1, tauD = 1 and tauC = 1. This is found by using iterations, widgets, and trial and error. I'm really at a loss as to how I should code this in order to obtain the smallest possible parameters. It seems as if any change in the parameters cause a significant change in the error at this minimum value. Any help is greatly appreciated.



      import sys
      import control
      import numpy as np
      import matplotlib.pyplot as plt
      import pandas as pd

      # Pull data from CSV

      file = 'profiledata.csv'
      data = pd.read_csv(file,sep=',')
      T_i = data.values

      # Universal Variables

      time_array = np.linspace(0,59,60)
      perf = np.linspace(1,1,100)
      average_perf = np.linspace(1,1,100)
      Kc = 1
      tI = 1
      tD = 1
      tC = 1

      # Functions

      for i in range(len(perf)):

      s = control.tf([1,0],[0,1])
      Gp = 1/(s**2 + s + 1)
      Gd = (s+1)/(s**2+s+1)
      Gc = Kc*(1+1/(tI*s) + tD*s/(tC*s + 1))
      sys_D = Gd/(1+Gp*Gc)
      _,T,_ = control.forced_response(sys_D, time_array, T_i[:,i])

      # Compute output based on disturbance closed loop TF sys_D

      _,Q,_ = control.forced_response(-Gc, time_array, T) # Compute input

      perf[i] = sum(abs(T) + (0.2)*abs(Q))

      # Calculate the average error from the parameters

      average_perf = sum(perf)/100

      print(average_perf)


      The expected result is when average_perf = 0. The data file read are disturbance profiles with 100 columns and 60 rows. Is there anyway to test the optimal parameters, hold that parameter and then test the other parameters with that parameter fully optimized for the smallest error? Or am I just looking at this completely wrong. Also new to coding, so I'm not sure how to efficiently do this. The transfer functions are inputted in the for loop.







      python performance controller jupyter pid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 2:27









      ottomeister

      3,4572 gold badges15 silver badges21 bronze badges




      3,4572 gold badges15 silver badges21 bronze badges










      asked Mar 28 at 1:42









      NickNick

      11 bronze badge




      11 bronze badge

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388967%2fpid-controller-tuning%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388967%2fpid-controller-tuning%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript