teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Mon Dec 17 13:25:00 2018 +0000
Revision:
29:eb3d72dd94aa
Parent:
28:fdb3b144e342
Child:
32:7f4145cc3551
2018/12/17 modify HbMotCtrl HbSubProp 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 28:fdb3b144e342 29 eMotPos pos; // 位置
MasashiNomura 28:fdb3b144e342 30 INT16 typ; // 流入側or出力側
MasashiNomura 28:fdb3b144e342 31 INT16 val; //
MasashiNomura 28:fdb3b144e342 32 INT16 ofs; // オフセットスロットル
MasashiNomura 28:fdb3b144e342 33 INT16 pwmMin; //
MasashiNomura 28:fdb3b144e342 34 INT16 pwmMax; //
MasashiNomura 28:fdb3b144e342 35 INT16 rpmMin; //
MasashiNomura 28:fdb3b144e342 36 INT16 rpmMax; //
MasashiNomura 29:eb3d72dd94aa 37 INT16 rpmOfs; // 調整用オフセット
MasashiNomura 29:eb3d72dd94aa 38 float rpmGain; // 調整用ゲイン
MasashiNomura 28:fdb3b144e342 39 float coefA; // PWMとRPMの関係の曲線の係数A
MasashiNomura 28:fdb3b144e342 40 float coefB; // PWMとRPMの関係の曲線の係数B
MasashiNomura 28:fdb3b144e342 41 float coefC; // PWMとRPMの関係の曲線の係数C
MasashiNomura 29:eb3d72dd94aa 42 //INT16 curPwmVal; // 計算してセットした値
MasashiNomura 29:eb3d72dd94aa 43 //INT16 curRpmVal; // 指定された現在のRPM
MasashiNomura 28:fdb3b144e342 44 //INT16 tblVal[100]; // %->PWMの変換テーブル
MasashiNomura 28:fdb3b144e342 45
MasashiNomura 28:fdb3b144e342 46 public:
MasashiNomura 28:fdb3b144e342 47 /**/
MasashiNomura 28:fdb3b144e342 48 HbMotCtrl(eMotPos Pos, INT16 Type);//コンストラクタ
MasashiNomura 28:fdb3b144e342 49 ~HbMotCtrl();//デストラクタ
MasashiNomura 28:fdb3b144e342 50 bool isReady();//使用できるようにパラメータがセットされたかどうか(今は使わないかなぁ)
MasashiNomura 28:fdb3b144e342 51 void setPwmLimt(INT16 Min, INT16 Max);
MasashiNomura 28:fdb3b144e342 52 void setRpmLimt(INT16 Min, INT16 Max);
MasashiNomura 29:eb3d72dd94aa 53 void setRpmOffset(INT16 ofs);
MasashiNomura 29:eb3d72dd94aa 54 void setRpmGain(float gain);
MasashiNomura 28:fdb3b144e342 55 void setMotCoef(float a, float b, float c);
MasashiNomura 28:fdb3b144e342 56 //void makeTable(); // 変換テーブル作成 パラメータセット後呼ぶ
MasashiNomura 28:fdb3b144e342 57 INT16 calcPwm(INT16 percent);
MasashiNomura 29:eb3d72dd94aa 58 INT16 calcPwm(UINT16 rpm);
MasashiNomura 28:fdb3b144e342 59
MasashiNomura 29:eb3d72dd94aa 60 //void setValue(float value); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 61 //void setOfs(float value); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 62 //float getValue(); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 63 //float getOfs(); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 64
MasashiNomura 29:eb3d72dd94aa 65 void setRpmValue(INT16 value); // Rpm
MasashiNomura 29:eb3d72dd94aa 66 void setRpmOfs(INT16 value); // Rpm
MasashiNomura 29:eb3d72dd94aa 67 INT16 getRpmValue(); // Rpm
MasashiNomura 29:eb3d72dd94aa 68 INT16 getRpmOfs(); // Rpm
MasashiNomura 28:fdb3b144e342 69 };
MasashiNomura 28:fdb3b144e342 70
MasashiNomura 28:fdb3b144e342 71 class HbSubProp{
MasashiNomura 28:fdb3b144e342 72 private:
MasashiNomura 28:fdb3b144e342 73 // 今回のモーターと電装ではこうなるが、変更があれば適宜変更かクラス構成の見直しが必要
MasashiNomura 28:fdb3b144e342 74 #define PWN_MAX 4000
MasashiNomura 28:fdb3b144e342 75 #define RPM_IN_MAX 8500
MasashiNomura 28:fdb3b144e342 76 #define RPM_OUT_MAX 7500
MasashiNomura 28:fdb3b144e342 77 #define RPM_MIN 1500
MasashiNomura 28:fdb3b144e342 78 eMotPos pos ;//識別ID
MasashiNomura 28:fdb3b144e342 79 HbMotCtrl *motCtrl[2];
MasashiNomura 28:fdb3b144e342 80 float curVal; // 現在のパーセンテージ
MasashiNomura 28:fdb3b144e342 81 float tarVal; // 目標パーセンテージ
MasashiNomura 28:fdb3b144e342 82 public:
MasashiNomura 28:fdb3b144e342 83 HbSubProp(eMotPos Pos);//コンストラクタ
MasashiNomura 28:fdb3b144e342 84 ~HbSubProp();//デストラクタ
MasashiNomura 28:fdb3b144e342 85
MasashiNomura 28:fdb3b144e342 86 void setRpmLimIn(INT16 min, INT16 max);
MasashiNomura 28:fdb3b144e342 87 void setRpmLimOut(INT16 min, INT16 max);
MasashiNomura 28:fdb3b144e342 88 void setPwmLimit(INT16 min, INT16 max);
MasashiNomura 29:eb3d72dd94aa 89 void setRpmGain(eMotType type, float gain);
MasashiNomura 29:eb3d72dd94aa 90 void setRpmOffset(eMotType type, INT16 ofs);
MasashiNomura 28:fdb3b144e342 91 void setCoef(eMotType type, float a, float b, float c);
MasashiNomura 28:fdb3b144e342 92 //void makeTbl();
MasashiNomura 28:fdb3b144e342 93
MasashiNomura 29:eb3d72dd94aa 94 //void setValue(float val); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 95 //void setOfs(float val); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 96 //float getValue(); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 97 //float getOfs(); // パーセンテージ0~50
MasashiNomura 29:eb3d72dd94aa 98 void setValue(INT16 val); // rpm
MasashiNomura 29:eb3d72dd94aa 99 void setOfs(INT16 val); // rpm
MasashiNomura 29:eb3d72dd94aa 100 INT16 getValue(); // rpm
MasashiNomura 29:eb3d72dd94aa 101 INT16 getOfs(); // rpm
MasashiNomura 28:fdb3b144e342 102
MasashiNomura 28:fdb3b144e342 103 // あとで実装したい関数たち
MasashiNomura 28:fdb3b144e342 104 //void addValue(float val);
MasashiNomura 28:fdb3b144e342 105 //void onePush(float val);// パーセンテージ
MasashiNomura 28:fdb3b144e342 106 //void setValueEMG(float val); // オフセット分も含めて指定可能
MasashiNomura 28:fdb3b144e342 107 };
MasashiNomura 28:fdb3b144e342 108
MasashiNomura 28:fdb3b144e342 109
takeru0x1103 18:5aa48aec9cae 110 /////////////////////////////////////////////////////////////////////
takeru0x1103 18:5aa48aec9cae 111 #endif