Pages: [1] 2   Go Down
Author Topic: servo control  (Read 1738 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 29
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm using an arduino to do some servo control.  I have a PC
application that connects to the Arudino board through the
serial port.  I can then issue commands over the COM port
to tell the servo what to do.  Generally speaking this works
just fine.  The problem I have with it is startup.  
When I connect to the Arduino board, I activate DTR to start
the application, but I notice that this drives the servos nuts
for a few seconds.  My guess is that the PCM driving the servos is
interrupted by the restart and the GPIO pins I use go back to input
 mode momentarily.  At first glance, I'm guessing there's really not
 too much I can do about this because of the momentary transition
 out of the application back to the booloader which then restarts the
 app.  But then, I'm not really that familiar with this whole setup, so
maybe there is a solution...
Anyone?
Logged

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

You might try wiring external pull-down resistors between the pins that drive the servos and ground. Say 10k ohms, might help with the transistion period and cheap to try.

Lefty

Logged

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

Good idea...
Tried it, unfortunately, had no effect.
Logged

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

Hmmm..
I just reread the servo reference page, and it states:

>Note servos draw considerable power, so if you need to drive
>more than one or two, you'll probably need to power them from
>a separate supply (i.e. not the +5V pin on your Arduino). Be sure
>to connect the grounds of the Arduino and external power supply
>together.

I am driving three servos, but I do use an external supply, plugged
into the jack on the arduino board.  I do have my servos connected
to +5v on the arduino, and I did not do any wiring to strap the
external power supply ground to arduino ground.  I took for granted
that these were the same point.  Now I'm guessing that this is
 wrong...???

Also, by the way, I notice that plugging/unplugging other USB devices
into my PC cause the servos to occasionally go haywire.  I have this
arduino board on a separate powered hub, and I apply the additional
external powersupply to the arduino, so I'm kinda surprised at that.
« Last Edit: May 05, 2010, 07:35:47 am by edsut » Logged

Vejen, Denmark
Offline Offline
Edison Member
*
Karma: 9
Posts: 1178
RAWR! ^,..,^
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I do have my servos connected to +5v on the arduino
Don't do that.

Make your own little circuit for the power to the servo's. So you only use the arduino for signal, and your own circuit for powering the servo.
Logged

captain-slow.dk | non contagious!

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

Hmmm..
If I'm using a 9v external wall-wart powersupply, anyone know
if that's too much voltage to directly power the servos?  All I read
is that the servos run between 4.5 and 6V, so I guess I need an
additional regulator (or voltage divider at least) to get 6V?
Logged

Vejen, Denmark
Offline Offline
Edison Member
*
Karma: 9
Posts: 1178
RAWR! ^,..,^
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

9V is too high, so yeah, you need something to get it down.
Logged

captain-slow.dk | non contagious!

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

4 alkaline batteries.  Bigger battery with a voltage regulator.  Bunch of possibilities.  Just make sure to:

Tie the ground to the Arduino ground and to all the servo grounds.
Tie the hot to all the servo hots.
The data pins go to each servo signal.

This will work for any power source in the proper voltage range.

I used a Bigger Lithium Polymer battery and a voltage regulator to get proper voltage for my servos.  But it is pretty much the same as using 4 AA batteries.

Here is a thread with more info about how I did it.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265626147/6#6

In the first picture, you can see the orange and green wires.  They carry the signal from the 18 pins to the servo plugs.  Power comes from the 2 wires running off the shield.
Logged

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

First, before I continue, I just wanna say thanks for the responses.
Great forum!
Ok, now back to the problem...
I found a 6V supply, and rewired the power for the three servos to
that line, plus I have grounds tied together.  I also have 10k pull-down
resistors on each of my servo signal lines (to help with the transition
from powerup to servo.attach()).
That being said, it appears that I can now plug in/out other USB
devices  on my PC and this no longer affects my servos.
Unfortunately, that's the only good news.
I still have a glitch each time I connect to the PC com port.  My
guess is that this is caused by the transition on DTR, so I could
disable that; however, it seems like a good thing to have the board
 reset when I first connect to it.
Plus, the other problem is that at startup you don't know what the
position of the servo is, so when you do the initial attach how do
you keep the servo from potentially slamming to the startup position?

So, I have two problems (sorry about the verbosity):
1. Glitch at startup (servo just jumps a few degrees.  this happens
    even with an empty setup() loop())

2. How do you gently sync up the initial position you set your servo to
    with the actual position the servo is at?  For example, if my servo
    just happens to be at 180-degrees and I start up and want to
    initialize things to 90 degrees it will just "SLAM" over from 180 to
    90 because I can't tell where the servo is at startup.

Again, thanks for all the input.
BTW, I'm using pins 9, 10 & 11 for servo control.  Are there preferred pins for this?
Logged

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

So, I have two problems (sorry about the verbosity):
1. Glitch at startup (servo just jumps a few degrees.  this happens
   even with an empty setup() loop())

 I think you just have to live with that. Even when used in radio control systems, the servos twitch a little on initial power up.

2. How do you gently sync up the initial position you set your servo to
   with the actual position the servo is at?  For example, if my servo
   just happens to be at 180-degrees and I start up and want to
   initialize things to 90 degrees it will just "SLAM" over from 180 to
   90 because I can't tell where the servo is at startup.

As there is no independent position feedback from the servos to the Arduino, there is no way to know what position the servos are at when first powered up, therefore no way to smoothly transition to a desired starting position. If it's an important safety or application requirement then about the only thing you could consider is adding some kind of analog position feedback pot to the servo's output wheel or linkage, then you could read it's position and decide which direction and how fast to command to the desired start-up position.

Lefty
Logged

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

I agree regarding the initial position issue (needing some kind of
position encoder on the servo); however, I still wonder if there is
more I could do to reduce/eliminate the startup glitch...
The glitch is apparently caused by the change in state on the signal
line.  I'm reasonably certain of this because the 6v supply I'm now
using for servo power is always on.
So, assuming DTR does a reset on the CPU, the IO lines that end up
being servo control signals are initially inputs, and the pull-downs
on those pins would keep those lines low from the servo's point of view
(right?).
Since I still see this glitch even if I don't call servo.attach() in my
arduino app, doesn't that imply that the bootloader must be doing
something with these lines momentarily?
I guess my long-winded question here is this:
Is it possible that a bootloader modification would cure this?
Logged

Vejen, Denmark
Offline Offline
Edison Member
*
Karma: 9
Posts: 1178
RAWR! ^,..,^
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The servo motors will even move back when you just give them power without a signal. They should then just move to their middle position.

Maybe a fix could be to make the arduino control when they get power? So it can set the signal, and then pull a relay to give them power. But still not sure if that would work.
Logged

captain-slow.dk | non contagious!

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

Quote
Since I still see this glitch even if I don't call servo.attach() in my
arduino app, doesn't that imply that the bootloader must be doing
something with these lines momentarily?
I guess my long-winded question here is this:
Is it possible that a bootloader modification would cure this?

I don't think so. The processor internal hardware logic just defaults to all I/O pins go to input mode (floating) on power up or reset cycle. The bootloader I don't think does anything to pins other then serial in and out and pin 13.

 Look at from the servos perspective. When it powers up, but has no valid command PPM pulse arriving what should it do? That is a undefined state and servos can only do what they see coming from the signal wire. Most I have worked with, in that condition, just twitch a little but stay in the position they are already at. That is if mechanically unloaded. If there is a heavy mechanical load and no PPM pulse arriving it's possible for the load to move the servos initial position, but that depends on the load, gearing, etc.

 Again if initial position at power up is important then you will have to add some kind of feedback measurement, otherwise you just have to live with commanding to a initial known starting position.

Lefty
Logged

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

Quote
The servo motors will even move back when you just give them power without a signal. They should then just move to their middle position.

I don't believe that is a true statement. A servo will not default to it's middle position unless it is receiving 1.5msec PPM pulses on it's signal line. There is no default position for servos that have no PPM pulses being sent to them.

Lefty
Logged

Vejen, Denmark
Offline Offline
Edison Member
*
Karma: 9
Posts: 1178
RAWR! ^,..,^
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't believe that is a true statement. A servo will not default to it's middle position unless it is receiving 1.5msec PPM pulses on it's signal line. There is no default position for servos that have no PPM pulses being sent to them.
hmm, I got four that does it.
Logged

captain-slow.dk | non contagious!

Pages: [1] 2   Go Up
Jump to: