Pages: [1]   Go Down
Author Topic: external power servo problem  (Read 945 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have 2 parallax continuous servos and i want to use an external power 4 AA batteries (= 6Volt). The problem is that i can't find a way to make it work with the arduino.
I read that i should connect the Gnd from batteries with the Gnd pin from arduino, but it doesn't work. Look my connections:



If i connect the servos this way, it only begin the one and with low speed(in my code i have both of them in full speed). If i connect only one servo it works, but with 2 NO.With 2 servos it has really strange behaviour, when i disconnect the signal wire from one also stops the other

Is it hardware problem (burned servo, connection)? Maybe software (my code is wrong? but if i connect only one each time works) ?
Thanks !!!
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23709
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post some more stuff:  your code, a link to the servo, your schematic.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

datasheet for the servo
http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/900-00008-CRServo-v2.1.pdf
and my code
Code:
//simple code to rotate one servo right and one servo left in full speed

int servoPin1 = 6;
int servoPin2 = 7;

void setup()
{
pinMode(servoPin1,OUTPUT);
pinMode(servoPin2,OUTPUT);
}
void loop()
{

digitalWrite(servoPin1,HIGH);
delayMicroseconds(1200);
digitalWrite(servoPin1,LOW);
delay(20); // 20ms

digitalWrite(servoPin2,HIGH);
delayMicroseconds(1800);
digitalWrite(servoPin2,LOW);
delay(20); // 20ms


}

schematic ??
i just connect the servos to the breadboard in my first  post
« Last Edit: February 24, 2011, 01:00:23 pm by ersod » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your wiring setup looks correct to me. However your software is a problem. You really should be using a servo library for your code, that way you just program changes and the library handles the continous updating to the servo control signal.

http://arduino.cc/en/Reference/Servo

Lefty
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23709
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So you have the effect of a 1.2mS high pulse and 41.8mS off for one, and 1.8mS pulse and 41.2mS off for the other.
Reading the datasheet, looks like you have an extra delay(20) in your code, at a  minimum.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@retrolefty when i search i found that code for continuous rotation for arduino and so i used it. I knew about the servo library but i don't know how works. I will try again

@KE7GKP the max voltage for each servo is 6 Volt. My batteries are new and since i have seen many constructions with 4 AA batteries( 6 Volt) and 3 servos , i believe that it should work.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
@retrolefty when i search i found that code for continuous rotation for arduino and so i used it. I knew about the servo library but i don't know how works. I will try again

The servo library will allow you just to only concern yourself with when you want to send a specific usec command value to each servo, the library will handle all the timing stuff for you.

Lefty

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

is this code correct ? I try with this but nothing works (edit:Look next post)
Code:
#include <Servo.h>

Servo myservo1;
Servo myservo2;

void setup()
{
  myservo1.attach(6);
  myservo2.attach(7);
    myservo1.writeMicroseconds(1.5);
    myservo2.writeMicroseconds(1.5);

}

void loop() {
  
    myservo1.writeMicroseconds(1.2);
    myservo2.writeMicroseconds(1.8);


}
« Last Edit: February 24, 2011, 01:55:56 pm by ersod » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Guys i believe that one servo is burned
I found a standard servo this time and i put on the breadboard both one continuous and one standard servo and i use servo library.
Both of them works. Then i put the second continuous servo in the continuous servo that it works and didn't begin.( i hear a sound  for a second like it going to begin but it doesn't begin)

I would like to ask you also 1 more question.
i want to put 3 servo in my construction, how to power them safe ( i don't want to burn one more)?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't use floating point numbers (ones with decimal points) in the servo command. It's expecting a usec long value:

    myservo1.writeMicroseconds(1.5);
    myservo2.writeMicroseconds(1.5);

should be:

   myservo1.writeMicroseconds(1500);
   myservo2.writeMicroseconds(1500);

Servos value should stay in the 1000 to 2000 usec range.

Lefty



Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't use floating point numbers (ones with decimal points) in the servo command. It's expecting a usec long value:

Yes but with  1800 and 1200 it turns REALLY slowly, hardly you see it turn
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't use floating point numbers (ones with decimal points) in the servo command. It's expecting a usec long value:

Yes but with  1800 and 1200 it turns REALLY slowly, hardly you see it turn


Well 1000 should give max speed in one direction, 2000 max speed in the other direction, and somewhere around 1500 should stop turning.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

first i like to thank you for your answers and sorry if I become tedious.

I read some things and i understand that maybe i need to calibrate my servo(so for this reason @retrolefty you gave me other numbers than the datasheet) ?. I use writeMicroseconds(1500) and the servo turns in a speed. I open my servo and i find a trimmer. I turn it still it stop. I find the center(1500 says the datasheet) for the servo , right ?
Now when i put 1800 and 1200 it works as it says in the datasheet.
But if i put for example 2300 it turns faster. Is this safe ? (since datasheet says to send pulses 1200 - 1800 only )  ? and since i calibrate my servo these values are not allowed?
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8913
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is some code I've used for testing two continous rotation servos via the serial monitor.

Code:
// zoomkat 11-22-10 serial servo (2) test
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.
// two servo setup with two servo commands
// send eight character string like 15001500 or 14501550

#include <Servo.h>
String readString, servo1, servo2;
Servo myservo1;  // create servo object to control a servo
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(6);  //the pin for the servo control
  myservo2.attach(7);
  Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(1); 
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    }
  }

  if (readString.length() >0) {
      Serial.println(readString); //see what was received
     
      // expect a string like 07002100 containing the two servo positions     
      servo1 = readString.substring(0, 4); //get the first four characters
      servo2 = readString.substring(4, 8); //get the next four characters
     
      Serial.println(servo1);  //print to serial monitor to see results
      Serial.println(servo2);
     
      int n1; //declare as number 
      int n2;
     
      char carray1[6]; //magic needed to convert string to a number
      servo1.toCharArray(carray1, sizeof(carray1));
      n1 = atoi(carray1);
     
      char carray2[6];
      servo2.toCharArray(carray2, sizeof(carray2));
      n2 = atoi(carray2);
     
      myservo1.writeMicroseconds(n1); //set servo position
      myservo2.writeMicroseconds(n2);
    readString="";
  }
}
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: