Arduino ServoTester

In order to test the newly bought big servo GWS S777CG/6BB, I use my arduino board and write a very simple sketch to do the task.

S777CG/6BB is a giant in terms of it's physical size, and it's a power hungry monster as well.
My arduino is equiped with a single 7805 regulator which is supposed to provide 1A of output current maximum. It is not enough to drive monster with this kind of output. So I decided to use exteranl power source, the 4-cell 1700mAh NiCd battery pack. With a hook-up current meter, I got the peak current of 1.2A, even without loading on the servo.

A pot was employed as an input source to adjust the servo horn position.



S777/6BB 買回來了, 當然要先測測看,
之前在披薩那裏跟飛友買的 servo tester kit 因為 output 電流太小, 接上 S777 後根本無法工作,
所以就自己做用 Arduino 做一個 ServoTester 好了.

Arduino 的  5V 輸出是靠一顆 7805 穩壓器, 最多也只能輸出 1A, 所以也不夠, 因此 S777 就用外接電源來推, 最簡單的就是 NiCd 電池啦. 用電流勾表量, 電流最高有 1.2A, 不過我看是不只, 因為一般電表反應慢, 不見得能量到 peak, 反正 這種電池用 20C 輸出應該都不成問題.
另外用了一顆可變電阻, 當作 servo 轉角調整, 寫個 Arduino 小程式, 呼叫 Sero library, 簡簡單單一個 ServoTester 就做做好了, 而且可透過 COM port 監看輸出值, 挺方便的.




The servo horn at neutral (90 deg.) position.






The servo horn at 170. deg position.






The servo horn at 10 deg. position.





The sketch


// ServoTester
//
// by GalileoSky  (http://tw.myblog.yahoo.com/galileo-sky)
// 2010,5,11

#include

#define  PIN_POT  0
#define  MAX_POS  170
#define  MIN_POS  10
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 
int servoPos = 0;    // variable to store the servo position
int potValues[3]= {0,0,0};


void setup()
{
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 
  // prints title
  Serial.println("ServoTester v0.1");
}
 
 
void loop()
{
  int    potValue;
 
  potValues[0] = analogRead(PIN_POT);
  delay(1);                        // waits 1ms
  potValues[1] = analogRead(PIN_POT);
  delay(1);                        // waits 1ms
  potValues[2] = analogRead(PIN_POT);
 
  potValue = (potValues[0]+potValues[1]+potValues[2])/3;
  Serial.print("potValue = ");
  Serial.println(potValue); 
 
  servoPos = map(potValue, 0,1023, MIN_POS, MAX_POS);
  Serial.print("servoPos = ");
  Serial.println(servoPos); 
  Serial.println(""); 

  myservo.write(servoPos);          // tell servo to go to position in variable 'servoPos'
  //delay(15);                        // waits 15ms for the servo to reach the position
}











arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Galileo 的頭像
    Galileo

    Galileo's Sky

    Galileo 發表在 痞客邦 留言(0) 人氣()