Pages: [1]   Go Down
Author Topic: Promini driving 3 servos?? – Can it??  (Read 494 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 33
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using a Promini (small to bury in a piece of kinetic art)  - powered separately with a “switching” PS (5V,1000ma) and 3 standard servos powered with a 5V 1000ma PS, (common ground) - would you expect the following code to drive the 3 servos independently?  They seemed to work at first for some time but then lose control and chattered.

Quote
// Sweep
// back and forth rotations of 60 degrees at random times of 5-20 seconds
//upload tp Promini 16mHz using Ardu Duemil 328 board and tty modem 

#include <Servo.h> m
 
Servo myservo9;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
Servo myservo5;
Servo myservo3;
 
int pos;    // variable to store the servo position
unsigned long pa9;
unsigned long pa5;
unsigned long pa3;
void setup()

  myservo9.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo5.attach(5);  // attaches the servo on pin 5 to the servo object
  myservo3.attach(3);  // attaches the servo on pin 3 to the servo object

 
 
void loop()

 
 //for servo9
  for(pos = 60; pos < 120; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
   { myservo9.write(pos);              // tell servo to go to position in variable 'pos'
    delay(45);}    // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
 
  }
 
 pa9=random (10000,40000);
 delay (pa9);
 
  for(pos = 120; pos>=60; pos-=1)     // goes from 180 degrees to 0 degrees
  {                                
    {myservo9.write(pos);              // tell servo to go to position in variable 'pos'
    delay(45);}                       // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
  } 
pa9=random (10000,40000);
 delay (pa9);
 
 
 //for servo5
 
  for(pos = 60; pos < 120; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
   { myservo5.write(pos);              // tell servo to go to position in variable 'pos'
    delay(45);}    // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
 
  }
 
 pa5=random (10000,40000);
 delay (pa5);
 
  for(pos = 120; pos>=60; pos-=1)     // goes from 180 degrees to 0 degrees
  {                                
    {myservo5.write(pos);              // tell servo to go to position in variable 'pos'
    delay(45);}                       // waits 15ms for the servo to reach the position
  } 
pa5=random (10000,40000);
 delay (pa5);
 
 
 //for servo3
 
  for(pos = 60; pos < 120; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
   { myservo3.write(pos);              // tell servo to go to position in variable 'pos'
    delay(45);}    // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
 
  }
 
 pa3=random (10000,40000);
 delay (pa3);
 
  for(pos = 120; pos>=60; pos-=1)     // goes from 180 degrees to 0 degrees
  {                                
    {myservo3.write(pos);              // tell servo to go to position in variable 'pos'
    delay(45);}                       // waits 15ms for the servo to reach the position
  } 
pa3=random (10000,40000);
 delay (pa3);



}

« Last Edit: August 27, 2010, 09:51:30 am by Peter_Rand » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34220
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
They seemed to work at first for some time but then lost control and chattered.
If they continued to chatter after you hit the reset then there is probably nothing wrong with the code but how you wires it up. You might have fried something, can you post a schematic?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 33
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi G-M
If I disconnect any one of the servos, the other two work fine. - If I exchange servo connections but use only two servos, all works fine - So connections are OK and neither motors nor promini is fried. Its just when I add the third motor that control is lost.
« Last Edit: August 27, 2010, 08:00:10 am by Peter_Rand » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34220
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You didn't say that. Your problem is either:-
1) Insufficient current from the supply to drive all the motors or
2) Insufficient supply decoupling http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

or possibly both
« Last Edit: August 27, 2010, 08:48:59 am by Grumpy_Mike » Logged

Pages: [1]   Go Up
Jump to: