Servo Control with Microcontroller

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
aklaum
Posts: 3
Joined: Thu Jul 07, 2005 1:01 am
Contact:

Servo Control with Microcontroller

Post by aklaum »

Hello All,<p>I am new to a lot of things, electronics, embedded systems programming etc. Essentially I am just trying to get an Atmel AT89C2051 microcontroller to control one servo. <p>From what I have read a pulse of 1.5ms in a range of 50-60Hz should center pretty much any servo and particularly the Hobbico CS-60 I am using. <p>I have verified that I am getting the correct pulse with out of the output pin of the microcontroller with an oscilloscope (1.5ms at 55Hz). I get a nice square wave with 1.5ms pulses. I am running the microcontroller at 5v so it is a 0-5v pulse.<p>I have the yellow wire (control wire) of the servo hooked directly to the output pin. I have the red wire of the servo going to a 6v source (4 AA NiMh batteries) and the black wire going to ground.<p>When I turn on the circuit the servo rotates to its maximum rotation and sits there buzzing like it is trying to go even further rather then going to center like it is supposed to. <p>I have tried several different servos all with the same result. I am pulling my hair out at this point. Any ideas anyone has on troubleshooting this would be a great help. <p>Let me know if I need to provide more info.<p>Adam
Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: Servo Control with Microcontroller

Post by Newz2000 »

More info is always appreciated, I have found.<p>Have you tried switching to 50 Hz? Also, have you tried different pulse widths?<p>If Alpha == expert, I am Omega (furthest from Alpha), but since no one else has replied, and this is something I'm interested in, I'll chip in my $0.02.
ecerfoglio
Posts: 108
Joined: Thu Nov 25, 2004 1:01 am
Location: Buenos Aires Argentina
Contact:

Re: Servo Control with Microcontroller

Post by ecerfoglio »

Are the grounds of the tho power supplies (5 V for the microcontroler, 6 V for the servo) tied together??
E. Cerfoglio
Buenos Aires
Argentina
Gorgon
Posts: 325
Joined: Wed May 04, 2005 1:01 am
Location: Norway
Contact:

Re: Servo Control with Microcontroller

Post by Gorgon »

Hi Adam,
You say that you have pulses of 1,5 ms on your scope(positive pulses from 0v to 5v and back to 0v after 1.5 ms?), but what type of output are you using? If it is an open collector type of output you need a relative low ohm pull up, 2k2 or something like that.
The 55Hz is no problem, I think you can go down to about 12 ms period.<p>TOK ;)
Gorgon the Caretaker - Character in a childrens TV-show from 1968. ;)
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Servo Control with Microcontroller

Post by philba »

I've done servo control from a uC. I use a 20 mS window (50 hz) and 1-2 mS pulse. I believe most servos can handle up to a 10 mS window. 1.5 mS is neutral so the servo should center and stay there. I've never used a pull-up on the servo control line but then I have only driven servos with PICs.<p>Are you sure you have the wiring correct? If you reverse the wires, you would get a result as you described. Its pretty easy to reverse them (uh, speaking from experience...). Unfortunately, hobbico doesn't see fit to put any information about the wiring of the servo on its web site but it is supposedly compatible with hitec servos (hitec is the wiring style/color you described).<p>I would also double check your timing scale on the scope though I doubt you got it wrong the first time.<p>Phil
aklaum
Posts: 3
Joined: Thu Jul 07, 2005 1:01 am
Contact:

Re: Servo Control with Microcontroller

Post by aklaum »

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by ecerfoglio:
Are the grounds of the tho power supplies (5 V for the microcontroler, 6 V for the servo) tied together??<hr></blockquote><p>
um...gulp...no the grounds are not tied together. Please tell me it is that simple?
ecerfoglio
Posts: 108
Joined: Thu Nov 25, 2004 1:01 am
Location: Buenos Aires Argentina
Contact:

Re: Servo Control with Microcontroller

Post by ecerfoglio »

If the grounds are not tied together the servo does not "see" the pulse, so it moves to the end of its travel.<p>The servo must be connected to the battery (6V suply) (+ to the red wire, - to the black one), and to the microprocesor (output to the yellow wire, ground to the black wire).
E. Cerfoglio
Buenos Aires
Argentina
aklaum
Posts: 3
Joined: Thu Jul 07, 2005 1:01 am
Contact:

Re: Servo Control with Microcontroller

Post by aklaum »

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by ecerfoglio:
If the grounds are not tied together the servo does not "see" the pulse, so it moves to the end of its travel.<p>The servo must be connected to the battery (6V suply) (+ to the red wire, - to the black one), and to the microprocesor (output to the yellow wire, ground to the black wire).<hr></blockquote><p>Ok, a very hearty and very sheepish thank you thank you thank you. Talk about smacking the forehead. I connected the two grounds together and like a dream the servo went to dead center. When I breadboarded this thing I was so nervous about making sure the 6v and 5v power sources were isolated from each other that I completely forgot about common ground. <p>Going back to circuitry 101 now. Again, thanks a million.
Post Reply

Who is online

Users browsing this forum: No registered users and 162 guests