{"id":526,"date":"2024-05-22T15:57:58","date_gmt":"2024-05-22T15:57:58","guid":{"rendered":"https:\/\/peterklemperer.com\/blog\/?p=526"},"modified":"2024-05-22T15:59:22","modified_gmt":"2024-05-22T15:59:22","slug":"out-of-control-pids","status":"publish","type":"post","link":"https:\/\/peterklemperer.com\/blog\/2024\/05\/22\/out-of-control-pids\/","title":{"rendered":"Out of Control PIDs"},"content":{"rendered":"\n<p>This week&#8217;s post is less of a how-to and more of a &#8220;how-to?&#8221; I&#8217;ve got some ideas about the basics of PID controls, but this system is giving me trouble. I updated the PID control system on Egg-Bot Version 2. V2 currently holds a single position okay, but changes in the target are wild and guaranteed failure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Control Loop Upgrade<\/h2>\n\n\n\n<p>First thing I did this week was add a non-linear adjustment to the PID loop to more accurately map the pendulum angle to the geometry of the robot. In this way a change in the output angle would reflect the center of gravity of the robot, rather than the center of rotation of the pendulum.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"699\" data-attachment-id=\"527\" data-permalink=\"https:\/\/peterklemperer.com\/blog\/2024\/05\/22\/out-of-control-pids\/pid_controller_calculation\/\" data-orig-file=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2024\/05\/pid_controller_calculation.png\" data-orig-size=\"481,699\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pid_controller_calculation\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2024\/05\/pid_controller_calculation-206x300.png\" data-large-file=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2024\/05\/pid_controller_calculation.png\" src=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2024\/05\/pid_controller_calculation.png\" alt=\"\" class=\"wp-image-527\" srcset=\"https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2024\/05\/pid_controller_calculation.png 481w, https:\/\/peterklemperer.com\/blog\/wp-content\/uploads\/2024\/05\/pid_controller_calculation-206x300.png 206w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/figure>\n\n\n\n<p>I think the reason for the failures is that the controller relies on the integral term to reach the target position. In a previous iteration of the controller, whenever I changed the target, I could observe a pretty wild perturbation where the integral term &#8220;unspooled&#8221; and had a big time delay until it could start moving towards the new target.<\/p>\n\n\n\n<p>To combat this &#8220;spooling&#8221;\/&#8221;unspooling&#8221; delay, in today&#8217;s PID version, I reset the integral term whenever a change in target was entered. This had a new effect where the robot would suddenly fall over on target changes due to the rapid change in that term. I want to investigate what&#8217;s done more commonly to address this challenge.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Egg Bot Version 2.0 #robotics #3dprinting #mechatronics\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/9oUOldZD9SQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Egg Bot Version 3 &#8211; Body and Screen<\/h2>\n\n\n\n<p>Finally, I also got version 3 of the robot built. Version 3 includes a front and back cover and an 8&#215;8 LED display. It looks really nice, but can&#8217;t stand on its own. I think it&#8217;s too top heavy for the pendulum to control. Time to do some actual static analysis instead of just guessing.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Egg Robot Version 4 #robotics #3dprinting #mechatronics\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/6JopL-n4v14?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This week&#8217;s post is less of a how-to and more of a &#8220;how-to?&#8221; I&#8217;ve got some ideas about the basics of PID controls, but this system is giving me trouble. I updated the PID control system on Egg-Bot Version 2. &hellip; <a href=\"https:\/\/peterklemperer.com\/blog\/2024\/05\/22\/out-of-control-pids\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[46,6,80],"tags":[110,101,12,92],"class_list":["post-526","post","type-post","status-publish","format-standard","hentry","category-3d-printing","category-projects","category-robotics","tag-mechatronics","tag-pololu","tag-robot","tag-robotics"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1VqWo-8u","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/posts\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/comments?post=526"}],"version-history":[{"count":0,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/posts\/526\/revisions"}],"wp:attachment":[{"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/media?parent=526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/categories?post=526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peterklemperer.com\/blog\/wp-json\/wp\/v2\/tags?post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}