teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Sun Feb 24 10:33:34 2019 +0000
Revision:
48:71aec693a7dc
Parent:
46:5074781a28dd
20190224 add cmd pid mode 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 40:debe99e228d3 44 INT16 fpgaval; // FPGAにセットされた0~4095の値
MasashiNomura 28:fdb3b144e342 45 public:
MasashiNomura 28:fdb3b144e342 46 HbMotCtrl(eMotPos Pos, INT16 Type);//コンストラクタ
MasashiNomura 28:fdb3b144e342 47 ~HbMotCtrl();//デストラクタ
MasashiNomura 38:24ee50452755 48
MasashiNomura 28:fdb3b144e342 49 void setPwmLimt(INT16 Min, INT16 Max);
MasashiNomura 28:fdb3b144e342 50 void setRpmLimt(INT16 Min, INT16 Max);
MasashiNomura 29:eb3d72dd94aa 51 void setRpmOffset(INT16 ofs);
MasashiNomura 29:eb3d72dd94aa 52 void setRpmGain(float gain);
MasashiNomura 28:fdb3b144e342 53 void setMotCoef(float a, float b, float c);
MasashiNomura 32:7f4145cc3551 54
MasashiNomura 32:7f4145cc3551 55 INT16 calcPwm(INT16 rpm);
MasashiNomura 28:fdb3b144e342 56
MasashiNomura 32:7f4145cc3551 57 void setRpmValue(eMotInType type, INT16 value); // 値セット
MasashiNomura 48:71aec693a7dc 58 void setRpmValue(); //!< セットしたRPMの合計でFPGAに値をセット
MasashiNomura 32:7f4145cc3551 59 INT16 getRpmValue(eMotInType type); // Rpm
MasashiNomura 40:debe99e228d3 60
MasashiNomura 40:debe99e228d3 61 void setValFpga(INT16 value);
MasashiNomura 40:debe99e228d3 62 INT16 getValFpga();
MasashiNomura 28:fdb3b144e342 63 };
MasashiNomura 28:fdb3b144e342 64
MasashiNomura 28:fdb3b144e342 65 class HbSubProp{
MasashiNomura 28:fdb3b144e342 66 private:
MasashiNomura 28:fdb3b144e342 67 // 今回のモーターと電装ではこうなるが、変更があれば適宜変更かクラス構成の見直しが必要
MasashiNomura 40:debe99e228d3 68 #define PWN_MAX 4095
MasashiNomura 48:71aec693a7dc 69 #define RPM_IN_MAX 9000
MasashiNomura 46:5074781a28dd 70 #define RPM_OUT_MAX 9000
MasashiNomura 28:fdb3b144e342 71 #define RPM_MIN 1500
MasashiNomura 28:fdb3b144e342 72 eMotPos pos ;//識別ID
MasashiNomura 28:fdb3b144e342 73 HbMotCtrl *motCtrl[2];
MasashiNomura 28:fdb3b144e342 74 float curVal; // 現在のパーセンテージ
MasashiNomura 28:fdb3b144e342 75 float tarVal; // 目標パーセンテージ
MasashiNomura 28:fdb3b144e342 76 public:
MasashiNomura 28:fdb3b144e342 77 HbSubProp(eMotPos Pos);//コンストラクタ
MasashiNomura 28:fdb3b144e342 78 ~HbSubProp();//デストラクタ
MasashiNomura 28:fdb3b144e342 79
MasashiNomura 28:fdb3b144e342 80 void setRpmLimIn(INT16 min, INT16 max);
MasashiNomura 28:fdb3b144e342 81 void setRpmLimOut(INT16 min, INT16 max);
MasashiNomura 28:fdb3b144e342 82 void setPwmLimit(INT16 min, INT16 max);
MasashiNomura 32:7f4145cc3551 83 void setRpmGain(eMotType type, float gain);// 個体差吸収用ゲイン
MasashiNomura 32:7f4145cc3551 84 void setRpmOffset(eMotType type, INT16 ofs);// 個体差吸収用オフセット
MasashiNomura 28:fdb3b144e342 85 void setCoef(eMotType type, float a, float b, float c);
MasashiNomura 28:fdb3b144e342 86
MasashiNomura 32:7f4145cc3551 87 void setValue(eMotInType type, INT16 val); // rpm
MasashiNomura 48:71aec693a7dc 88 void setValue();//!< セットしたRPMの合計でFPGAに値をセット
MasashiNomura 32:7f4145cc3551 89 INT16 getValue(eMotInType type); // rpm
MasashiNomura 28:fdb3b144e342 90
MasashiNomura 40:debe99e228d3 91 // Debug用
MasashiNomura 40:debe99e228d3 92 void setValueFpgaMot(eMotType type, INT16 val);
MasashiNomura 40:debe99e228d3 93 INT16 getValueFpgaMot(eMotType type);
MasashiNomura 28:fdb3b144e342 94 // あとで実装したい関数たち
MasashiNomura 28:fdb3b144e342 95 //void addValue(float val);
MasashiNomura 28:fdb3b144e342 96 //void onePush(float val);// パーセンテージ
MasashiNomura 28:fdb3b144e342 97 //void setValueEMG(float val); // オフセット分も含めて指定可能
MasashiNomura 28:fdb3b144e342 98 };
MasashiNomura 28:fdb3b144e342 99
MasashiNomura 28:fdb3b144e342 100
takeru0x1103 18:5aa48aec9cae 101 /////////////////////////////////////////////////////////////////////
takeru0x1103 18:5aa48aec9cae 102 #endif