Go Down

Topic: external power servo problem (Read 1 time) previous topic - next topic

ersod


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

retrolefty



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

ersod

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?

zoomkat

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

Code: [Select]
// 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="";
  }
}
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

Go Up