Pages: [1]   Go Down
Author Topic: help in controlling several servo motors  (Read 487 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi guys, we are having a hard time programming several servo motors, can someone help us on how to made servo motors moves simultaneously we madly need help regarding this one
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
   There are lots of people that can help you on these forums, but to get anyones interest you really need to put more detail in the question.

Try editing your question to include the code you are using, a quick description of the circuit and power supply and a description of the problem. Your problem may be something very simple such as insufficient power for the number of servos, but right now we have nothing to go on.

Duane B
Logged


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

here is what we are really trying to do but with the use of Arduino

Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Test code for two servos.

Code:
// zoomkat 12-13-11 serial servo (2) test
// for use with serial monitor
// for IDE 1.0
// 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("two-servo-test-1.0"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(3);  //delay to allow buffer to fill
    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 = servo1.toInt();
      int n2 = servo2.toInt();
     
      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

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

is that code for simultaneous movement of servo motors??
Logged

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

is that code for simultaneous movement of servo motors??

The rotational speed of R/C servos is so slow compared to arduino program execution speed that yes all servos controlled by the servo library can be 'simultaneously controlled'. A position command sent to the servo library is only one instruction is time span, the servo library continuously keeps sending the last position command on a interrupt basis while the sketch continuous on to other statements in the sketch. How long a servo takes to reach the commanded position is of course determined by it's starting position relative to the new commanded position, and a little dependent on the mechanical load attached to the servo.

If a Arduino can turn on and off 125 leds in my 5x5x5 led cube without me seeing any sign of flicker is it controlling all 125 leds simultaneously? No but in reality it appears to be.

Lefty
Logged

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

i will try this code thanks for the help!! by the way is a servo controller also a best way of controlling several servo motors?
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
by the way is a servo controller also a best way of controlling several servo motors

If you have a lot of servos or the servos have to do things like move slowly, a dedicated servo controller can take the load off of the arduino coding.
Logged

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

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

i will try this code thanks for the help!! by the way is a servo controller also a best way of controlling several servo motors?

The servo library being interrupt driven and once enabled and attached, places little overhead on a typical sketch. But again that really is dependent on what other things your sketch has to accomplish. Dedicated hardware servo controllers have there place in life. Keep in mind that a Arduino board itself could become a great 'hardware servo' controller, receiving servo commands from another arduino board via serial, I2C, or SPI communication methods. Hardware servo controllers are nothing more then dedicated microcontrollers assigned just one task and communicate with a 'master' controller.

Lefty

Logged

Pages: [1]   Go Up
Jump to: