|
Easy Control Library for Cubic 0.01
|
インクリメンタルエンコーダを用いた、DCモータの速度制御を行うためのクラス More...
#include <Cubic.controller.h>
Public Member Functions | |
| Velocity_PID (uint8_t motorNo, uint8_t encoderNo, enum class encoderType encoderType, uint16_t CPR, double Kp, double Ki, double Kd, double target, bool direction, double capableDutyCycle=1.0, double p=1.0, bool logging=false) | |
| Construct a new Velocity_PID object. | |
| void | setLPF (double p) |
| ローパスフィルタの係数pを設定します。 | |
| double | encoderToAngle (int32_t encoder) override |
| エンコーダの値から角度を計算します。設定したCPR(Count Per Revolution)に依存します。 | |
| double | compute () override |
| duty比を計算します。各ループで一回呼び出してください。このduty比は、DUTY_SPI_MAXに対する比です。計算された値は、この関数内部で、DC_motor::put()されます。 | |
| void | reset () override |
| 制御器のリセット | |
| void | reset (double target) override |
| 制御器のリセット | |
| void | reset (double Kp, double Ki, double Kd) override |
| 制御器のリセット | |
| void | reset (double Kp, double Ki, double Kd, double target) override |
| 制御器のリセット | |
Public Member Functions inherited from Cubic_controller::Controller | |
| Controller (uint8_t motorNo, uint8_t encoderNo, enum class encoderType encoderType, uint16_t CPR, double Kp, double Ki, double Kd, double target, bool direction, double capableDutyCycle, double current, bool logging=false) | |
| Construct a new Controller object. | |
| virtual void | setTarget (double target) |
| 制御量の目標値を設定します。 | |
| void | setGains (double Kp, double Ki, double Kd) |
| PIDゲインを設定します。負の値は-1倍されます。 | |
| void | setKp (double Kp) |
| Pゲインを設定します。負の値は-1倍されます。 | |
| void | setKi (double Ki) |
| Iゲインを設定します。負の値は-1倍されます。 | |
| void | setKd (double Kd) |
| Dゲインを設定します。負の値は-1倍されます。 | |
| int32_t | readEncoder () const |
| エンコーダを読みだします。 | |
| double | getTarget () const |
| 目標値を返します。 | |
| double | getDutyCycle () const |
| 直前に計算したデューティ比を返します。 | |
| double | getDt () const |
| 直前のループにおける経過時間dtを返します | |
| double | getCurrent () const |
| 直前に読んだ制御量を返します。 | |
Additional Inherited Members | |
Protected Member Functions inherited from Cubic_controller::Controller | |
| double | compute_PID (double current) |
| pid.compute_PID()を呼ぶだけの関数です。 | |
Protected Attributes inherited from Cubic_controller::Controller | |
| const uint8_t | motorNo |
| モータ番号 | |
| enum encoderType | encoderType |
| エンコーダの種類 | |
| const uint8_t | encoderNo |
| エンコーダ番号 | |
| const uint16_t | CPR |
| CPR(Counts Per Revolution) | |
| const bool | direction |
| モータをプラスの方向に回したとき、エンコーダが増加するかどうか | |
| const bool | logging |
| ログを出力するかどうか | |
インクリメンタルエンコーダを用いた、DCモータの速度制御を行うためのクラス
このクラスでは、エンコーダの角速度[rad/s]を制御量とします。
| Cubic_controller::Velocity_PID::Velocity_PID | ( | uint8_t | motorNo, |
| uint8_t | encoderNo, | ||
| enum class encoderType encoderType | , | ||
| uint16_t | CPR, | ||
| double | Kp, | ||
| double | Ki, | ||
| double | Kd, | ||
| double | target, | ||
| bool | direction, | ||
| double | capableDutyCycle = 1.0, | ||
| double | p = 1.0, | ||
| bool | logging = false ) |
Construct a new Velocity_PID object.
| motorNo | モータ番号 |
| encoderNo | エンコーダ番号 |
| encoderType | エンコーダの種類(インクリメントかアブソリュートか) |
| CPR | エンコーダのCPR(PPRでないことに注意。CPR=PPR*4) |
| Kp | |
| Ki | |
| Kd | |
| target | 目標速度[rad/s] |
| direction | モーターに正のdutyを与えたときに、エンコーダが正方向に回転するかどうか。trueなら正方向、falseなら負方向。 |
| capableDutyCycle | 最大許容デューティ比。0.0~1.0。省略可能で、デフォルトは1.0。 |
| p | ローパスフィルタの係数。0.0~1.0。省略可能で、デフォルトは1.0(フィルタなし)。 |
| logging | ログをSerial.printで出力するかどうか。省略可能で、デフォルトはfalse。 |
|
overridevirtual |
duty比を計算します。各ループで一回呼び出してください。このduty比は、DUTY_SPI_MAXに対する比です。計算された値は、この関数内部で、DC_motor::put()されます。
Implements Cubic_controller::Controller.
|
inlineoverridevirtual |
エンコーダの値から角度を計算します。設定したCPR(Count Per Revolution)に依存します。
| encoder |
Implements Cubic_controller::Controller.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inline |
ローパスフィルタの係数pを設定します。
| p |