Author Topic: Mutlpe servos  (Read 2278 times)

0 Members and 1 Guest are viewing this topic.

Offline vipulan12Topic starter

  • Robot Overlord
  • ****
  • Posts: 181
  • Helpful? 0
Mutlpe servos
« on: March 10, 2013, 12:06:52 PM »
Hey guys, Is it possible to run multiple servos at the exact same time on the arduino uno, i want to see if i could create a walking robot that could move its thigh,heel and foot to create movement
in total it would be six servos
could this work?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Mutlpe servos
« Reply #1 on: March 10, 2013, 12:51:41 PM »
Yes, it is possible and has been done.
Search the forums here for more info.

Also look up the Webbotlib code to make coding for multiple servos easier.

Offline vipulan12Topic starter

  • Robot Overlord
  • ****
  • Posts: 181
  • Helpful? 0
Re: Mutlpe servos
« Reply #2 on: March 10, 2013, 01:37:27 PM »
I am new to programming, so could you explain why exactly the webbotlib is helpful?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Mutlpe servos
« Reply #3 on: March 10, 2013, 04:24:12 PM »
It contains pre-written high level code to setup and use the Atmega's hardware features.

As I said, look it up. There is a lot of info in the SoR forums about webbotlib and how to use it.
Just type "webbotlib" in the text box at the upper right of this screen then click the 'search' button.

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: Mutlpe servos
« Reply #4 on: March 10, 2013, 05:08:41 PM »
If you're using a Arduino Uno, I think using the Arduino libraries and IDE is probably the easiest way to go, s it has many, many tutorials all over the web. For example, the Servo library lets you connect and drive up to 12 RC hobby servos (PWM) with reasonable performance. Not saying Webbotlib is bad, but if you're using Arduino specifically

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Mutlpe servos
« Reply #5 on: March 10, 2013, 07:01:38 PM »
Ok, what jwatt said is a better way to start learning.

Offline vipulan12Topic starter

  • Robot Overlord
  • ****
  • Posts: 181
  • Helpful? 0
Re: Mutlpe servos
« Reply #6 on: March 13, 2013, 07:40:02 PM »
could you send me sample code or something?
I am stuck on the programming aspect since if i were to code the servos normally it go in chronological order rather than the same time

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Mutlpe servos
« Reply #7 on: March 14, 2013, 02:27:59 AM »
could you send me sample code or something?
I am stuck on the programming aspect since if i were to code the servos normally it go in chronological order rather than the same time
Microcontrollers don't do anything at the same time, all is done sequentiality, however it is done so fast that it seams that everything is happening at the same time. Using dedicated PWM pins would be best, but that means that Your Arduino has to have 6 PWM channels. Also, driving many servos can be done by toggling IO pins with software, but, as far as I know, stability falls with extra workload added to microcontroller. You are lucky though, as Arduino Uno has 6 PWM pins, meaning that all 6 servos can be driven in hardware without having an impact on stability and main loop performance.

--> http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: Mutlpe servos
« Reply #8 on: March 14, 2013, 10:32:47 AM »
The Servo library for the Arduino uses interrupts and a single timer to drive up to 12 servos. It is *reasonably* stable. The code lets you configure the position the servos should take, and the library takes care of actually putting the servos there asynchronously from when you tell the library. So, you'll do something like:

- tell library to put pin 8 at position 1900
- do some work
- tell library to put pin 3 at position 1200
- tell library to put pin 4 at position 700
- do more work

The library will continually (every 30 milliseconds) send the latest set position to each of the pins. This means that pin 3 may actually be told to go to position 1200 right before pin 8 gets told to go to position 1900.
However, this is so fast (30 milliseconds is less than the duration of a single frame of film at the movies) that, from a human point of view, it looks simultaneous.

I highly suggest you try the built-in Servo library with your servos and Arduino. I think it'll work well for your application.

Offline olivthill

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Mutlpe servos
« Reply #9 on: March 15, 2013, 03:56:34 AM »
could you send me sample code or something?
I am stuck on the programming aspect since if i were to code the servos normally it go in chronological order rather than the same time
A sample code for 2 servos is shown at http://learn.parallax.com/node/179
You can see that the servo library is taking care of sending the required signals periodically. You just give an order once: a_servo.writeMicroseconds(a_number);. That order is repeated behind the scene, forever, until you send another order or detach the servo.

... The library will continually (every 30 milliseconds) send the latest set position to each of the pins.
By the way, this is rather every 20 milliseconds, as you can see on the diagram at Wikipedia, http://en.wikipedia.org/wiki/Servo_control and on the oscilloscope of the video How do RC Servos work? Part I .

 


Get Your Ad Here

data_list