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 /********************************************* 00002 PID library 00003 00004 PositionPid : 位置型 00005 SpeedPid : 速度型 00006 00007 setup(float Kp, float Ki, float Kd, float dt) 00008 パラメータ、制御周期の設定 00009 Kp : Pゲイン 00010 Ki : Iゲイン 00011 Kd : Dゲイン 00012 dt : 制御周期[s] 00013 00014 calculate(float target, float nowValue) 00015 PIDの計算をする 00016 target : 目標値 00017 nowValue : 現在値 00018 00019 duty() 00020 計算結果を-1~1で返す 00021 *********************************************/ 00022 00023 #ifndef MBED_PID_H 00024 #define MBED_PID_H 00025 00026 #include "mbed.h" 00027 00028 class PositionPid 00029 { 00030 public : 00031 void setup(float Kp, float Ki, float Kd, float dt); 00032 00033 void calculate(float target, float nowValue); 00034 00035 float duty(); 00036 00037 private : 00038 float kp, ki, kd, 00039 time, frequency, 00040 old, now, 00041 p, i, d, result; 00042 }; 00043 00044 class SpeedPid 00045 { 00046 public : 00047 void setup(float Kp, float Ki, float Kd, float dt); 00048 00049 void calculate(float target, float nowValue); 00050 00051 float duty(); 00052 00053 private : 00054 float kp, ki, kd, 00055 time, frequency, 00056 e, e1, e2, 00057 p, i, d, result; 00058 }; 00059 00060 #endif
Generated on Wed Jul 27 2022 12:59:15 by
