Git Product home page Git Product logo

pid-impl's Introduction

Just run g++ example.cpp qPIDs.c -o executable ./executable

qPID Digital PID controller library

Introduction

This library is a digital Proportional-Integrative-Derivative digital controller designed for embedded systems to interact with real systems.

Principle of work and definitions

Block Diagram

Block diagram

Detailed information

Full mathematical description and testing results of this libarary can be found (in spanish) in kharsansky-quadrotor-control-thesis.

Usage example

#include "qPIDs.h"

float setPoint = 0.0;
float sensor = 0.0;
float output = 0.0;


// Example usage for the qPID library for controlling the speed of a simle motor
// The idea is to control the speed of the motor by varing the voltage applied via PWM

float readSensor(void);			// A function that reads the motor speed from a sensor
float readSetPoint(void);		// A function that reads the desired speed from a potentiometer
void setActuator(float);				// A function that sets the PWM output for controlling the motor

void example(void){

	// Declare de new object
	qPID controller;

	// Configure settings
	controller.AntiWindup = ENABLED;
	controller.Bumpless = ENABLED;

	// Set mode to auotmatic (otherwise it will be in manual mode)
	controller.Mode = AUTOMATIC;

	// Configure de output limits for clamping
	controller.OutputMax = 1.0;
	controller.OutputMin = -1.0;

	// Set the rate at the PID will run in seconds
	controller.Ts = 0.005;

	// More settings
	controller.b = 1.0;
	controller.c = 1.0;

	// Init de controller
	qPID_Init(&controller);

	// Set the tunning constants
	controller.K = 0.5;
	controller.Ti = 1/0.02;
	controller.Td = 0.0;
	controller.Nd = 4.0;

	while (1){
		sensor = readSensor();				// update the process variable
		setPoint = readSetPoint(); 			// update the user desired value

		// Update the PID and get the new output
		output = qPID_Process(&controller, setPoint, sensor);

		setActuator(output);				// update the actuator input
	}

}

pid-impl's People

Contributors

akharsa avatar saloid avatar cocopeanutz avatar

Watchers

James Cloos avatar  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.