Git Product home page Git Product logo

autopid-for-esp-idf's Introduction

AutoPID-for-ESP-IDF

AutoPID-for-ESP-IDF is a PID controller library adapted from the AutoPID library designed for Arduino, now compatible with the ESP-IDF (Espressif IoT Development Framework) environment. This library provides an easy way to implement PID control in your ESP32 projects, offering flexibility and precision for various control systems.

Features

  • PID Control: Implements Proportional-Integral-Derivative (PID) control for fine-tuned process control.
  • Bang-Bang Control: Provides bang-bang control mode for simpler on/off control with upper and lower thresholds.
  • Integral Windup Prevention: Manages integral windup, ensuring stability and performance.
  • Flexible Output Range: Allows setting custom output ranges for different applications.
  • Adjustable Gains: Enables dynamic adjustment of Kp, Ki, and Kd gains.
  • Time Step Configuration: Customizable PID update interval for better control over processing cycles.
  • Relay Control: Includes a relay control extension for on/off switching applications.

Time-scaling and Automatic Value Updating

The PID controller’s run() function can be called as often as possible in the main loop, and will automatically only perform the updated calculations at a specified time-interval. The calculations take the length of this time-interval into account, so the interval can be adjusted without needing to recaculate the PID gains.

Since the PID object stores pointers to the input, setpoint, and output, it can automatically update those variables without extra assignment statements.

Bang-Bang Control

This library includes optional built-in bang-bang control. When the input is outside of a specified range from the setpoint, the PID control is deactivated, and the output is instead driven to max (bang-on) or min (bang-off).

This can help approach the setpoint faster, and reduce overshooting due to integrator wind-up.

PWM (Relay) Control

Since the output of a PID control is an analog value, this can be adapted to control an on-off digital output (such as a relay) using pulse-width modulation.

Getting Started

Prerequisites

  • ESP-IDF: Ensure you have the ESP-IDF installed and set up. Follow the official ESP-IDF Getting Started Guide for instructions.
  • Hardware: ESP32 development board, sensors (e.g., temperature sensor), and actuators (e.g., heaters, motors).

Installation

Using ESP Component Registry (Recommended)

Head to the ESP component registry for AutoPID-for-ESP-IDF and follow the instructions to add the library to your project.

Using Git (Manual Installation)

  1. Clone the Repository:

    git clone https://github.com/hayschan/AutoPID-for-ESP-IDF.git
    cd AutoPID-for-ESP-IDF
  2. Add to Your ESP-IDF Project:

    • Add the AutoPID-for-ESP-IDF directory to the components directory of your ESP-IDF project.
    • Modify your project's CMakeLists.txt to include the AutoPID component

Usage

An example project demonstrating the use of AutoPID for temperature control can be found in the examples directory. The example uses a temperature sensor, potentiometer, and DAC output to maintain a setpoint temperature.

Two examples are provided:

  • Basic Example: Demonstrates the basic usage of the AutoPID library for temperature control.
  • Temperature Control with Relay: Demonstrates the use of the AutoPID library with relay control for on/off temperature control.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • Original AutoPID library by r-downing: AutoPID

autopid-for-esp-idf's People

Contributors

hayschan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.