Control of Servo Motors

Hi, I am posting this on behalf of a friend who has been unable to log onto the news server :( and advice would be much appreciated.

If further info is needed please let me know. Here goes:

Hi I am trying to control a swinging mechanism using 2 HS-300 servo motors. To control these I am using a 16F873 microcontroller with a 4 MHz crystal. I am using a program called MPLAB and I was wondering how to control the servo Motors.

(The problem I think is how to turn the servo to different positions using MPLAB)

Thanks,

Emma

Reply to
Emma Wignall
Loading thread data ...

I know nothing of MPLAB, so I'll pretend you didn't mention it and tell you more than you ever wanted to know about radio control servos. Hopefully knowing what's supposed to be coming out of the PIC will help you understand where things are breaking down.

All "RC" servos on the market today are controlled with a logic-level pulse who's on-time sets the servo position. The industry nominal pulse width is

1 to 2 ms, with 1.5ms being center. The pulse repetition rate is around 50-60Hz. You can generate an appropriate pulse train with a 555 timer chip or an appropriate signal generator and watch the servo wheel rotate when you twiddle the right knob.

If the HS-300 is an "analog" servo it operates by stretching the input pulse and comparing it to a pulse who's width is controlled by the feedback pot inside the servo. Because of the pulse stretching there'll be a maximum rep rate for any given servo which, if you exceed, the servo will get jittery and "hum". If the HS-300 is a "digital" servo then it operates in whatever manner it's particular software engineer decided to make it work. By rights it _should_ be able to cope with any rep rate, but I don't have experience with these new-fangled devices so I don't know if it will, or if it varies by manufacturer.

Good luck.

------------------------------------------- Tim Wescott Wescott Design Services

formatting link

Reply to
Tim Wescott

Your problem involves at least two distinct tasks. you have to program a digital output for each servo to generate the pulse width modulated signal appropriate to the servos you are using. You might use the PWM output function of the PIC for this, but its durations are long enough that you can use an internal counter/timer to make these timing decisions in code. Then you have the problem of deciding what position you want to command the servos to go to at any particular moment. And that depends on the purpose for having the servos, in the first place, which you have not told us anything about. This is an arbitrarily complicated task.

You may be able to find some sample code involving servo control in Microchip's application notes:

formatting link

Reply to
John Popelish

As John P. said, this is an arbitrarily complicated problem. Most people in the industrial control business control servo motors using off-the-shelf servo control products. These are either stand-alone boxes, or else they are plug-in motion control boards in a PC or PLC. In any case, the job they do in quite involved. They control a primary output drive to the servo motor based on closed-loop calculations for either velocity or position, and based on a number of tuning parameters, usually PID. This is not the kind of thing to do yourself unless you are just playing around and want to learn, or you are designing a high-volume product that can justify original development of a motion control system. All that MPLAB gives you is a software development environment (usually assembler) for the various Microchip microcontrollers. It is kind of like asking how to use a pencil to write the next best-selling mystery novel. Knowing how to use a pencil does not go very far in reaching that ultimate goal.

If your friend still wants to proceed, then have him ask specific questions like how does one read an incremental encoder using a PIC and such-and-such interface chip, or how does one generate a PWM signal to drive a power driver for servo motor. For the PWM question, I recommend a thorough reading of the relevant PIC data sheet. Many of these PICs have specific hardware built-in for PWM generation.

Hope this helps..

-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)

Reply to
Robert Scott

The servo that is mentioned in the original post is one used in radio control aircraft, cars, etc. They're nice self-contained units that take their position command from the width of an "on" pulse -- so all you need to know is how to diddle the command wire. There really isn't and real "servo" knowledge involved.

address is fake.)

>
Reply to
Tim Wescott

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.