iT邦幫忙

0

伺服馬達抖動的原因/解法?

  • 分享至 

  • xImage

小弟我最近剛接觸到arduino,看了許多教程還有機械手臂後一時心血來潮想自己設計一個。原本想用直覺操作的方式控制伺服馬達,在模擬器瘋狂演練也看不出什麼大問題(https://www.tinkercad.com/things/bZYs6ib9LYU) 但實際組裝起來以後問題就出現了==
我剛上傳完程式,開啟獨立供電模塊以後,伺服馬達(們)馬上就瘋狂的亂轉,用來控制的可變電阻好像也沒什麼幫助...
跪求各大神指點我做錯的地方或是我忽略了什麼關鍵點.../images/emoticon/emoticon02.gif

https://ithelp.ithome.com.tw/upload/images/20200403/20126084fdoCOa4Z0Z.png
程式碼如下↓

#include   <Servo.h>

Servo servo1;  
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

const int servo1Pin = 3;
const int servo2Pin = 5;
const int servo3Pin = 6;
const int servo4Pin = 9;
const int servo5Pin = 10;
const int servo6Pin = 11;

const int pot1 = 0;
const int pot2 = 1;
const int pot3 = 2;
const int pot4 = 3;

int potValue1;
int potValue2;
int potValue3;
int potValue4;
int potValue5;
int potValue6;

void setup() {
  
  servo1.attach(servo1Pin);
  servo2.attach(servo2Pin);
  servo3.attach(servo3Pin);
  servo4.attach(servo4Pin);
  servo5.attach(servo5Pin);
  servo6.attach(servo6Pin);
  
}
void loop() {
  
 potValue1 = analogRead (pot1);
 potValue1 = map(potValue1, 0, 1023, 0, 180);
 servo1.write(potValue1);

 
 potValue2 = analogRead (pot1);
 potValue2 = map(potValue2, 0, 1023, 0, 180);
 servo2.write(180-potValue2);

delay(50); 
 
 potValue3 = analogRead (pot3);
 potValue3 = map(potValue3, 0, 1023, 0, 180);
 servo3.write(potValue3);

delay(50);
 
 potValue4 = analogRead (pot4);
 potValue4 = map(potValue4, 0, 1023, 0, 180);
 servo4.write(potValue4);

 delay(50);
  
 potValue5 = analogRead (pot2);
 potValue5 = map(potValue5, 0, 1023, 0, 180);
 servo5.write(potValue5);


 potValue6 = analogRead (pot2);
 potValue6 = map(potValue6, 0, 1023, 0, 180);
 servo6.write(180-potValue6);
 
 
 delay(50);
}
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
frank1025
iT邦見習生 ‧ 2020-04-04 17:46:03
最佳解答

先確認是input還是控制馬達的output問題
如果馬達的解析度與精度不佳,就算能正常操控也是會發生抖動,因為移動不到目標值,就會持續修正,要求不高可以嘗試把角度轉過頭再拉回.

我要發表回答

立即登入回答