ArduinoGeneral

flyduino servo control

userHead hardmouse 2013-01-13 04:51:02 8706 Views19 Replies
Hi,
I am having problem with following code to control servos via flyduino:
[quote]#include <Servo.h>
#define NBR_SERVOS 12
#define FIRST_SERVO_PIN 2

Servo Servos[NBR_SERVOS] ;

int pos = 0;

void setup()
{
for( int i =0; i < NBR_SERVOS; i++)
Servos[i].attach( FIRST_SERVO_PIN +i, 800, 2200);
}
void loop()
{

for(pos = 0; pos < 180; pos += 1){
for( int i =0; i <NBR_SERVOS; i++){
Servos[i].write(pos);
}
delay(15);
}
for(pos = 180; pos>=1; pos-=1){
for( int i =0; i <NBR_SERVOS; i++){
Servos[i].write(pos);
}
delay(15);
}
}[/quote]

The servo suppose to moving form 0~90 degree and back to 0 degree and keep looping. However, servos do moves but they only moving in between reading POS:45~55 and jiggling when reading less than 45 or greater than 55.

Any ideas? I really hope to get my quadrabot moving by using this board since it's the smallest board I can find to fit in my design. Thanks!

[img]http://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash3/65111_10152349937770111_1238878931_n.jpg[/img]
2013-01-18 16:01:08 So, by your code. 90 is the maximum?

When I test the Arduino SWEEP sample code, it only good until 60(default was 180).
Any inter over 60 just hold in position.

// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  for(pos = 0; pos < 60; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                      // waits 15ms for the servo to reach the position
  }
  for(pos = 60; pos>=1; pos-=1)    // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                      // waits 15ms for the servo to reach the position
  }
}
userHeadPic hardmouse
2013-01-18 16:01:08 So, by your code. 90 is the maximum?

When I test the Arduino SWEEP sample code, it only good until 60(default was 180).
Any inter over 60 just hold in position.

// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  for(pos = 0; pos < 60; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                      // waits 15ms for the servo to reach the position
  }
  for(pos = 60; pos>=1; pos-=1)    // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                      // waits 15ms for the servo to reach the position
  }
}
userHeadPic hardmouse
2013-01-18 00:54:47 =.=!
I used a servo controlled guitar system from my friend to test the flyduino.
The servos work fine... Here's the simple code. Could you figure out some difference?  ???

[code]
#include <Servo.h>
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
Servo myservo6;
Servo myservo7;
Servo myservo8;


void setup()
{
  myservo1.attach(2);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(3);  // attaches the servo on pin 9 to the servo object
  myservo3.attach(4);  // attaches the servo on pin 9 to the servo object
  myservo4.attach(5);  // attaches the servo on pin 9 to the servo object
  myservo5.attach(6);  // attaches the servo on pin 9 to the servo object
  myservo6.attach(7);  // attaches the servo on pin 9 to the servo object
  myservo7.attach(8);  // attaches the servo on pin 9 to the servo object
  myservo8.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  myservo1.write(0);
  myservo2.write(0);
  myservo3.write(0);
  myservo4.write(0);
  myservo5.write(0);
  myservo6.write(0);
  myservo7.write(0);
  myservo8.write(0);
  delay(1000);
  myservo1.write(90);
  myservo2.write(90);
  myservo3.write(90);
  myservo4.write(90);
  myservo5.write(90);
  myservo6.write(90);
  myservo7.write(90);
  myservo8.write(90);
  delay(1000);
}
[/code]
userHeadPic Lauren
2013-01-18 00:54:47 =.=!
I used a servo controlled guitar system from my friend to test the flyduino.
The servos work fine... Here's the simple code. Could you figure out some difference?  ???

[code]
#include <Servo.h>
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
Servo myservo6;
Servo myservo7;
Servo myservo8;


void setup()
{
  myservo1.attach(2);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(3);  // attaches the servo on pin 9 to the servo object
  myservo3.attach(4);  // attaches the servo on pin 9 to the servo object
  myservo4.attach(5);  // attaches the servo on pin 9 to the servo object
  myservo5.attach(6);  // attaches the servo on pin 9 to the servo object
  myservo6.attach(7);  // attaches the servo on pin 9 to the servo object
  myservo7.attach(8);  // attaches the servo on pin 9 to the servo object
  myservo8.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  myservo1.write(0);
  myservo2.write(0);
  myservo3.write(0);
  myservo4.write(0);
  myservo5.write(0);
  myservo6.write(0);
  myservo7.write(0);
  myservo8.write(0);
  delay(1000);
  myservo1.write(90);
  myservo2.write(90);
  myservo3.write(90);
  myservo4.write(90);
  myservo5.write(90);
  myservo6.write(90);
  myservo7.write(90);
  myservo8.write(90);
  delay(1000);
}
[/code]
userHeadPic Lauren
2013-01-17 23:38:25 :o Oh... It seems strange. I will try it also to figure the reason!  ;) userHeadPic Lauren
2013-01-17 23:38:25 :o Oh... It seems strange. I will try it also to figure the reason!  ;) userHeadPic Lauren
2013-01-17 10:39:11 By the way, I did try using Arduino NANO and the expansion shield, it works fine. But since the design of flyduino is much smaller. I'd like to use it as my first choice.  ;) userHeadPic hardmouse
2013-01-17 10:39:11 By the way, I did try using Arduino NANO and the expansion shield, it works fine. But since the design of flyduino is much smaller. I'd like to use it as my first choice.  ;) userHeadPic hardmouse
2013-01-17 10:24:32 The sample code is using MEGASERVO library which not working under IDE 1.0.1 so I modified it to servo instead. It doesn't work. And please, tried it yourself before post GUESSING answer. The code works with no problem. It's the reaction from servo doesn't seems right. If you want I can make a video for you. The power source is 7.2V lipo battery and I also using 15A UBEC regulate the current down to 6V. This setting works in all my other robots.

Re:Lauren
Here is the link:
[url=http://www.thingiverse.com/thing:41840]http://www.thingiverse.com/thing:41840[/url]
userHeadPic hardmouse
2013-01-17 10:24:32 The sample code is using MEGASERVO library which not working under IDE 1.0.1 so I modified it to servo instead. It doesn't work. And please, tried it yourself before post GUESSING answer. The code works with no problem. It's the reaction from servo doesn't seems right. If you want I can make a video for you. The power source is 7.2V lipo battery and I also using 15A UBEC regulate the current down to 6V. This setting works in all my other robots.

Re:Lauren
Here is the link:
[url=http://www.thingiverse.com/thing:41840]http://www.thingiverse.com/thing:41840[/url]
userHeadPic hardmouse
2013-01-17 00:23:01 Wow,Cool..... Could you please be kind to share with me the 3d model? What about your 3d printer?

Yes, like Ricky said, there's a high requirement for the max current supplied to the servos. What about your power system?
userHeadPic Lauren
2013-01-17 00:23:01 Wow,Cool..... Could you please be kind to share with me the 3d model? What about your 3d printer?

Yes, like Ricky said, there's a high requirement for the max current supplied to the servos. What about your power system?
userHeadPic Lauren
2013-01-17 00:11:24 These servo need huge current.  Double check your battery supply. userHeadPic R2D2C3PO
2013-01-17 00:11:24 These servo need huge current.  Double check your battery supply. userHeadPic R2D2C3PO
2013-01-17 00:10:49 Have you tried the servo sample?  The sample sketch is used to check your connection and power is correctly connected.


userHeadPic R2D2C3PO
2013-01-17 00:10:49 Have you tried the servo sample?  The sample sketch is used to check your connection and power is correctly connected.


userHeadPic R2D2C3PO
2013-01-15 08:19:18 So, no solution for this one? userHeadPic hardmouse
2013-01-15 08:19:18 So, no solution for this one? userHeadPic hardmouse
2013-01-13 04:51:02 Hi,
I am having problem with following code to control servos via flyduino:
[quote]#include <Servo.h>
#define NBR_SERVOS 12
#define FIRST_SERVO_PIN 2

Servo Servos[NBR_SERVOS] ;

int pos = 0;

void setup()
{
  for( int i =0; i < NBR_SERVOS; i++)
    Servos[i].attach( FIRST_SERVO_PIN +i, 800, 2200);
}
void loop()
{
 
    for(pos = 0; pos < 180; pos += 1){
      for( int i =0; i <NBR_SERVOS; i++){
        Servos[i].write(pos);
      }
      delay(15);
    }
    for(pos = 180; pos>=1; pos-=1){
      for( int i =0; i <NBR_SERVOS; i++){
        Servos[i].write(pos);
      }
      delay(15);
    }
}[/quote]

The servo suppose to moving form 0~90 degree and back to 0 degree and keep looping. However, servos do moves but they only moving in between reading POS:45~55 and jiggling when reading less than 45 or greater than 55.

Any ideas? I really hope to get my quadrabot moving by using this board since it's the smallest board I can find to fit in my design. Thanks!

[img]http://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-ash3/65111_10152349937770111_1238878931_n.jpg[/img]
userHeadPic hardmouse