Library for driving a 3-phase brushless DC motor.

Dependents:   BLDC_mainProgram STMF302R8_MotorDrive HelloWorld_IHM07M1

BLDCmotorDriver

Introduction

This library is still being developed.

This is a Wiki page about BLDCmotorDriver library developed by TVZ Mechatronics Team. The library is part of our project of creating an e-bike which is supposed to drive/run a 3-phase brushless DC motor with Hall sensors.

We are testing our library on NXP mbed LPC1768 platform and driver DRV8301 from Texas Instruments to run our testing BLDC motor. Next step of our project is creating a standalone library for DRV8301.

Hall sensors

In our BLDC motors there are three Hall sensors located 120 degrees from one another, they are identified as InterruptIn/DigitalIn on mbed and they send zeros and ones on TeraTerm with we locate in which sector

Na našim testnim BLDC motorima postoje 3 halova senzora, koji su udaljeni za 120 stupnjeva jedan od drugoga te inicijaliziranjem svakog pojedinog kao InterruptIn/DigitalIn na pinovima mbeda preko terminala na računalu (TeraTerm) dobivamo prikaz binarnih nula i jedinica koji se slažu sa trobitnim gray-evim kodom, s time da smo kombinacije 000 i 111 definirali kao fault vrijednosti. Pošto se slučajevi kada su sva tri hallova senzora upaljena ili ugašena ne mogu dogoditi tj. ne bi se smijeli dogoditi, ukoliko je došlo do takve situacije dogodio se kvar na hallovim senzorima te bi motor trebao prijeći u mod rada bez hallovih senzora.

With that we got six combinations, which we use to determine six sectors:

  • 001 - Sector 1
  • 011 - Sector 2
  • 010 - Sector 3
  • 110 - Sector 4
  • 100 - Sector 5
  • 101 - Sector 6

Nakon toga odredili smo za sve tri faze stanja mosfeta..

/media/uploads/dfraj/3-bit_gray_code_ring.jpg

Components

/media/uploads/dfraj/kotac.jpg

Committer:
avilei
Date:
Wed Oct 12 08:16:28 2016 +0000
Revision:
4:f56d1fb53d9b
Parent:
3:a4b4a8e3f2a0
Make members protected to allow C++ inheritance

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mslovic 0:5602fba2a7f7 1 #include "mbed.h"
mslovic 0:5602fba2a7f7 2 #include "RateLimiter.h"
mslovic 0:5602fba2a7f7 3
mslovic 0:5602fba2a7f7 4 class BLDCmotorDriver {
mslovic 0:5602fba2a7f7 5 public:
mslovic 3:a4b4a8e3f2a0 6 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);
mslovic 0:5602fba2a7f7 7 void configure(float sampleTime, float switchingFrequency, float rampUpSlope, float rampDownSlope);
mslovic 0:5602fba2a7f7 8 void setDutyCycle(float dutyCycle);
mslovic 0:5602fba2a7f7 9 void coast();
mslovic 0:5602fba2a7f7 10 float getDutyCycle();
tbjazic 1:786897114846 11 int getSector();
mslovic 3:a4b4a8e3f2a0 12 void ispis();
mslovic 3:a4b4a8e3f2a0 13
avilei 4:f56d1fb53d9b 14 protected:
tbjazic 1:786897114846 15 PwmOut GH_A, GH_B, GH_C;
tbjazic 1:786897114846 16 DigitalOut GL_A, GL_B, GL_C; // Low-side gates are never PWM driven
tbjazic 1:786897114846 17 InterruptIn H1; // InterruptIn can be used on all pins except p19 and p20
tbjazic 1:786897114846 18 InterruptIn H2;
tbjazic 1:786897114846 19 InterruptIn H3;
mslovic 0:5602fba2a7f7 20 RateLimiter rl;
mslovic 0:5602fba2a7f7 21 Ticker ticker;
mslovic 0:5602fba2a7f7 22 float switchingPeriod, dutyCycle, tempDutyCycle, sampleTime;
tbjazic 1:786897114846 23 void commutation();
mslovic 3:a4b4a8e3f2a0 24 int currentSector, _currentSector, previousSector, difference;
mslovic 3:a4b4a8e3f2a0 25 DigitalOut Fault;
mslovic 3:a4b4a8e3f2a0 26 int h1, h2, h3;
mslovic 3:a4b4a8e3f2a0 27 //void adjustDutyCycle();
mslovic 3:a4b4a8e3f2a0 28
mslovic 0:5602fba2a7f7 29 };