第六部分:翻譯《THE MAKING OF A DIY BRUSHLESS GIMBAL WITH ARDUINO》 步驟6

步驟6:利用現(xiàn)有的程序來旋轉(zhuǎn)無刷電機


現(xiàn)在回到我的項目中阳距,本步驟中將會第一次涉及“如何來做”的內(nèi)容哦吆你。

在上個步驟中提到的文章幻林,作者利用Arduino來驅(qū)動了無刷電機讓其旋轉(zhuǎn)愚墓。他們參考了

一篇早期由eLABZ撰寫的文章杠氢。并且他們利用程序驗證了它摘能。在這面文章里作者eLABZ解釋了如何利用舊的DVD光驅(qū)的無刷電機來制作一個頻閃觀測器续崖。

據(jù)我所知,這是僅僅唯一的一篇關(guān)于利用Arduino來驅(qū)動無刷電機旋轉(zhuǎn)的团搞,并包含了全部細節(jié)的文章严望。這篇文章包含了3個部分。

1.Learning fundamental knowledge of (3-phase) Brushless Motor

2.Rotating Brushless Motor by using Arduino

3.Putting materials together to get Stroboscope

在第二個部分里提供了驅(qū)動無刷電機的程序逻恐。我讀完之后并做了相關(guān)的注釋像吻。然后我明白了我應(yīng)該需要給電機的三項通上三項交流電,并且每一項之間的相位相差120°(項與項之間無特殊順序)复隆。我模仿這個程序來驅(qū)動電機果然輕松地就讓我買的這個電機轉(zhuǎn)了起來拨匆。?DOCUMENTARY (5)?這個視頻展示了效果。

:

[DOCUMENTARY (5)] Rotating 3-Phase Brushless Motor with Arduino and AC Square Wave

視頻地址:https://www.youtube.com/embed/rzWfxoOVmjU

這里我解釋一下如何利用Arduino UNO來旋轉(zhuǎn)無刷電機挽拂。你需要一個三項無刷電機惭每,它有三條引出線。

1.把電機的這三根引出線分別與UNO的9,10,11引腳相連亏栈,沒有連接順序的要求台腥。

2.下載我這個步驟最后提供的兩個PDF文檔到你的電腦中

3.利用PDF閱讀器打開他們。

4.把任意其中一個文檔中的全部文字拷貝

5.把拷貝內(nèi)容粘貼到Arduino的開發(fā)環(huán)境中并且更正一些小錯誤绒北。

6.上載檢查無誤后的程序到Arduino中

這兩程序都是基于eLABz的原始程序修改而來黎侈。高轉(zhuǎn)矩的云臺電機會在程序上載完成后立刻開始旋轉(zhuǎn),而有些模型上用高速型的電機僅用Arduino提供的電力可能不會旋轉(zhuǎn)闷游。這時候就需要外部電源和電機驅(qū)動芯片了峻汉。在DOCUMENTARY (6)中的展示中就利用里外部電源和驅(qū)動芯片贴汪。在這個視頻的前半部分是展示的高扭矩型電機,在后半部分是展示的高速型電機休吠。

[DOCUMENTARY (6)] Rotating Two Types of Brushless Motor with Arduino, Outer Batteries and Sine Wave AC

視頻地址: https://www.youtube.com/embed/55_e6MnpI88



PDF1:

// Driving 3-phase Brushless DC Motor with Square-wave

// This sketch is based on the code for the stroboscope project by eLABZ.

// (http://elabz.com/bldc-motor-with-arduino-circuit-and-software/)

// Copyright (C) 2015 ArduinoDeXXX All Rights Reserved.

const int motorDelayActual = 150;

const int motorPin1 =9;

const int motorPin2 =10;

const int motorPin3 =11;

const int motorPinState[]={1,1,1,0,0,0};

int currentStepA=0;

int currentStepB=2;

int currentStepC=4;

long lastMotorDelayTime = 0;

void setup () {

pinMode(motorPin1, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

}

void loop () {

if((millis() - lastMotorDelayTime) > motorDelayActual){

currentStepA = currentStepA ++;

if(currentStepA > 5) currentStepA = 0;

if(currentStepA < 0) currentStepA = 5;

currentStepB = currentStepB ++;

if(currentStepB > 5) currentStepB = 0;

if(currentStepB < 0) currentStepB = 5;

currentStepC = currentStepC ++;

if(currentStepC > 5) currentStepC = 0;

if(currentStepC < 0) currentStepC = 5;

lastMotorDelayTime = millis();

analogWrite(motorPin1, 254 * motorPinState[currentStepA]);

analogWrite(motorPin2, 254 * motorPinState[currentStepB]);

analogWrite(motorPin3, 254 * motorPinState[currentStepC]);

}

}

// Copyright (C) 2015 ArduinoDeXXX All Rights Reserved.



PDF2:

// Driving 3-phase Brushless DC Motor with Sinusoidal Wave

// This sketch is based on the code for the stroboscope project by eLABZ.

// (http://elabz.com/bldc-motor-with-arduino-circuit-and-software/)

// Copyright (C) 2015 ArduinoDeXXX All Rights Reserved.

const int motorDelayActual = 20;

const int motorPin1 =9;

const int motorPin2 =10;

const int motorPin3 =11;

const int motorPinState[]={127,111,94,78,64,50,37,26,17,9,4,1,0,1,4,9,17,26,37,50,64,78,

94,111,127,144,160,176,191,205,218,229,238,245,251,254,255,

254,251,245,238,229,218,205,191,176,160,144,127};

int currentStepA = 0;

int currentStepB = 16;

int currentStepC = 32;

long lastMotorDelayTime = 0;

void setup () {

pinMode(motorPin1, OUTPUT);

pinMode(motorPin2, OUTPUT);

pinMode(motorPin3, OUTPUT);

}

void loop () {

if((millis() - lastMotorDelayTime) > motorDelayActual){

currentStepA = currentStepA ++;

if(currentStepA > 47) currentStepA = 0;

if(currentStepA < 0) currentStepA = 47;

currentStepB = currentStepB ++;

if(currentStepB > 47) currentStepB = 0;

if(currentStepB < 0) currentStepB = 47;

currentStepC = currentStepC ++;

if(currentStepC > 47) currentStepC = 0;

if(currentStepC < 0) currentStepC = 47;

lastMotorDelayTime = millis();

analogWrite(motorPin1, motorPinState[currentStepA]);

analogWrite(motorPin2, motorPinState[currentStepB]);

analogWrite(motorPin3, motorPinState[currentStepC]);

}

}

// Copyright (C) 2015 ArduinoDeXXX All Rights Reserved.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末嘶是,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子蛛碌,更是在濱河造成了極大的恐慌,老刑警劉巖辖源,帶你破解...
    沈念sama閱讀 221,695評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蔚携,死亡現(xiàn)場離奇詭異,居然都是意外死亡克饶,警方通過查閱死者的電腦和手機酝蜒,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,569評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來矾湃,“玉大人亡脑,你說我怎么就攤上這事⊙荆” “怎么了霉咨?”我有些...
    開封第一講書人閱讀 168,130評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長拍屑。 經(jīng)常有香客問我途戒,道長,這世上最難降的妖魔是什么僵驰? 我笑而不...
    開封第一講書人閱讀 59,648評論 1 297
  • 正文 為了忘掉前任喷斋,我火速辦了婚禮,結(jié)果婚禮上蒜茴,老公的妹妹穿的比我還像新娘星爪。我一直安慰自己,他們只是感情好粉私,可當(dāng)我...
    茶點故事閱讀 68,655評論 6 397
  • 文/花漫 我一把揭開白布顽腾。 她就那樣靜靜地躺著,像睡著了一般诺核。 火紅的嫁衣襯著肌膚如雪崔泵。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,268評論 1 309
  • 那天猪瞬,我揣著相機與錄音憎瘸,去河邊找鬼。 笑死陈瘦,一個胖子當(dāng)著我的面吹牛幌甘,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,835評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼锅风,長吁一口氣:“原來是場噩夢啊……” “哼酥诽!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起皱埠,我...
    開封第一講書人閱讀 39,740評論 0 276
  • 序言:老撾萬榮一對情侶失蹤肮帐,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后边器,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體训枢,經(jīng)...
    沈念sama閱讀 46,286評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,375評論 3 340
  • 正文 我和宋清朗相戀三年忘巧,在試婚紗的時候發(fā)現(xiàn)自己被綠了恒界。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,505評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡砚嘴,死狀恐怖十酣,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情际长,我是刑警寧澤耸采,帶...
    沈念sama閱讀 36,185評論 5 350
  • 正文 年R本政府宣布,位于F島的核電站工育,受9級特大地震影響洋幻,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜翅娶,卻給世界環(huán)境...
    茶點故事閱讀 41,873評論 3 333
  • 文/蒙蒙 一文留、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧竭沫,春花似錦燥翅、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,357評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至谎势,卻和暖如春凛膏,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背脏榆。 一陣腳步聲響...
    開封第一講書人閱讀 33,466評論 1 272
  • 我被黑心中介騙來泰國打工猖毫, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人须喂。 一個月前我還...
    沈念sama閱讀 48,921評論 3 376
  • 正文 我出身青樓吁断,卻偏偏與公主長得像趁蕊,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子仔役,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,515評論 2 359

推薦閱讀更多精彩內(nèi)容