teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Thu Dec 20 11:38:09 2018 +0000
Revision:
32:7f4145cc3551
Parent:
29:eb3d72dd94aa
Child:
35:3779201b4c73
12/20 Add new Feedback for PID and Modify MotCtrl,SubProp,Attitude,HbManager,etc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeru0x1103 18:5aa48aec9cae 1 #ifndef __HBMOTOR_H__
takeru0x1103 18:5aa48aec9cae 2 #define __HBMOTOR_H__
takeru0x1103 18:5aa48aec9cae 3 /////////////////////////////////////////////////////////////////////
takeru0x1103 18:5aa48aec9cae 4 #include "typedef.h"
MasashiNomura 28:fdb3b144e342 5 #include "globalFlags.h"
takeru0x1103 18:5aa48aec9cae 6
takeru0x1103 18:5aa48aec9cae 7 class HbMotor{
takeru0x1103 18:5aa48aec9cae 8 private:
takeru0x1103 18:5aa48aec9cae 9 UCHAR id ;//識別ID
takeru0x1103 18:5aa48aec9cae 10 INT16 ofs;//オフセットスロットル
takeru0x1103 18:5aa48aec9cae 11 INT16 limitH;//
takeru0x1103 18:5aa48aec9cae 12 INT16 limitL;//
MasashiNomura 25:f3a6e7eec9c3 13 INT16 curVal;
takeru0x1103 18:5aa48aec9cae 14 public:
takeru0x1103 18:5aa48aec9cae 15 HbMotor(UCHAR iID);//コンストラクタ
takeru0x1103 18:5aa48aec9cae 16 void setValue(INT16 iVal);
MasashiNomura 25:f3a6e7eec9c3 17 void setOfs(INT16 iVal);
MasashiNomura 25:f3a6e7eec9c3 18 INT16 getOfs();
MasashiNomura 24:c5945aaae777 19 void setLimit(INT16 low, INT16 hi);
MasashiNomura 25:f3a6e7eec9c3 20 INT16 getCurrentValue();
MasashiNomura 25:f3a6e7eec9c3 21 void setValueDirect(INT16 iVal);
MasashiNomura 27:ff63c23bc689 22 void setValueFPGA(UCHAR iID, INT16 iVal);//iIDは 0 or 1
takeru0x1103 18:5aa48aec9cae 23 };
takeru0x1103 18:5aa48aec9cae 24
MasashiNomura 28:fdb3b144e342 25 class HbMotCtrl{
MasashiNomura 28:fdb3b144e342 26 private:
MasashiNomura 29:eb3d72dd94aa 27 //std::bitset<4> ready;
MasashiNomura 28:fdb3b144e342 28 //bool ready;
MasashiNomura 32:7f4145cc3551 29 eMotPos pos; // 位置
MasashiNomura 32:7f4145cc3551 30 INT16 typ; // 流入(IN)側or出力(OUT)側
MasashiNomura 32:7f4145cc3551 31 INT16 val; // User入力値
MasashiNomura 32:7f4145cc3551 32 INT16 attval; // 姿勢制御の入力値
MasashiNomura 32:7f4145cc3551 33 INT16 ofs; // オフセットスロットル値
MasashiNomura 32:7f4145cc3551 34 INT16 pwmMin; //
MasashiNomura 32:7f4145cc3551 35 INT16 pwmMax; //
MasashiNomura 32:7f4145cc3551 36 INT16 rpmMin; //
MasashiNomura 32:7f4145cc3551 37 INT16 rpmMax; //
MasashiNomura 32:7f4145cc3551 38 INT16 rpmOfs; // 調整用オフセット
MasashiNomura 32:7f4145cc3551 39 float rpmGain; // 調整用ゲイン
MasashiNomura 32:7f4145cc3551 40 float coefA; // PWMとRPMの関係の曲線の係数A
MasashiNomura 32:7f4145cc3551 41 float coefB; // PWMとRPMの関係の曲線の係数B
MasashiNomura 32:7f4145cc3551 42 float coefC; // PWMとRPMの関係の曲線の係数C
MasashiNomura 28:fdb3b144e342 43
MasashiNomura 28:fdb3b144e342 44 public:
MasashiNomura 28:fdb3b144e342 45 HbMotCtrl(eMotPos Pos, INT16 Type);//コンストラクタ
MasashiNomura 28:fdb3b144e342 46 ~HbMotCtrl();//デストラクタ
MasashiNomura 32:7f4145cc3551 47 //bool isReady();//使用できるようにパラメータがセットされたかどうか(今は使わないかなぁ)
MasashiNomura 28:fdb3b144e342 48 void setPwmLimt(INT16 Min, INT16 Max);
MasashiNomura 28:fdb3b144e342 49 void setRpmLimt(INT16 Min, INT16 Max);
MasashiNomura 29:eb3d72dd94aa 50 void setRpmOffset(INT16 ofs);
MasashiNomura 29:eb3d72dd94aa 51 void setRpmGain(float gain);
MasashiNomura 28:fdb3b144e342 52 void setMotCoef(float a, float b, float c);
MasashiNomura 32:7f4145cc3551 53
MasashiNomura 32:7f4145cc3551 54 INT16 calcPwm(INT16 rpm);
MasashiNomura 28:fdb3b144e342 55
MasashiNomura 32:7f4145cc3551 56 void setRpmValue(eMotInType type, INT16 value); // 値セット
MasashiNomura 32:7f4145cc3551 57 //void setRpmOfs(INT16 value); // Rpm
MasashiNomura 32:7f4145cc3551 58 INT16 getRpmValue(eMotInType type); // Rpm
MasashiNomura 32:7f4145cc3551 59 //INT16 getRpmOfs(); // Rpm
MasashiNomura 28:fdb3b144e342 60 };
MasashiNomura 28:fdb3b144e342 61
MasashiNomura 28:fdb3b144e342 62 class HbSubProp{
MasashiNomura 28:fdb3b144e342 63 private:
MasashiNomura 28:fdb3b144e342 64 // 今回のモーターと電装ではこうなるが、変更があれば適宜変更かクラス構成の見直しが必要
MasashiNomura 28:fdb3b144e342 65 #define PWN_MAX 4000
MasashiNomura 28:fdb3b144e342 66 #define RPM_IN_MAX 8500
MasashiNomura 28:fdb3b144e342 67 #define RPM_OUT_MAX 7500
MasashiNomura 28:fdb3b144e342 68 #define RPM_MIN 1500
MasashiNomura 28:fdb3b144e342 69 eMotPos pos ;//識別ID
MasashiNomura 28:fdb3b144e342 70 HbMotCtrl *motCtrl[2];
MasashiNomura 28:fdb3b144e342 71 float curVal; // 現在のパーセンテージ
MasashiNomura 28:fdb3b144e342 72 float tarVal; // 目標パーセンテージ
MasashiNomura 28:fdb3b144e342 73 public:
MasashiNomura 28:fdb3b144e342 74 HbSubProp(eMotPos Pos);//コンストラクタ
MasashiNomura 28:fdb3b144e342 75 ~HbSubProp();//デストラクタ
MasashiNomura 28:fdb3b144e342 76
MasashiNomura 28:fdb3b144e342 77 void setRpmLimIn(INT16 min, INT16 max);
MasashiNomura 28:fdb3b144e342 78 void setRpmLimOut(INT16 min, INT16 max);
MasashiNomura 28:fdb3b144e342 79 void setPwmLimit(INT16 min, INT16 max);
MasashiNomura 32:7f4145cc3551 80 void setRpmGain(eMotType type, float gain);// 個体差吸収用ゲイン
MasashiNomura 32:7f4145cc3551 81 void setRpmOffset(eMotType type, INT16 ofs);// 個体差吸収用オフセット
MasashiNomura 28:fdb3b144e342 82 void setCoef(eMotType type, float a, float b, float c);
MasashiNomura 28:fdb3b144e342 83
MasashiNomura 32:7f4145cc3551 84 void setValue(eMotInType type, INT16 val); // rpm
MasashiNomura 32:7f4145cc3551 85 //void setOfs(INT16 val); // rpm
MasashiNomura 32:7f4145cc3551 86 INT16 getValue(eMotInType type); // rpm
MasashiNomura 32:7f4145cc3551 87 //INT16 getOfs(); // rpm
MasashiNomura 28:fdb3b144e342 88
MasashiNomura 28:fdb3b144e342 89 // あとで実装したい関数たち
MasashiNomura 28:fdb3b144e342 90 //void addValue(float val);
MasashiNomura 28:fdb3b144e342 91 //void onePush(float val);// パーセンテージ
MasashiNomura 28:fdb3b144e342 92 //void setValueEMG(float val); // オフセット分も含めて指定可能
MasashiNomura 28:fdb3b144e342 93 };
MasashiNomura 28:fdb3b144e342 94
MasashiNomura 28:fdb3b144e342 95
takeru0x1103 18:5aa48aec9cae 96 /////////////////////////////////////////////////////////////////////
takeru0x1103 18:5aa48aec9cae 97 #endif