Crates.io | piddiy |
lib.rs | piddiy |
version | |
source | src |
created_at | 2024-04-28 06:18:31.034366 |
updated_at | 2025-01-15 01:23:42.420124 |
description | DIY custom PID controller toolkit. |
homepage | |
repository | https://github.com/sgeos/piddiy |
max_upload_size | |
id | 1223029 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
PIDDIY (Proportional-Integral-Derivative Do It Yourself) is a lightweight and flexible library designed for building custom PID controllers in no_std
Rust environments. This library provides the foundational components for Proportional, Integral, and Derivative controls, allowing users to fine-tune and deploy PID algorithms tailored to their specific application needs.
The core philosophy behind PIDDIY is to offer a simple yet powerful set of tools that enable developers to implement custom PID control strategies without the overhead of unnecessary features. By providing direct control over the three primary components of PID systems:
PIDDIY encourages a hands-on approach, allowing for deep integration into systems where precise control and customization are required.
To use PIDDIY in your project, add the following to your Cargo.toml
:
[dependencies]
piddiy = { version = "0.1.0", default-features = false }
Example Usage Here is a basic example of how to set up a PID controller:
use piddiy::PidController;
// Custom control data for temperature reading.
#[derive(Clone, Copy)]
struct ControlData {
temperature: f64, // Current Temperature (Celsius)
dt: f64, // Time Step (Seconds)
}
// Custom compute function for temperature control.
fn temperature_control_compute(
pid: &mut PidController<f64, ControlData>,
data: ControlData,
) -> (f64, f64, f64) {
// PID control is calculated with library routines.
let error = pid.calculate_error(data.temperature);
let integral = pid.calculate_integral_dt(error, data.dt);
let derivative = pid.calculate_derivative_backward(error, data.dt);
(error, integral, derivative)
}
fn main() {
// Initialize the PID controller.
let mut pid = PidController::<f64, ControlData>::new();
pid
.compute_fn(temperature_control_compute) // Custom PID Function
.set_point(23.0) // Desired Temperature (Celsius)
.kp(0.1) // Proportional Gain
.ki(0.05) // Integral Gain
.kd(0.01); // Derivative Gain
// Simutlated control data.
let mut control_data = ControlData {
temperature: 20.0, // Initial Temperature (Celsius)
dt: 0.1, // Measurement Time Step (Seconds)
};
// Perform PID control computation to determine control action.
let control_output = pid.compute(control_data);
println!("Control Action: {}", control_output);
}
PIDDIY is licensed under the BSD Zero Clause License (0BSD), allowing for nearly unrestricted use, modification, and distribution of the library in both open and closed source projects.
For more details, see the LICENSE file included with the library.