{"id":2712,"date":"2025-07-19T07:42:53","date_gmt":"2025-07-19T07:42:53","guid":{"rendered":"https:\/\/learnbydoing.dev\/?p=2712"},"modified":"2026-01-10T22:19:00","modified_gmt":"2026-01-10T22:19:00","slug":"pid-control-algorithm","status":"publish","type":"post","link":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/","title":{"rendered":"PID Control Algorithm"},"content":{"rendered":"<div data-elementor-type=\"wp-post\" data-elementor-id=\"2712\" class=\"elementor elementor-2712\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-e28ab35 e-flex e-con-boxed e-con e-parent\" data-id=\"e28ab35\" data-element_type=\"container\" data-e-type=\"container\" id=\"content\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-62ab6e3 e-con-full e-flex e-con e-child\" data-id=\"62ab6e3\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-62ab203 elementor-align-center elementor-widget elementor-widget-post-info\" data-id=\"62ab203\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"post-info.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<ul class=\"elementor-inline-items elementor-icon-list-items elementor-post-info\">\n\t\t\t\t\t\t\t\t<li class=\"elementor-icon-list-item elementor-repeater-item-2c98363 elementor-inline-item\" itemprop=\"about\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-icon-list-text elementor-post-info__item elementor-post-info__item--type-terms\">\n\t\t\t\t\t\t\t\t\t\t<span class=\"elementor-post-info__terms-list\">\n\t\t\t\t<span class=\"elementor-post-info__terms-list-item\">Arduino<\/span>, <span class=\"elementor-post-info__terms-list-item\">Control<\/span>, <span class=\"elementor-post-info__terms-list-item\">ROS 2<\/span>, <span class=\"elementor-post-info__terms-list-item\">Tutoriales<\/span>\t\t\t\t<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t\t\t\t<\/li>\n\t\t\t\t<\/ul>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-0650e10 e-con-full e-flex e-con e-child\" data-id=\"0650e10\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-ac19582 elementor-view-default elementor-widget elementor-widget-icon\" data-id=\"ac19582\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"icon.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-wrapper\">\n\t\t\t<div class=\"elementor-icon\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"75\" height=\"75\" viewbox=\"0 0 75 75\" fill=\"none\"><path d=\"M74.9999 75H13.1889V73.0002H71.5859L0.460938 1.87521L1.87515 0.460999L73.0001 71.586V13.1889H74.9999V75Z\" fill=\"white\"><\/path><\/svg>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-47aa245d e-flex e-con-boxed e-con e-parent\" data-id=\"47aa245d\" data-element_type=\"container\" data-e-type=\"container\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-a3b40ae elementor-widget elementor-widget-image\" data-id=\"a3b40ae\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1920\" height=\"1080\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp\" class=\"attachment-full size-full wp-image-2714\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp 1920w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-18x10.webp 18w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4bc31ca3 elementor-widget elementor-widget-text-editor\" data-id=\"4bc31ca3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>In control theory, the <strong>PID (Proportional\u2013Integral\u2013Derivative)<\/strong> algorithm is often considered the <em>holy grail<\/em> of control.\u00a0PID is one of the most successful control algorithms due to its flexibility and simplicity, and it\u2019s relatively easy to implement. In fact, the PID control algorithm has proven robust and flexible enough to yield excellent results in a wide variety of applications, which is a main reason for its continued widespread use over the decades.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-63715e8 elementor-widget elementor-widget-text-editor\" data-id=\"63715e8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><b>\ud83c\udf2a\ufe0f\u00a0PID Control in the Wild<\/b><\/h3>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c8775b8 elementor-widget elementor-widget-image\" data-id=\"c8775b8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"768\" height=\"432\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/5-Motion-Planning-Videos-3.gif\" class=\"attachment-full size-full wp-image-2725\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-daae8f2 elementor-widget elementor-widget-text-editor\" data-id=\"daae8f2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"1132\" data-end=\"1371\">The PID algorithm\u2019s flexibility and effectiveness have led to its adoption in countless systems across different domains. Some examples include:<br \/><br \/><\/p><ol><li><strong data-start=\"1375\" data-end=\"1388\">Robotics:<\/strong> robotic manipulators, self-balancing robots, ball-and-plate balancing robots, and line-following robots all use PID control for stability and accuracy.<\/li><li><strong data-start=\"1560\" data-end=\"1583\">Industrial control:<\/strong> thermostats use PID for precise temperature control, and PID regulates flow and pressure in hydraulic pumps and process control systems.<\/li><li><strong data-start=\"1762\" data-end=\"1777\">Automotive:<\/strong> Many driver assistance systems, like automotive cruise control, rely on PID loops to maintain speed.<\/li><li><strong data-start=\"1881\" data-end=\"1895\">Aerospace:<\/strong> even advanced systems such as rocket launchers and guided missile trackers use PID controllers for trajectory and attitude control.<br \/><br \/><\/li><\/ol><p data-start=\"2066\" data-end=\"2369\">These are just a few examples \u2014 PID controllers are employed anywhere we need to automatically maintain a variable at a set value with minimal error. From simple home appliances to critical aerospace systems, PID control provides a reliable way to regulate behavior.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-87c55c3 elementor-widget elementor-widget-text-editor\" data-id=\"87c55c3\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><b>\ud83e\uddf0\u00a0Use PID Algorithm to Control the Speed of a Motor<\/b><\/h3><p data-start=\"2411\" data-end=\"2569\">To better understand how the PID algorithm works, let\u2019s consider a simple real-world use case: controlling a robot\u2019s wheel motor to achieve a specific speed.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-743d00c elementor-widget elementor-widget-text-editor\" data-id=\"743d00c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"2571\" data-end=\"3006\">Suppose we want the motor to rotate at a desired speed of 1 radian per second. This target speed is the <strong data-start=\"2675\" data-end=\"2692\">desired value<\/strong> (also called the <strong data-start=\"2710\" data-end=\"2722\">setpoint<\/strong>, denoted as \\(r(t)\\). We can measure the motor\u2019s <strong data-start=\"2771\" data-end=\"2788\">current speed<\/strong> using an encoder, giving us \\(y(t)\\) as the feedback output of the system. We then compare the current speed to the setpoint to compute the <strong data-start=\"2927\" data-end=\"2936\">error\u00a0<\/strong>\\(e(t)\\), defined as the difference between the desired and current speed: $$e(t) = r(t) &#8211; y(t)$$<\/p><p>The controller\u2019s job is to use this error to generate a <strong data-start=\"3092\" data-end=\"3103\">command\u00a0<\/strong>\\(u(t)\\) (for an electric motor, this command could be a voltage or power level) to drive the error toward zero. In other words, the PID controller will take \\(e(t)\\) as input and output a control signal \\(u(t)\\) that minimizes this error, making the motor reach the desired speed as quickly as possible.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5f0b1e5 elementor-widget elementor-widget-image\" data-id=\"5f0b1e5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"1920\" height=\"1080\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1.webp\" class=\"attachment-full size-full wp-image-2739\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1.webp 1920w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-1-18x10.webp 18w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-637e795 elementor-widget elementor-widget-text-editor\" data-id=\"637e795\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"3404\" data-end=\"3456\">Let\u2019s walk through an example scenario step by step:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-64e6e7f elementor-widget elementor-widget-text-editor\" data-id=\"64e6e7f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ol><li><strong data-start=\"3461\" data-end=\"3479\">Initial state:<\/strong> The desired speed is \\(r(t)=1 rad\/s\\), and the motor is initially at rest, so \\(y(t)=0 rad\/s\\). Thus, the error is: $$e(t) = 1 rad\/s &#8211; 0 rad\/s = 1 rad\/s$$<p>Because the error is large, the PID controller responds with a large command. For instance, if the motor\u2019s command range is 0 to 255 (where 255 is full power), the controller might output <strong data-start=\"3813\" data-end=\"3820\">255<\/strong> to give maximum thrust. This strong action causes the motor to accelerate quickly.<\/p><\/li><li data-start=\"3908\" data-end=\"4423\"><strong data-start=\"3908\" data-end=\"3928\">Motor speeds up:<\/strong> The motor begins to spin, and soon the encoder reads a current speed of about \\(y(t)=0.5 rad\/s\\). Now the error has reduced to $$e(t) = 1 rad\/s &#8211; 0.5 rad\/s = 0.5 rad\/s$$ Since the error is smaller, the controller reduces the command. It might now send a command of around <strong data-start=\"4196\" data-end=\"4203\">150<\/strong> (out of 255). The motor is still accelerating, but more gently than before, because as the speed approaches the target, we no longer need maximum power \u2013 in fact, too much power would risk overshooting the target speed.<br \/><br \/><\/li><li><strong data-start=\"4428\" data-end=\"4457\">Closing in on the target:<\/strong> The motor\u2019s speed continues to increase and reaches \\(y(t)=0.8 rad\/s\\). The error is now \\(e(t)=0.2 rad\/s\\). With the error getting quite small, the controller further decreases the command (say to about <strong data-start=\"4668\" data-end=\"4674\">50<\/strong>). The motor keeps accelerating, but now quite slowly. At this point, we\u2019re trying to sneak up on the target speed without overshooting it.<br \/><br \/><\/li><li><strong data-start=\"4817\" data-end=\"4843\">Reaching steady state:<\/strong> After a few more control loop iterations, the motor finally reaches \\(y(t)=1 rad\/s\\), matching the desired speed. The error is now essentially \\(e(t)=0 rad\/s\\). The controller output doesn\u2019t drop to zero, however. Instead, it settles to some moderate value (perhaps around <strong data-start=\"5113\" data-end=\"5119\">30<\/strong> in this example) to sustain the motor\u2019s rotation. This makes sense: even when the error is zero, the motor likely needs a bit of power to overcome friction and air resistance to maintain a constant speed.<\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d72a4aa elementor-widget elementor-widget-image\" data-id=\"d72a4aa\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"1152\" height=\"648\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.gif\" class=\"attachment-full size-full wp-image-2864\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b53084a elementor-widget elementor-widget-text-editor\" data-id=\"b53084a\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Throughout this process, the PID controller runs its loop repeatedly (many times per second), each time recalculating the error and adjusting the command. Notice that once the setpoint is reached, the controller doesn\u2019t turn off \u2014 it continues working to hold the motor at \\(1 rad\/s\\).<br \/><br \/>If any disturbance occurs (for example, if the robot starts going uphill or we add a load on the wheel), the error will no longer be zero. The PID loop will then respond by increasing the motor command (drawing more current) to compensate and keep the speed constant.<br \/><br \/>This <strong data-start=\"5882\" data-end=\"5897\">closed-loop<\/strong> behavior is what makes PID so powerful: the controller automatically corrects for changes and uncertainties to minimize the error at all times.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1b26dfe elementor-widget elementor-widget-image\" data-id=\"1b26dfe\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-1024x576.webp\" class=\"attachment-large size-large wp-image-2868\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-1320x743.webp 1320w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2-600x338.webp 600w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-2.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c50fabf elementor-widget elementor-widget-text-editor\" data-id=\"c50fabf\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p data-start=\"6043\" data-end=\"7021\">If we visualize the behavior of this PID-controlled motor, we would see the <strong data-start=\"6253\" data-end=\"6270\">desired speed<\/strong> (setpoint) as a horizontal line at \\(1 rad\/s\\) and the <strong data-start=\"6322\" data-end=\"6339\">motor\u2019s speed<\/strong> \\(y(t)\\) gradually rising to meet it. In a well-tuned system, the speed curve will approach the target smoothly without exceeding it (no overshoot). The <strong data-start=\"6491\" data-end=\"6508\">control input<\/strong> \\(u(t)\\) starts at a maximum value to kick-start the motion, then steps down as the error decreases, leveling off once the target speed is achieved. <br \/><br \/>Meanwhile, the <strong data-start=\"6671\" data-end=\"6680\">error<\/strong> \\(e(t)\\) begins at \\(1 rad\/s\\) (when the motor is stopped) and steadily declines to 0 as the motor reaches \\(1 rad\/s\\). This example illustrates the essence of PID control: at each moment, the controller computes a command that strives to reduce the error. Over time, the output converges to the setpoint due to the controller\u2019s corrective actions.<\/p><p data-start=\"7023\" data-end=\"7346\">In summary, the PID controller generates a control command that continuously pushes the system toward the desired value. By responding strongly when the error is large and backing off as the error shrinks, the PID algorithm drives the error to zero in a reasonable time and then maintains the target with minimal deviation.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-189ce54 elementor-widget elementor-widget-text-editor\" data-id=\"189ce54\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><b>\ud83d\udcd6 How the PID Controller Works (P, I, D Components)<\/b><\/h3><p>So far, we treated the PID controller as a black box that takes an error and outputs a command. Now let\u2019s open that box and see what\u2019s inside. The name <strong data-start=\"7553\" data-end=\"7560\">PID<\/strong> comes from the three mathematical components at the core of its operation: <strong data-start=\"7636\" data-end=\"7678\">Proportional, Integral, and Derivative<\/strong>. Each component handles a different aspect of error correction:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-26eefb6 elementor-widget elementor-widget-image\" data-id=\"26eefb6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-1024x576.webp\" class=\"attachment-large size-large wp-image-2870\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-1320x743.webp 1320w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3-600x338.webp 600w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-3.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d610325 elementor-widget elementor-widget-text-editor\" data-id=\"d610325\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4 data-start=\"7744\" data-end=\"7787\">Proportional Term (P) \u2013 Present Error<\/h4><p data-start=\"7788\" data-end=\"8629\">The proportional component generates an output that is <strong data-start=\"7843\" data-end=\"7880\">proportional to the current error<\/strong>. It essentially looks at <strong data-start=\"7906\" data-end=\"7951\">how far off the setpoint we are right now<\/strong>. The proportional term output is computed as $$P_\\text{out} = K_p \\cdot e(t)$$ where \\(K_p\\) is the proportional gain (a constant) and \\(e(t)\\) is the instantaneous error. If the error is large, \\(P_\\text{out}\\) will be large; if the error is small, \\(P_\\text{out}\\) will be small. This term\u2019s job is to <strong data-start=\"8253\" data-end=\"8294\">immediately correct the current error<\/strong> by commanding the actuator in the direction that reduces \\(e(t)\\). Intuitively, the P term is a straight-line response: for example, if you\u2019re driving and you\u2019re 5 mph below the desired speed, a proportional controller might press the accelerator a certain amount; if you\u2019re 10 mph slow (double the error), it will press twice as much.<\/p><p data-start=\"8631\" data-end=\"9273\">However, proportional control on its own has a limitation: it typically cannot drive the error all the way to zero, especially in the presence of external forces or friction. The system tends to stabilize when the proportional output balances out those opposing forces, which often leaves a <strong data-start=\"8922\" data-end=\"8944\">steady-state error<\/strong> (offset). In our motor example, using only a P term might make the motor stabilize slightly below \\(1\u00a0rad\/s\\), because some error is needed to produce enough output to counteract friction. Increasing \\(K_p\\) reduces this residual error, but one cannot increase \\(K_p\\) arbitrarily high without consequences (as we\u2019ll discuss in tuning).<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9e872e2 elementor-widget elementor-widget-image\" data-id=\"9e872e2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-1024x576.webp\" class=\"attachment-large size-large wp-image-2882\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-1320x743.webp 1320w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4-600x338.webp 600w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-4.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5dbeff8 elementor-widget elementor-widget-text-editor\" data-id=\"5dbeff8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h4 data-start=\"9275\" data-end=\"9311\">Integral Term (I) \u2013 Past Error<\/h4><p data-start=\"9312\" data-end=\"9789\">The integral component produces an output proportional to the <strong data-start=\"9374\" data-end=\"9405\">accumulated error over time<\/strong>. It looks at <strong data-start=\"9419\" data-end=\"9470\">how long and how far we\u2019ve been off in the past<\/strong>. Mathematically, it integrates the error: $$I_\\text{out} = K_i \\int e(t),dt$&amp; (the integral of error from the start up to the current time), and \\(K_i\\) is the integral gain. In practice, the integral term continuously sums up errors: even a small persistent error will accumulate over time into a large integral value.<\/p><p data-start=\"9791\" data-end=\"10656\">The role of the I term is to <strong data-start=\"9820\" data-end=\"9862\">eliminate long-standing, steady errors<\/strong>. It slowly increases the controller output as long as there is any error, and it won\u2019t rest until the error has been driven to zero. Going back to the driving analogy, if your car remains 2\u00a0mph below the set speed for a while, the integral term will keep increasing the throttle over that duration, effectively saying \u201cwe\u2019ve been off by 2\u00a0mph for too long, let\u2019s push a bit more until that error is gone.\u201d Thanks to the integral action, a well-tuned PID controller can <strong data-start=\"10332\" data-end=\"10366\">remove the steady-state offset<\/strong> that a pure P controller leaves. Once the error is zero (on target), the integral term will stop growing. In fact, if the error becomes positive (meaning you\u2019ve gone <strong data-start=\"10533\" data-end=\"10542\">above<\/strong> the setpoint), the integral term can start to cancel out (it will decrease, because the error has flipped sign).<\/p><p data-start=\"10658\" data-end=\"11043\">One must be careful with the integral term: since it reacts to accumulated past errors, it can make the system <strong data-start=\"10769\" data-end=\"10790\">slower to respond<\/strong> to changes (it\u2019s a delayed effect), and too much integral action can lead to overshoot. If the integral term has built up a large correction while chasing an error, that momentum can cause the system to overshoot the target and then have to swing back.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2a6fa0e elementor-widget elementor-widget-image\" data-id=\"2a6fa0e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-1024x576.webp\" class=\"attachment-large size-large wp-image-2886\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-1320x743.webp 1320w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5-600x338.webp 600w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-5.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-29c46d1 elementor-widget elementor-widget-text-editor\" data-id=\"29c46d1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3 data-start=\"11045\" data-end=\"11085\">Derivative Term (D) \u2013 Future Error<\/h3><p data-start=\"11086\" data-end=\"11725\">The derivative component\u2019s output is proportional to the <strong data-start=\"11143\" data-end=\"11174\">rate of change of the error<\/strong>. In essence, it looks at <strong data-start=\"11200\" data-end=\"11288\">how the error is changing (how it might behave in the future if the trend continues)<\/strong>. It is calculated as $$D_\\text{out} = K_d \\frac{d e(t)}{d t}$$, with \\(K_d\\) the derivative gain. The derivative term acts like a predictor: it responds to the <strong data-start=\"11447\" data-end=\"11472\">speed of error change<\/strong>. If the error is decreasing rapidly, the D term will produce a significant output in the opposite direction, effectively applying the brakes to the controller\u2019s action. If the error isn\u2019t changing much or is changing slowly, the D output will be small.<\/p><p data-start=\"11727\" data-end=\"12519\">The main purpose of the D term is to <strong data-start=\"11764\" data-end=\"11806\">dampen the system and reduce overshoot<\/strong>. It anticipates where the error is heading and counteracts fast changes. Imagine driving and approaching the desired speed: if you\u2019re closing in quickly, the derivative term will ease off the accelerator preemptively to avoid overshooting the speed. In a PID-controlled motor, as the speed approaches the setpoint, the D term counters the P term\u2019s push, helping prevent the speed from overshooting and oscillating around the target. A properly tuned derivative term improves stability and settling time. However, the D term is sensitive to noise in measurements (a noisy speed signal can cause large, erratic D outputs), which is why in practice \\(K_d\\) is often kept relatively small or even zero in many systems.<\/p><p data-start=\"12521\" data-end=\"12998\"><strong data-start=\"12521\" data-end=\"12540\">In other words,<\/strong> the P component addresses the present error, the I component addresses the accumulation of <strong data-start=\"12632\" data-end=\"12640\">past<\/strong> errors, and the D component attempts to predict <strong data-start=\"12689\" data-end=\"12699\">future<\/strong> errors based on their current rate of change. By combining these three contributions, a PID controller reacts to what is happening now, what has happened before, and what is likely to happen next. This blend allows it to correct errors efficiently and robustly.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2c45ce0 elementor-widget elementor-widget-image\" data-id=\"2c45ce0\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-1024x576.webp\" class=\"attachment-large size-large wp-image-2893\" alt=\"\" srcset=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-1024x576.webp 1024w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-300x169.webp 300w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-768x432.webp 768w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-1536x864.webp 1536w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-18x10.webp 18w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-1320x743.webp 1320w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6-600x338.webp 600w, https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning-6.webp 1920w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a9168f4 elementor-widget elementor-widget-text-editor\" data-id=\"a9168f4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h3><b>\u2797\u00a0The PID Control Equation<\/b><\/h3><p data-start=\"13029\" data-end=\"13235\">Mathematically, a PID controller in a feedback loop can be expressed with a simple equation. At any time \\(t\\), given the system\u2019s desired input \\(r(t)\\) and its measured output \\(y(t)\\), we define the error as: $$e(t) = r(t) &#8211; y(t)$$<\/p><p>\u00a0<\/p><p data-start=\"13265\" data-end=\"13410\">The controller computes a control signal (command) \\(u(t)\\) as the sum of a <strong data-start=\"13339\" data-end=\"13360\">Proportional term<\/strong>, an <strong data-start=\"13365\" data-end=\"13382\">Integral term<\/strong>, and a <strong data-start=\"13390\" data-end=\"13409\">Derivative term<\/strong>:<\/p><p data-start=\"13265\" data-end=\"13410\">$$u(t) = K_p \\cdot e(t) + K_i \\int_0^t e(\\tau) \\, d\\tau + K_d \\cdot \\frac{d e(t)}{d t}$$<\/p><p data-start=\"13510\" data-end=\"14136\">In this formula, \\(K_p\\), \\(K_i\\), and \\(K_d\\) are constants known as the <strong data-start=\"13578\" data-end=\"13591\">PID gains<\/strong> (proportional gain, integral gain, and derivative gain, respectively). These gains determine the weight or influence of each of the P, I, D components on the controller\u2019s output.<br \/><br \/>The controller output \\(u(t)\\) is then applied to the system (for example, as a voltage to the motor) to drive the output \\(y(t)\\) toward the setpoint \\(r(t)\\). This equation is the one we will implement in code for our robot\u2019s controller: at each time step, our program will calculate the error and then use this formula to compute the new command to send to the motors.<br \/><br \/><\/p><p data-start=\"14138\" data-end=\"14622\">Notice that the PID formula depends only on the error \\(e(t)\\) (and its history and rate of change) and on the chosen gains \\(K_p\\), \\(K_i\\), \\(K_d\\). It does <strong data-start=\"14289\" data-end=\"14296\">not<\/strong> explicitly depend on the time \\(t\\) itself or any knowledge of the internal dynamics of the system \u2013 PID is a generic closed-loop controller. The art of using PID effectively lies in choosing appropriate values for these three gains so that the closed-loop system behaves as desired. This choice is what we call <strong data-start=\"14607\" data-end=\"14621\">PID tuning<\/strong>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-50161b5 e-con-full e-flex e-con e-parent\" data-id=\"50161b5\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-5128701 elementor-bg-transform elementor-bg-transform-move-left elementor-cta--layout-image-left elementor-cta--mobile-layout-image-above elementor-cta--skin-classic elementor-animated-content elementor-widget elementor-widget-call-to-action\" data-id=\"5128701\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"call-to-action.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-cta\">\n\t\t\t\t\t<div class=\"elementor-cta__bg-wrapper\">\n\t\t\t\t<div class=\"elementor-cta__bg elementor-bg\" style=\"background-image: url(https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/odometry_control.webp);\" role=\"img\" aria-label=\"odometry_control\"><\/div>\n\t\t\t\t<div class=\"elementor-cta__bg-overlay\"><\/div>\n\t\t\t<\/div>\n\t\t\t\t\t\t\t<div class=\"elementor-cta__content\">\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<h2 class=\"elementor-cta__title elementor-cta__content-item elementor-content-item\">\n\t\t\t\t\t\tWant to learn more?\t\t\t\t\t<\/h2>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-cta__description elementor-cta__content-item elementor-content-item\">\n\t\t\t\t\t\tYou can find a detailed explaination of the PID Algorithm, along with Control theory in the \"Self Driving and ROS 2 - Learn by Doing! Odometry &amp; Control\" course\t\t\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-cta__button-wrapper elementor-cta__content-item elementor-content-item\">\n\t\t\t\t\t<a class=\"elementor-cta__button elementor-button elementor-size-\" href=\"\" target=\"_blank\">\n\t\t\t\t\t\tEnroll Now\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t<div class=\"elementor-ribbon elementor-ribbon-right\">\n\t\t\t\t<div class=\"elementor-ribbon-inner\">\n\t\t\t\t\tDISCOUNT\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2443ce4 elementor-widget elementor-widget-spacer\" data-id=\"2443ce4\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>In control theory, the PID (Proportional\u2013Integral\u2013Derivative) algorithm is often considered the holy grail of control.\u00a0PID is one of the most successful control algorithms due to its flexibility and simplicity, and it\u2019s relatively easy to implement. In fact, the PID control algorithm has proven robust and flexible enough to yield excellent results in a wide variety [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":2714,"comment_status":"closed","ping_status":"open","sticky":false,"template":"elementor_header_footer","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[68,225,45,43],"tags":[109,223,98,100,75,71,72,224],"class_list":["post-2712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-control","category-ros-2","category-tutorials","tag-control","tag-pid","tag-python","tag-robot","tag-robotics","tag-ros","tag-ros2","tag-tuning"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PID Control Algorithm - Learn by Doing!<\/title>\n<meta name=\"description\" content=\"Discover how PID control works: understand proportional, integral, and derivative terms and how they correct errors to stabilize systems.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnbydoing.dev\/es\/pid-control-algorithm\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PID Control Algorithm\" \/>\n<meta property=\"og:description\" content=\"Learn by Doing!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnbydoing.dev\/es\/pid-control-algorithm\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn by Doing!\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-19T07:42:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-10T22:19:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"PID Control Algorithm\",\"datePublished\":\"2025-07-19T07:42:53+00:00\",\"dateModified\":\"2026-01-10T22:19:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/\"},\"wordCount\":2343,\"publisher\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/PID-Control-and-Tuning.webp\",\"keywords\":[\"control\",\"PID\",\"python\",\"robot\",\"Robotics\",\"ROS\",\"ROS2\",\"tuning\"],\"articleSection\":[\"Arduino\",\"Control\",\"ROS 2\",\"Tutorials\"],\"inLanguage\":\"es\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/\",\"name\":\"PID Control Algorithm - Learn by Doing!\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/PID-Control-and-Tuning.webp\",\"datePublished\":\"2025-07-19T07:42:53+00:00\",\"dateModified\":\"2026-01-10T22:19:00+00:00\",\"description\":\"Discover how PID control works: understand proportional, integral, and derivative terms and how they correct errors to stabilize systems.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#primaryimage\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/PID-Control-and-Tuning.webp\",\"contentUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/PID-Control-and-Tuning.webp\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/pid-control-algorithm\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/learn-by-doing-es\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PID Control Algorithm\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#website\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/\",\"name\":\"Learn by Doing!\",\"description\":\"Learn Robotics the fun way\",\"publisher\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#organization\",\"name\":\"Learn by Doing!\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-Progetto-senza-titolo-6-1.png\",\"contentUrl\":\"https:\\\/\\\/learnbydoing.dev\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-Progetto-senza-titolo-6-1.png\",\"width\":512,\"height\":512,\"caption\":\"Learn by Doing!\"},\"image\":{\"@id\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/antonio-brandi-512166bb\\\/\"]},{\"@type\":\"Person\",\"@id\":\"\",\"url\":\"https:\\\/\\\/learnbydoing.dev\\\/es\\\/author\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PID Control Algorithm - Learn by Doing!","description":"Discover how PID control works: understand proportional, integral, and derivative terms and how they correct errors to stabilize systems.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnbydoing.dev\/es\/pid-control-algorithm\/","og_locale":"es_ES","og_type":"article","og_title":"PID Control Algorithm","og_description":"Learn by Doing!","og_url":"https:\/\/learnbydoing.dev\/es\/pid-control-algorithm\/","og_site_name":"Learn by Doing!","article_published_time":"2025-07-19T07:42:53+00:00","article_modified_time":"2026-01-10T22:19:00+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp","type":"image\/webp"}],"twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"","Tiempo de lectura":"13 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#article","isPartOf":{"@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/"},"author":{"name":"","@id":""},"headline":"PID Control Algorithm","datePublished":"2025-07-19T07:42:53+00:00","dateModified":"2026-01-10T22:19:00+00:00","mainEntityOfPage":{"@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/"},"wordCount":2343,"publisher":{"@id":"https:\/\/learnbydoing.dev\/es\/#organization"},"image":{"@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#primaryimage"},"thumbnailUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp","keywords":["control","PID","python","robot","Robotics","ROS","ROS2","tuning"],"articleSection":["Arduino","Control","ROS 2","Tutorials"],"inLanguage":"es"},{"@type":"WebPage","@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/","url":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/","name":"PID Control Algorithm - Learn by Doing!","isPartOf":{"@id":"https:\/\/learnbydoing.dev\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#primaryimage"},"image":{"@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#primaryimage"},"thumbnailUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp","datePublished":"2025-07-19T07:42:53+00:00","dateModified":"2026-01-10T22:19:00+00:00","description":"Discover how PID control works: understand proportional, integral, and derivative terms and how they correct errors to stabilize systems.","breadcrumb":{"@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnbydoing.dev\/pid-control-algorithm\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#primaryimage","url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp","contentUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/07\/PID-Control-and-Tuning.webp","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/learnbydoing.dev\/pid-control-algorithm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learnbydoing.dev\/es\/learn-by-doing-es\/"},{"@type":"ListItem","position":2,"name":"PID Control Algorithm"}]},{"@type":"WebSite","@id":"https:\/\/learnbydoing.dev\/es\/#website","url":"https:\/\/learnbydoing.dev\/es\/","name":"Learn by Doing!","description":"Learn Robotics the fun way","publisher":{"@id":"https:\/\/learnbydoing.dev\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnbydoing.dev\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/learnbydoing.dev\/es\/#organization","name":"Learn by Doing!","url":"https:\/\/learnbydoing.dev\/es\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/","url":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-Progetto-senza-titolo-6-1.png","contentUrl":"https:\/\/learnbydoing.dev\/wp-content\/uploads\/2025\/06\/cropped-Progetto-senza-titolo-6-1.png","width":512,"height":512,"caption":"Learn by Doing!"},"image":{"@id":"https:\/\/learnbydoing.dev\/es\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/antonio-brandi-512166bb\/"]},{"@type":"Person","@id":"","url":"https:\/\/learnbydoing.dev\/es\/author\/"}]}},"_links":{"self":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/2712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/comments?post=2712"}],"version-history":[{"count":125,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/2712\/revisions"}],"predecessor-version":[{"id":5547,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/posts\/2712\/revisions\/5547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/media\/2714"}],"wp:attachment":[{"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/media?parent=2712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/categories?post=2712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learnbydoing.dev\/es\/wp-json\/wp\/v2\/tags?post=2712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}