PID bijdrage

Dependencies:   mbed

main.cpp

Committer:
s1574396
Date:
2018-10-26
Revision:
0:8c5ca301505f

File content as of revision 0:8c5ca301505f:

#include "mbed.h"
const double Ts = // sample frequency 

//PID rotation - aanmaken van PID constanten en variabelen voor rotatie
const double = Rot_Kp =  , Rot_Ki =  , Rot_Kd = ;
double Rot_error = 0;
double Rot_prev_error = 0;

//PID translation - aanmaken van PID constanten en variabelen voor translatie
const double = Trans_Kp =  , Trans_Ki =  , Trans_Kd = ;
double Trans_error = 0;
double Trans_prev_error = 0;

// PID execution
double PID_control(double error, const double kp, const double ki, const double kd, 
{ 
// P control
double u_k = pk * error;

// I control
error_int = error_int + (Ts * error);
double u_i = ki * error_int;

// D control
double error_deriv = (error - error_prev);
double u_d = kd * error_deriv;
error_prev = error;

return u_k + u_i + u_d;

int main()
{

}