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.
Diff: HbMotor.h
- Revision:
- 28:fdb3b144e342
- Parent:
- 27:ff63c23bc689
- Child:
- 29:eb3d72dd94aa
--- a/HbMotor.h Fri Dec 14 12:32:27 2018 +0000
+++ b/HbMotor.h Sat Dec 15 14:20:04 2018 +0000
@@ -2,6 +2,7 @@
#define __HBMOTOR_H__
/////////////////////////////////////////////////////////////////////
#include "typedef.h"
+#include "globalFlags.h"
class HbMotor{
private:
@@ -21,5 +22,74 @@
void setValueFPGA(UCHAR iID, INT16 iVal);//iIDは 0 or 1
};
+class HbMotCtrl{
+private:
+ std::bitset<4> ready;
+ //bool ready;
+ eMotPos pos; // 位置
+ INT16 typ; // 流入側or出力側
+ INT16 val; //
+ INT16 ofs; // オフセットスロットル
+ INT16 pwmMin; //
+ INT16 pwmMax; //
+ INT16 rpmMin; //
+ INT16 rpmMax; //
+ float coefA; // PWMとRPMの関係の曲線の係数A
+ float coefB; // PWMとRPMの関係の曲線の係数B
+ float coefC; // PWMとRPMの関係の曲線の係数C
+ INT16 curPwmVal; // 計算してセットした値
+ INT16 curRpmVal; // 指定された現在のRPM
+ //INT16 tblVal[100]; // %->PWMの変換テーブル
+
+public:
+/**/
+ HbMotCtrl(eMotPos Pos, INT16 Type);//コンストラクタ
+ ~HbMotCtrl();//デストラクタ
+ bool isReady();//使用できるようにパラメータがセットされたかどうか(今は使わないかなぁ)
+ void setPwmLimt(INT16 Min, INT16 Max);
+ void setRpmLimt(INT16 Min, INT16 Max);
+ void setMotCoef(float a, float b, float c);
+ //void makeTable(); // 変換テーブル作成 パラメータセット後呼ぶ
+ INT16 calcPwm(INT16 percent);
+
+ void setValue(float value); // パーセンテージ0~50
+ void setOfs(float value); // パーセンテージ0~50
+ float getValue(); // パーセンテージ0~50
+ float getOfs(); // パーセンテージ0~50
+};
+
+class HbSubProp{
+private:
+// 今回のモーターと電装ではこうなるが、変更があれば適宜変更かクラス構成の見直しが必要
+#define PWN_MAX 4000
+#define RPM_IN_MAX 8500
+#define RPM_OUT_MAX 7500
+#define RPM_MIN 1500
+ eMotPos pos ;//識別ID
+ HbMotCtrl *motCtrl[2];
+ float curVal; // 現在のパーセンテージ
+ float tarVal; // 目標パーセンテージ
+public:
+ HbSubProp(eMotPos Pos);//コンストラクタ
+ ~HbSubProp();//デストラクタ
+
+ void setRpmLimIn(INT16 min, INT16 max);
+ void setRpmLimOut(INT16 min, INT16 max);
+ void setPwmLimit(INT16 min, INT16 max);
+ void setCoef(eMotType type, float a, float b, float c);
+ //void makeTbl();
+
+ void setValue(float val); // パーセンテージ0~50
+ void setOfs(float val); // パーセンテージ0~50
+ float getValue(); // パーセンテージ0~50
+ float getOfs(); // パーセンテージ0~50
+
+ // あとで実装したい関数たち
+ //void addValue(float val);
+ //void onePush(float val);// パーセンテージ
+ //void setValueEMG(float val); // オフセット分も含めて指定可能
+};
+
+
/////////////////////////////////////////////////////////////////////
#endif
\ No newline at end of file