Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: L432KC_SPI_Pey_Lal
asservissement.cpp
00001 #include "asservissement.hpp" 00002 #include "toolbox.hpp" 00003 00004 double kp = 1; 00005 double ki = 1; 00006 double errorIntegral = 0; 00007 double integralLimit = 10; 00008 00009 uint32_t PID(double error, double sampleRate) 00010 { 00011 errorIntegral += error / sampleRate; 00012 errorIntegral = limitToInterval(errorIntegral, -integralLimit, integralLimit); 00013 double correction = kp * error + ki * errorIntegral; 00014 double correctionPWM = SPEED_TO_PWM_TRANSFORM(correction); 00015 return limitToInterval(correctionPWM, 1000, 1500); 00016 } 00017 00018 void setPIDParameters(double kp_, double ki_) 00019 { 00020 kp = kp_; 00021 ki = ki_; 00022 }
Generated on Thu Sep 15 2022 00:01:42 by
1.7.2