Skip to content

Commit ded9bfc

Browse files
authored
Document IZone (#2266)
1 parent a175db4 commit ded9bfc

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

source/docs/software/advanced-controls/controllers/pidcontroller.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,34 @@ The range limits may be increased or decreased using the ``setIntegratorRange()`
126126
// the total loop output
127127
pid.SetIntegratorRange(-0.5, 0.5);
128128

129+
Disabling Integral Gain if the Error is Too High
130+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131+
132+
Another way integral "wind-up" can be alleviated is by limiting the error range where integral gain is active. This can be achieved by setting ``IZone``. If the error is more than ``IZone``, the total accumulated error is reset, disabling integral gain. When the error is equal to or less than IZone, integral gain is enabled.
133+
134+
By default, ``IZone`` is disabled.
135+
136+
``IZone`` may be set using the ``setIZone()`` method. To disable it, set it to infinity.
137+
138+
.. tabs::
139+
140+
.. code-tab:: java
141+
142+
// Disable IZone
143+
pid.setIZone(Double.POSITIVE_INFINITY);
144+
145+
// Integral gain will not be applied if the absolute value of the error is
146+
// more than 2
147+
pid.setIZone(2);
148+
149+
.. code-tab:: c++
150+
// Disable IZone
151+
pid.SetIZone(std::numeric_limits<double>::infinity());
152+
153+
// Integral gain will not be applied if the absolute value of the error is
154+
// more than 2
155+
pid.SetIZone(2);
156+
129157
Setting Continuous Input
130158
^^^^^^^^^^^^^^^^^^^^^^^^
131159

source/docs/software/advanced-controls/introduction/common-control-issues.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Beware that if :math:`K_i` is too large, integral windup can occur. Following a
1111
There are a few ways to mitigate this:
1212

1313
1. Decrease the value of :math:`K_i`, down to zero if possible.
14-
2. Add logic to reset the integrator term to zero if the :term:`output` is too far from the :term:`setpoint`. Some smart motor controllers implement this with a ``setIZone()`` method.
14+
2. Add logic to reset the integrator term to zero if the :term:`output` is too far from the :term:`setpoint`. Some smart motor controllers and WPILib's ``PIDController`` implement this with a ``setIZone()`` method.
1515
3. Cap the integrator at some maximum value. WPILib's ``PIDController`` implements this with the ``setIntegratorRange()`` method.
1616

1717
.. important:: Most mechanisms in FRC do not require any integral control, and systems that seem to require integral control to respond well probably have an inaccurate feedforward model.

0 commit comments

Comments
 (0)