EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Is the HCS12 (E128 is mine) able to drive/control servos??

Started by gogosgeorge March 18, 2005

Hi guys,

Is the HCS12 able to control servos? Im using a remote control car
which has 2 servos already, but I need to use another servo (or
control the existing one) running from the 9S12E128 to control the
voltage pot on the cars rmote control transmitter. Im still after
full control of acceleration and steering off the remote, but the
other servo needs to set a limit so the cars acceleration cant go
past a certain point (i.e. limiting the remote cars speed)

So.....I guess I need to know if I can do this with a servo and the
MCU...cheers




Re: Is the HCS12 (E128 is mine) able to drive/control servos??
Hi gogos, I think again google may be your friend. I bet if you google
"HC12 servo," you will find lots of links. To get you started, you use PWM
to control the servos. the E128 may have builtin PWM. If not, you can bit
bang it using output compare etc.

Again, google is your friend and you should find the info you need. They
may be not specific to the E128, but chances are they may use the HC11 and
the idea is the same.

Good luck.

At 06:43 PM 3/18/2005, you wrote:
>Hi guys,
>
>Is the HCS12 able to control servos? Im using a remote control car
>which has 2 servos already, but I need to use another servo (or
>control the existing one) running from the 9S12E128 to control the
>voltage pot on the cars rmote control transmitter. Im still after
>full control of acceleration and steering off the remote, but the
>other servo needs to set a limit so the cars acceleration cant go
>past a certain point (i.e. limiting the remote cars speed)
>
>So.....I guess I need to know if I can do this with a servo and the
>MCU...cheers

// richard (This email is for mailing lists. To reach me directly, please
use richard at imagecraft.com)



Haven't dealt RC servos for a while, but I recall that they respond
to a PWM signal that is high in the range of very roughly 500 to 2000
microseconds, at a rate of about 50 or so such signals per second.
The position of the servo is proportionate to the high pulse width,
500 microseconds is near one travel limit, 2000 microseconds is near
the other. Some servos can range wider than others, some go crazy if
you try to drive them too far. If you are sending control signals
through a transmitter you can also control several servos
on a single PWM channel, by lining up several pulses of different
widths at close intervals.

But your best bet is good ol'google, as Richard suggests. Also, if
you have an oscilloscope hook it up to the signal feeding from a
receiver to the servos, you will learn much. If you have a
transmitter with a "driver training" cable output, take a look at
those signals because they show you how to string several servo
control pulses on a single channel. Unfortunately the E series have
PWM's that are a little different than other 9S12's, keep that in
mind when looking through examples. Frankly, you might be better off
with just about any other 9S12 family for driving RC servos.

One suggestion...drive the servos through some sort of buffer like a
74HCT245 to protect your micro from short circuits, static discharge,
off-volatage servos, etc. Wiring inside a model can get a little
crazy sometimes. Servo control signals must also drive both high and
low, you can't use open collector or open drain.

In your software you can put a cap on the maximum speed by simply not
letting the control pulse width go outside a certain value.

Lots of interesting things to be done with servos and a micro. For
instance, you can memorize control sequences in RAM (or generate them
algorithmically) and play them back at the push of a button. They're
much more fun than blinking LEDs.

Bill T.
http://www.kupercontrols.com

> >Is the HCS12 able to control servos? Im using a remote control car
> >which has 2 servos already, but I need to use another servo (or
> >control the existing one) running from the 9S12E128 to control the
> >voltage pot on the cars rmote control transmitter. Im still after
> >full control of acceleration and steering off the remote, but the
> >other servo needs to set a limit so the cars acceleration cant go
> >past a certain point (i.e. limiting the remote cars speed)
> >
> >So.....I guess I need to know if I can do this with a servo and the
> >MCU...cheers




George,

In addition to the PWM unit that others have recommended, the timer unit
can generate PWM as well, though it may require some more software effort
than the PWM unit does.

In other words, if the PWM has enough channels to control your servos,
use it. If it doesn't, you could look into using the timer in output
compare mode to generate additional channels.

Stephen

--
Stephen Trier
Technical Development Lab
Cleveland FES Center



The 2024 Embedded Online Conference