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: 2017NHKpin_config mbed FEP ikarashiMDC PID jy901 omni HMC6352 omni_wheel
Fork of KANI2017v2 by
bot/PIDcontroller/PID_controller.h
- Committer:
- number_key
- Date:
- 2017-09-07
- Revision:
- 22:682cc376da6f
- Parent:
- 20:477c5d039e93
- Child:
- 23:37bb9afe9fdc
File content as of revision 22:682cc376da6f:
/**
* @file PID_controller.h
* @brief コンパスセンサを使ったPIDコントローラ
*/
#ifndef PID_CONTROLLER_H
#define PID_CONTROLLER_H
#include "mbed.h"
#include "pin_config.h"
#include "PID.h"
#include "jy901.h"
// const double M_PI = 3.141592653589793;
const double KC = 5.2;
const double TI = 0.0;
const double TD = 0.00;
const float INTERVAL = 0.01;
const float INPUT_LIMIT = 180.0;
const float OUTPUT_LIMIT = 0.4;
const float BIAS = 0.0;
const int SENSED_THRESHOLD = 180;
/**
* @brief コンパスセンサを使ったPIDコントローラ
*/
class PIDC : public PID, JY901, Ticker
{
public :
/**
* @brief defaultコンストラクタ,タイマ割り込みでの計算開始
*/
PIDC();
/**
* @brief コンストラクタ
* @param sda sda HMC6352
* @param scl scl HMC6352
* @param kc KC
* @param ti TI
* @param td TD
* @param interval interval
*/
PIDC(PinName sda, PinName scl, float kc, float ti, float td, float interval);
/**
* @brief センサの値とPIDの値をアップデート
*/
void confirm();
/**
* @brief 回転用座標系リセット
*/
void resetAxisOffset();
/**
* 平行移動用座標系リセット
*/
void resetPlaneOffset();
/**
* @brief PIDの計算結果を取得
* @return PIDの計算結果
*/
float getCalculationResult() const;
/**
* 現在の角度を取得
* @return 現在の角度(degree)
*/
float getCurrentDegree() const;
/**
* @brief キャリブレーションする
* @param mode ENTER OR EXIT
*/
void calibration(int mode);
private :
void updateOutput();
float axisOffSetDegree;
float planeOffSetDegree;
int turnOverNumber;
float beforeDegree;
protected :
float rawDegree;
float calculationResult;
float axisCurrentDegree;
float planeCurrentDegree;
};
#endif//PID_CONTROLLER_H
