Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 31971|回復: 19
打印 上一主題 下一主題

用Arduino控制一顆步進馬達!

[複製鏈接]
跳轉到指定樓層
1#
發表於 2012-1-25 19:19:56 | 顯示全部樓層 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
用Arduino控制一顆步進馬達!

Arduino 接 L298N ic
(手機拍的影像比較不清楚)
2#
 樓主| 發表於 2012-1-25 19:21:30 | 顯示全部樓層
另外要接電容比較好
3#
 樓主| 發表於 2012-1-28 13:07:29 | 顯示全部樓層
回復 3# pizg


    新年恭喜!
步進馬達沒有額定轉速,
是看信號的頻率,
我現在用arduino,最多是做到近三轉一秒,
有人做到約一分鐘六百轉,
要知道步進角度,
你就在程式裡讓它走兩百步,
如果正好轉一圈,就表示是步進角度是1.8,
只有特別的驅動器有不同的磁激方式,
L298N好像做不到.
4#
 樓主| 發表於 2012-1-30 11:38:26 | 顯示全部樓層
回復 5# pizg

你用ULN2003 控制的 5線式步進馬達應該是這種:

步進角度:5.625 x 1/64
減速比:1/64
這顆步進馬達裡面有減速齒輪,
信號頻率越大,馬達轉速越快,
馬達的STEPS是由自己設定的,這句stepper.step(200);就是只走200 STEPS,
stepper.setSpeed(30); 這一行設定轉速為30rpm, 我的馬達真的會是30rpm,
又如果設成stepper.setSpeed(30000); 它就不會動,
我的是四線馬達,跟你的不一樣,最多接近三轉一秒,
code如下:
#include <Stepper.h>
// change this to the number of steps on your motor
#define STEPS 200
//steps:代表馬達轉完一圈需要多少步數。如果馬達上有標示每步的度數,
//將360除以這個角度,就可以得到所需要的步數(例如:360/3.6=100)。(int)
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 2, 3, 4, 5);
//Stepper stepper(STEPS, 26, 28, 32, 34);
void setup()
{
stepper.setSpeed(140);// 將馬達的速度設定成140RPM 最大  150~160
}
void loop()
{
stepper.step(100);//正半圈
delay(1000);
stepper.step(-100);//反半圈
delay(1000);
stepper.step(200);//正1圈
delay(1000);
stepper.step(-200);//反1圈
delay(1000);
stepper.step(300);//正1圈半
delay(1000);
stepper.step(-300);//反1圈半
delay(1000);
stepper.step(1600);//正8圈
delay(1000);
stepper.step(-1600);//反8圈
delay(1000);
}
5#
 樓主| 發表於 2012-1-31 11:57:31 | 顯示全部樓層
回復 7# pizg

nichal分析的很有道理,
就我所知,
你這顆步進馬達裡面有減速齒輪,拆開來就看得到,
所以步進角度:5.625經過減速齒輪,就變成如你所說的0.703度
所以你的Speed Max=50rpm,變慢很正常,
你這顆步進馬達,我本來也要買,後來沒買到,
所以所知有限,
大概就這樣.
如果你要搞懂函數STEPS和setSpeed的關係如何,
應該要從<Stepper.h>裡面去瞭解,
6#
 樓主| 發表於 2012-1-31 12:02:10 | 顯示全部樓層
回復 8# nichal

孩子長大一點了,
肩膀所要負的責任還有很長的時間,
加油.
7#
 樓主| 發表於 2012-2-1 14:57:30 | 顯示全部樓層
回復 11# pizg
像你這顆馬達,
只有四種step寫法:

digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delayTime);
亂寫的話,很容易把馬達燒壞,
請參考:
http://arduino.cc/hu/Tutorial/StepperUnipolar
我的四線馬達則如下:


    ======================
Stepwire 1wire 2wire 3wire 4
1Highlowhighlow
2lowhighhighlow
3lowhighlowhigh
4highlowlowhigh
8#
 樓主| 發表於 2013-8-9 22:22:15 | 顯示全部樓層
本帖最後由 vegewell 於 2013-8-9 22:28 編輯

回復 19# t706845

>>>為何我照著上面的方法接線與寫程式
>>>結果馬達只會震動而不是轉動
   我不清楚你是照什麼圖連線
是否類似如下圖:記住這是5v電源,更高壓有其他接法,


步進馬達四條線是兩條一組,
(某兩條接合時有煞車的感覺)
你可以試換線看看,
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-5-16 00:42 , Processed in 0.328457 second(s), 9 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表