Motacon_20200317
Dependents: HelloWorld_MotorKaisei
BLDCmotorDriver.h
- Committer:
- tbjazic
- Date:
- 2015-05-24
- Revision:
- 1:786897114846
- Parent:
- 0:5602fba2a7f7
- Child:
- 3:a4b4a8e3f2a0
File content as of revision 1:786897114846:
#include "mbed.h" #include "RateLimiter.h" class BLDCmotorDriver { public: BLDCmotorDriver(PinName pGH_A, PinName pGH_B, PinName pGH_C, PinName pGL_A, PinName pGL_B, PinName pGL_C, PinName pH1, PinName pH2, PinName pH3, PinName pfault); void configure(float sampleTime, float switchingFrequency, float rampUpSlope, float rampDownSlope); void setDutyCycle(float dutyCycle); void coast(); float getDutyCycle(); int getSector(); private: PwmOut GH_A, GH_B, GH_C; DigitalOut GL_A, GL_B, GL_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; DigitalOut fault; RateLimiter rl; Ticker ticker; float switchingPeriod, dutyCycle, tempDutyCycle, sampleTime; void commutation(); void adjustDutyCycle(); int currentSector, previousSector; };