提示: 作者被禁止或刪除 內容自動屏蔽

TOP

睇落好似SPWM, 但gen完出嚟唔駛LC濾波先?
唔濾波簡直同短pulse無分別噃.....

早排我都玩過, drive 單極AC ...
Brainstomer 發表於 2018-4-23 21:42


小第都看過一些細四軸飛行器;
用DC 有擦摩打;
都是用一些 有STM32 來編程的 ;
ALL IN ONE 底板;

TOP

搵翻N年前用BLDC玩機械人的板。
再Load個sketch落去試下。
重work喎。
P80423-222343.jpg
冇用push button。稍為改下個sketch。

基礎版
=====
//const int buttonPin1 = 4;// the number of the direction pushbutton pin
//const int buttonPin2 = 5;// the number of the direction pushbutton pin
const int ledPin =  13;  // the number of the status LED pin (not the flash LED)
const int motorPin1 =9;
const int motorPin2 =10;
const int motorPin3 =11;
const int motorPins[]={6,7,8};

const int motorPinSteps[3][6]={
{1,1,1,0,0,0},
{1,0,0,0,1,1},
{0,0,1,1,1,0}};

int motorDelay=8; // together with pot controls the RPM
boolean direct = true; // direction true=forward, false=backward
int increment;
int currentStepA=0;

///////////////////////////////////////////////////////////////////////////////////
void setup() {

  //pinMode(buttonPin1, INPUT);
  //digitalWrite(buttonPin1, HIGH);  //internal pull up resistor
  //pinMode(buttonPin2, INPUT);
  //digitalWrite(buttonPin2, HIGH);  //internal pull up resistor
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  //
  move();
  delay(300);
}//end setup()
//////////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
currentStepA++;
if (currentStepA > 5) currentStepA=0;
move();
delay( motorDelay);
}//end loop()
///////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
////////////////////////////////////////////////////////////////////////
void move()
{
digitalWrite(motorPin1,motorPinSteps[0][currentStepA]);
digitalWrite(motorPin2,motorPinSteps[1][currentStepA]);
digitalWrite(motorPin3,motorPinSteps[2][currentStepA]);  
}//end move()
////////////////////////////////////////////////////////////////////////



sine wave 版
========
//const int buttonPin1 = 4;// the number of the direction pushbutton pin
//const int buttonPin2 = 5;// the number of the direction pushbutton pin
const int ledPin =  13;  // the number of the status LED pin (not the flash LED)
const int motorPin1 =9;  //pwm
const int motorPin2 =10; //pwm
const int motorPin3 =11; //pwm
int pwmSinA[] = {127,119,110,102,94,86,78,71,64,56,50,43,37,32,26,21,17,13,10,7,4,2,1,0,0,0,1,2,4,7,10,13,17,21,26,32,37,43,50,56,64,71,78,86,94,102,110,119,127,135,144,152,160,168,176,183,191,198,204,211,217,222,228,233,237,241,244,247,250,252,253,254,254,254,253,252,250,247,244,241,237,233,228,222,217,211,204,198,191,183,176,168,160,152,144,135}; // array of PWM duty values for 8-bit timer - sine function
int pwmSinB[] = {237,241,244,247,250,252,253,254,254,254,253,252,250,247,244,241,237,233,228,222,217,211,204,198,191,183,176,168,160,152,144,135,127,119,110,102,94,86,78,71,64,56,50,43,37,32,26,21,17,13,10,7,4,2,1,0,0,0,1,2,4,7,10,13,17,21,26,32,37,43,50,56,64,71,78,86,94,102,110,119,127,135,144,152,160,168,176,183,191,198,204,211,217,222,228,233}; // array of PWM duty values for 8-bit timer - sine function
int pwmSinC[] = {17,21,26,32,37,43,50,56,64,71,78,86,94,102,110,119,127,135,144,152,160,168,176,183,191,198,204,211,217,222,228,233,237,241,244,247,250,252,253,254,254,254,253,252,250,247,244,241,237,233,228,222,217,211,204,198,191,183,176,168,160,152,144,135,127,119,110,102,94,86,78,71,64,56,50,43,37,32,26,21,17,13,10,7,4,2,1,0,0,0,1,2,4,7,10,13}; // array of PWM duty values for 8-bit timer - sine function

int motorDelay=400; //controls the RPM
int direction = 1; // direction 1=cw, 0=ccw
int currentStep=0;

///////////////////////////////////////////////////////////////////////////////////
void setup() {

  //pinMode(buttonPin1, INPUT);
  //digitalWrite(buttonPin1, HIGH);  //internal pull up resistor
  //pinMode(buttonPin2, INPUT);
  //digitalWrite(buttonPin2, HIGH);  //internal pull up resistor
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  //
  move();
  delay(100);
}//end setup()
//////////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
currentStep++;
if (currentStep > 95) currentStep=0;
move();
delayMicroseconds(motorDelay);
}//end loop()
///////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//
////////////////////////////////////////////////////////////////////////
void move()
{
analogWrite(motorPin1, pwmSinA[currentStep]);
analogWrite(motorPin2, pwmSinB[currentStep]);
analogWrite(motorPin3, pwmSinC[currentStep]);
}//end move()
////////////////////////////////////////////////////////////////////////


若然唔work, 可能係用嘅BLDC唔同。
試下增大 delay() 或 delayMicroseconds() 嘅值。
或者調換下接線順序。

TOP

arduino-sensorless-brushless-dc-motor-control-diy-esc.png

TOP

我覺得電變點都應該要有 MCU 元素,
平時啲電變,要 update firmware,
有幾個基本設定 例如摩打進角,PW ...
ghostkcleung 發表於 2018-4-23 21:38


如果唔用ESC,而用Arduino 或者STM控制BLDC。咁Arduino 或者STM就係MCU元素。
簡單控制,同控制步進電機差不多。前面提到的基礎版類似步進嘅整步控制。而sine wave版就類似micro step 控制。

商用BLDC控制一般用hall sensor去同步磁極的位置(例如電動單車),或者用back EMF (例如BLDC散熱扇)。最近見過用encoder嘅相機穩定器。

TOP

TOP

提示: 作者被禁止或刪除 內容自動屏蔽

TOP

回覆 37# Brainstomer

呢個係攝影雲台穩定器用的bldc。5V都推得郁。

TOP

如果用square wave,我試過驅動電壓係低好多下。

樓主似乎係HDD motor,正常都要用12V。 ...
Brainstomer 發表於 2018-4-24 09:14


因為盡量節省成本;
用住HDD MOTOR 先;
整好線路 OK;
再想MOTOR
THANKS
各位再試  

TOP

要做 electronic commutation.  有好多野搞架

via HKEPC Reader for Android

TOP