AutoThrottle is an Arduino library designed to provide a dynamic and adaptive throttle control system. It is particularly useful in applications where precise control of speed or motor output is critical, such as robotics, drones, or motorized vehicles. The library integrates the AutoTunePID system to offer both automatic and manual PID tuning, along with advanced features like throttle smoothing, stability checks, and flexible configuration options.
-
PID-Based Throttle Control
- Leverages PID (Proportional-Integral-Derivative) control to achieve precise speed or output regulation.
- Supports automatic tuning using AutoTunePID with multiple methods:
- Ziegler-Nichols
- Cohen-Coon
- Relay Feedback
- Internal Model Control (IMC)
- Allows manual tuning for custom PID gains.
-
Throttle Smoothing
- Gradual ramping of throttle to avoid sudden spikes or dips.
- Adjustable ramp rate for fine control over throttle response.
-
Dynamic Target Adjustment
- Update the target speed or desired output dynamically during runtime.
-
Real-Time Stability Monitoring
- Built-in functionality to assess system stability based on error tolerance.
- Enables monitoring and debugging in real-world scenarios.
-
Flexible Input and Output Limits
- Configurable throttle limits to match the hardware and application constraints.
-
Real-World Ready
- Designed for seamless integration into robotics, motorized systems, and other projects requiring precise motor control.
-
Download the Library
- Download the AutoThrottle library from the GitHub repository or as a .zip file.
-
Add to Arduino IDE
- Open Arduino IDE.
- Go to Sketch > Include Library > Add .ZIP Library...
- Select the downloaded .zip file and import it.
-
Verify Installation
- Navigate to File > Examples > AutoThrottle to see example sketches included with the library.
AutoThrottle(float minThrottle, float maxThrottle, TuningMethod method = ZieglerNichols);
- minThrottle: Minimum allowable throttle value.
- maxThrottle: Maximum allowable throttle value.
- method: Tuning method used by AutoTunePID (default: ZieglerNichols).
-
setTargetSpeed(float targetSpeed)
- Sets the desired speed or output for the throttle system.
- Parameters:
targetSpeed
: Target speed value in the desired unit.
-
setTuningMethod(TuningMethod method)
- Updates the tuning method for AutoTunePID.
- Parameters:
method
: Tuning method (ZieglerNichols, CohenCoon, RelayFeedback, IMC).
-
setManualGains(float kp, float ki, float kd)
- Manually sets PID gains for the system.
- Parameters:
kp
: Proportional gain.ki
: Integral gain.kd
: Derivative gain.
-
setThrottleLimits(float minThrottle, float maxThrottle)
- Updates the minimum and maximum allowable throttle values.
- Parameters:
minThrottle
: Minimum throttle value.maxThrottle
: Maximum throttle value.
-
updateCurrentSpeed(float currentSpeed)
- Updates the current speed or input value to the throttle system.
- Parameters:
currentSpeed
: Measured speed or input value.
-
computeThrottle()
- Computes the new throttle value based on the current speed and target speed.
- Returns:
float
: Computed throttle value.
-
reset()
- Resets the PID and throttle system to initial state.
- enableThrottleSmoothing(bool enable, float rampRate = 5.0)
- Enables or disables throttle smoothing.
- Parameters:
enable
: Enable (true) or disable (false) smoothing.rampRate
: Rate of change for throttle adjustments.
-
getThrottle()
- Retrieves the current throttle value.
- Returns:
float
: Current throttle value.
-
isStable(float tolerance = 0.1)
- Checks if the system is stable within a given error tolerance.
- Parameters:
tolerance
: Acceptable error margin for stability.
- Returns:
bool
: True if stable, false otherwise.
The AutoThrottle library is built on top of the AutoTunePID library, offering advanced tuning methods and features:
-
Automatic Tuning
- Choose from Ziegler-Nichols, Cohen-Coon, Relay Feedback, or IMC methods.
- Tuning adjusts PID gains dynamically during operation.
-
Manual Override
- Manually set PID gains for custom control.
-
Input and Output Filtering
- Smoothens noisy input or output signals.
-
Throttle Smoothing:
- Use smoothing in applications where sudden throttle changes can cause instability (e.g., drones, robots).
- Adjust the ramp rate to suit the system's response time.
-
Tuning Methods:
- For systems with high inertia, consider using the IMC method for better performance.
- Relay Feedback is ideal for oscillatory systems.
-
Error Tolerance:
- Set the
tolerance
value inisStable()
based on your system's precision requirements.
- Set the
Contributions to this library are welcome! To contribute:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix.
- Submit a pull request with detailed explanations of your changes.