Achieving stable locomotion on an inverted two-wheel pendulum involves navigating a highly complex interplay of mechanical lag, digital filter latency, and aggressive torque delivery. This guide documents exactly how to configure the physics model utilizing serial_tuner and config.h.
Before initiating live tuning procedures, ensure physical limits match your mechanical hardware identically:
TIMER_FREQ_HZ (20,000): Defines the maximum theoretical hardware stepping frequency. Altering this breaks discrete pulse timing matrices severely unless compensated across the structural loop geometry globally.MOTOR_ACCEL_LIMIT (200000.0f): Defines mathematical max capabilities explicitly mapped to motor stator torque constraints. If motors visually "stutter" instead of screaming when accelerating intensely, lower this instantly to prevent electromagnetic saturation and stall conditions.DEFAULT_TARGET_ANGLE (-1.469f): This represents absolute mathematical true horizontal specifically respecting internal chassis battery imbalances securely.
Live parameter injection prevents destructive compile cycles. Connect via Bluetooth Terminal (Self_Balancing_Robot) or native USB Serial, and adhere strictly to this methodology:
- Initialize structure exclusively resetting Integral and Derivative loops:
I=0,D=0,P=100
- Power the hardware (
E) whilst gripping the chassis loosely to prevent explosive torque. - Systematically scale Kp upwards logically until the absolute physical manifestation reflects intense, uniform oscillatory oscillation without structural degradation.
- Scale structurally downward precisely roughly 15%. This determines the permanent Proportional Baseline Matrix.
- Introduce minor variables (e.g.
D=1.0). - Gently evaluate external disturbance resilience physically nudging the structure.
- Excessive scaling logic explicitly induces catastrophic chassis shivering due to high-frequency IMU electromagnetic data multiplication.
- Scale up gently exclusively until low-frequency oscillatory behaviors decay flawlessly, completely mitigating physical overshoot properties native natively across balancing thresholds.
- Constant static battery weight discrepancies predictably force identical robotic frames to travel eternally backwards or forwards seeking false-centers.
- Incorporate explicitly diminutive constants (e.g.
I=2.0). - Ensure absolute strict mathematical enforcement limiting integral windups mapping variables securely within
config.hviaINTEGRAL_LIMITconstants.
Derivative variables exaggerate minor angular imperfections rapidly.
- Adjust
PID_D_FILTER_ALPHAdynamically withinconfig.h. < 0.2completely paralyzes reactive behaviors causing catastrophic phase-lag collapse.1.0introduces excessive grinding noises entirely originating directly from motor stators mimicking noise profiles precisely.- Typical structural optimum logic evaluates exactly near 0.7.
Actuating precise positional limits necessitates defining PKP.
- Transmit
PKP=0.0006dynamically activating algorithmic pushback protocols explicitly measuring cumulative uncommanded travel displacement structurally. - Transmit
EN_P=0totally disabling rigid odometric constraints executing solely standard gravity modeling.
Execute immediate configurations observing exact upper-case syntactical limits:
| Command | Action | Impact |
|---|---|---|
P=X |
Sets |
Immediate reaction strength. |
D=X |
Sets |
Damping influence and wobble reduction. |
M=X |
Sets RMS Limit | Adjusts explicitly the electrical current mapped natively by the TMC2208 drivers. Limits heat saturation. (Default 1100mA). |
S |
Output View | Dumps configured memory buffers sequentially displaying active parameters directly back identically mapped through UART protocols. |
C |
Calibrate | Completely zeroes drifting Mahony values identically measuring unmoving ambient vibration levels. (Perform Strictly Stationary) |