Giter VIP home page Giter VIP logo

pid's Introduction

PID Control Library

PID control library implemented in floating point arithmetic, it is designed to run in almost any microcontroller that can accept C language code and implement floating point routines. It is based on the Arduino project PID library that can be found in the following address:

The main advantage of this PID library is that it can be compiled on a wide range of devices, due to the fact that this library does not require a C++ compiler and can be linked with our other libraries for maximum portability to other platforms.

Library Usage

The following code depicts the library basic usage, input and output functions should be provided by end user.

#include "PID.h"

// Structure to strore PID data and pointer to PID structure
struct pid_controller ctrldata;
pid_t pid;

// Control loop input,output and setpoint variables
float input = 0, output = 0;
float setpoint = 15;

// Control loop gains
float kp = 2.5, ki = 1.0, kd = 1.0;

void main()
{
	// Prepare PID controller for operation
	pid = pid_create(&ctrldata, &input, &output, &setpoint, kp, ki, kd);
	// Set controler output limits from 0 to 200
	pid_limits(pid, 0, 200);
	// Allow PID to compute and change output
	pid_auto(pid);

	// MAIN CONTROL LOOP
	for (;;) {
		// Check if need to compute PID
		if (pid_need_compute(pid)) {
			// Read process feedback
			input = process_input();
			// Compute new PID output value
			pid_compute(pid);
			//Change actuator value
			process_output(output);
		}
	}
}

Librería de control PID

Librería de control PID en punto flotante diseñada para correr en prácticamente cualquier microcontrolador que pueda aceptar código en lenguaje C y aritmética de punto flotante. Esta basada en la librería PID de arduino que puede encontrarse en la siguiente dirección:

La ventaja de esta librería es que puede compilarse para una mayor cantidad de dispositivos pues no requiere un compilador de C++ y puede enlazarse con otras de nuestras librerías para maxima portabilidad a otras plataformas.

Uso de la librería

El codigo siguiente muestra el uso básico de la librería, las funciones de entrada y salida deben ser provistas por el usuario.

#include "PID.h"

// Structure to strore PID data and pointer to PID structure
struct pid_controller ctrldata;
pid_t pid;

// Control loop input,output and setpoint variables
float input = 0, output = 0;
float setpoint = 15;

// Control loop gains
float kp = 2.5, ki = 1.0, kd = 1.0;

void main()
{
	// Prepare PID controller for operation
	pid = pid_create(&ctrldata, &input, &output, &setpoint, kp, ki, kd);
	// Set controler output limits from 0 to 200
	pid_limits(pid, 0, 200);
	// Allow PID to compute and change output
	pid_auto(pid);

	// MAIN CONTROL LOOP
	for (;;) {
		// Check if need to compute PID
		if (pid_need_compute(pid)) {
			// Read process feedback
			input = process_input();
			// Compute new PID output value
			pid_compute(pid);
			//Change actuator value
			process_output(output);
		}
	}
}

pid's People

Contributors

geekfactory 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.