{"id":3811,"date":"2014-06-18T14:42:29","date_gmt":"2014-06-18T19:42:29","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=3811"},"modified":"2014-06-18T14:42:29","modified_gmt":"2014-06-18T19:42:29","slug":"plant-identification-using-the-pid-tuner-part-deux","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2014\/06\/18\/plant-identification-using-the-pid-tuner-part-deux\/","title":{"rendered":"Plant Identification Using the PID Tuner (Part Deux)"},"content":{"rendered":"<!--introduction-->\r\n<p>In a <a href=\"https:\/\/blogs.mathworks.com\/seth\/2014\/05\/30\/plant-identification-using-the-pid-tuner\/\">previous post<\/a>, we highlighted how the system identification capability of the <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/gs\/automated-tuning-of-simulink-pid-controller-block.html\">PID Tuner app<\/a> can help identifying an experimental plant. Today we see another very useful application: Identifying a linear plant from a model that does not linearize.<\/p>\r\n<!--\/introduction-->\r\n\r\n<p><strong>Not all models linearize easily<\/strong><\/p>\r\n\r\n<p>Most users who tried linearizing complex Simulink models know that it is often not an easy task. For a Simulink model to be realistic, it must have discontinuities like saturations, quantizations, ON\/OFF controllers, etc. All those elements are known to linearize to zero, and consequently make it impossible to apply classical control design techniques.<\/p>\r\n\r\n<p>When linearization fails, system identification can help.<\/p>\r\n\r\n<p><strong>The Challenge<\/strong><\/p>\r\n\r\n<p>To highlight this functionality, I picked a demo model which I thought would be challenging for the PID Tuner: <a title=\"https:\/\/www.mathworks.com\/help\/stateflow\/examples\/modeling-a-pwm-driven-hydraulic-servomechanism.html (link no longer works)\">sf_electrophydraulics: a PWM Driven Hydraulic Servomechanism<\/a>. <\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/sf_electrohydraulic_HydroSchema.png\" alt=\"PWM Driven Hydraulic Servomechanism\" \/><\/p>\r\n\r\n<p>This model already contains a PI controller doing a decent job, so I was curious to see if the PID Tuner would be able to do better.<\/p>\r\n\r\n<p>As expected, I opened the dialog of the PID block, clicked the \"Tune\" button, and the PID Tuner app opened with a badge saying: <em>Plant cannot be linearized<\/em>.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/CannotLinearize.png\" alt=\"The model cannot linearize!\" \/><\/p>\r\n\r\n<p><strong>Identifying a plant from a simulation<\/strong><\/p>\r\n\r\n<p>In the PID tuner, I clicked on the link to identify a plant<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/identifyPlant.png\" alt=\"Identify Plant\" \/><\/p>\r\n\r\n<p>and I choose to obtain my data by simulating the model<\/P>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/simulatedata.png\" alt=\"Simulate Data\" \/><\/p>\r\n\r\n<p>Under the hood, the app will open the loop and replace the PID block by a source signal to excite the system. Since I know that the output of the controller is a duty cycle percentage, I specified that this input should be a step from 0% to 90%.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/designStep.png\" alt=\"Design a Step Input\" \/><\/p>\r\n\r\n<p> I clicked the Simulate button, and obtained the following data. As I would expect based on my knowledge of the system, a 90% duty cycle results in a motion of ~18mm.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/simulationdata.png\" alt=\"Design a Step Input\" \/><\/p>\r\n\r\n<p>I clicked the Apply and Close buttons to go back to the Plant Identification tab. Here I can try different structures for the plant model, and use the adjustors to manually tweak the plant model:\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/adjustor.gif\" alt=\"Identifying the plant Plant\" \/><\/p>\r\n\r\n<p><strong>Designing the Controller<\/strong><\/p>\r\n\r\n<p>I saved the plant and went back to the PID Tuner tab. I cranked up the Response Time and Transient Behavior sliders to get something aggressive, and I clicked the Update Block button to apply the gain values to the block.<\/p>\r\n\r\n<p><a href=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/tunedSysLarge.png\"><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/tunedSysSmall.png\" alt=\"Tuned Controller\" \/><\/a><\/p>\r\n\r\n<p>When I simulate the model with this tuned controller, I can only realize that the controller designed using the PID Tuner app is tracking the set point as good as the original controller.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/tunedResponse.png\" alt=\"Simulation Response\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>I have to admit, I am really impressed by how easy it was to obtain a plant model and a controller for this model. Given all the complex discontinuities in this model, I was certain it would require more work to design a controller for it.<\/p>\r\n\r\n<p>Give this new functionality a try, and let us know what you think by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=3811&#comment\">comment here<\/a>.<\/p>\r\n\r\n\r\n\r\n\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/tunedResponse.png\" onError=\"this.style.display ='none';\" \/><\/div><!--introduction-->\r\n<p>In a <a href=\"https:\/\/blogs.mathworks.com\/seth\/2014\/05\/30\/plant-identification-using-the-pid-tuner\/\">previous post<\/a>, we highlighted how the system identification capability of the <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/gs\/automated-tuning-of-simulink-pid-controller-block.html\">PID Tuner app<\/a> can help identifying an experimental plant. Today we see another very useful application: Identifying a linear plant from a model that does not linearize.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2014\/06\/18\/plant-identification-using-the-pid-tuner-part-deux\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[115,30,16],"tags":[389,388],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3811"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=3811"}],"version-history":[{"count":34,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3811\/revisions"}],"predecessor-version":[{"id":3859,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3811\/revisions\/3859"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=3811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=3811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=3811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}