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.
PID.h
00001 //Ben Katz, 2013 00002 //PID Controller class 00003 00004 #include "mbed.h" 00005 00006 #ifndef PID_CONTROLLER_H 00007 #define PID_CONTROLLER_H 00008 00009 class PIDController { 00010 public: 00011 PIDController(float p_gain, float d_gain, float i_gain); 00012 00013 float command_position(float current_position); 00014 float command_torque(float current_current); 00015 float command_position_tm(float current_position, float current_current); 00016 00017 // Process variable commanded value 00018 float command; 00019 float current_torque; 00020 00021 void set_command(float command); 00022 00023 private: 00024 float kp; 00025 float kd; 00026 float ki; 00027 00028 // State for process variable (position for now) 00029 float error; 00030 float old_error; 00031 float integral_error; 00032 00033 // Current command (fuse with command?) 00034 float torque_command; 00035 float torque_error; 00036 float torque_integral_error; 00037 float torque_history[5]; 00038 00039 float direction; 00040 }; 00041 00042 #endif
Generated on Tue Jul 12 2022 15:35:31 by
1.7.2