20200821_motacon_ver4
Diff: BLDCmotorDriver.h
- Revision:
- 6:51643d078474
- Parent:
- 3:a4b4a8e3f2a0
- Child:
- 7:7365c75b2af1
--- a/BLDCmotorDriver.h Fri Mar 13 01:07:30 2020 +0000 +++ b/BLDCmotorDriver.h Fri Aug 21 08:29:01 2020 +0000 @@ -1,29 +1,37 @@ #include "mbed.h" -#include "RateLimiter.h" class BLDCmotorDriver { public: BLDCmotorDriver(PinName GH_A, PinName GL_A, PinName GH_B, PinName GL_B, PinName GH_C, PinName GL_C, PinName h1, PinName h2, PinName h3, PinName Fault); void configure(float sampleTime, float switchingFrequency, float rampUpSlope, float rampDownSlope); void setDutyCycle(float dutyCycle); + void setDirection(float direction); //方向決定スイッチ void coast(); float getDutyCycle(); int getSector(); void ispis(); + short HS_cnt; //short(min:-32768 max: 32767)で充分 //intとかshortのサイズについて:https://os.mbed.com/users/mbed714/notebook/integer-types-int-long-and-long-long/ + bool HS_check; //0か1にしかならなkためboolで宣言 + int HS_usec; + int rpm_a, rpm_b; //ホールセンサカウンタ(速度計測用) private: - PwmOut GH_A, GH_B, GH_C; - DigitalOut GL_A, GL_B, GL_C; // Low-side gates are never PWM driven + PwmOut GL_A, GL_B, GL_C; //←ハイサイド・ローサイドの変更 + DigitalOut GH_A, GH_B, GH_C; // Low-side gates are never PWM driven InterruptIn H1; // InterruptIn can be used on all pins except p19 and p20 InterruptIn H2; InterruptIn H3; - RateLimiter rl; + Timer t; //回転数用大麻 Ticker ticker; float switchingPeriod, dutyCycle, tempDutyCycle, sampleTime; + int direction; void commutation(); - int currentSector, _currentSector, previousSector, difference; + void H1rise(); //ホールセンサ1の立ち上がり時に飛ぶ関数(回転数計測用に使っている) + int currentSector, _currentSector; DigitalOut Fault; int h1, h2, h3; + + int n; //void adjustDutyCycle(); }; \ No newline at end of file