[En-Nut-Discussion] Control function to drive a RC servo
ptlinux
ptlinux at optushome.com.au
Sun Jun 8 04:45:42 CEST 2003
Hi,
I am trying to write a simple application for controlling a RC Servo
using the Digital Output on Ethernut.
The characteristic of the Servo is controlled by the period of the
square wave. With 5V pulses of 1.5 (peak) ms is neutral (Centre
position) with 2.0 ms and 1.0 ms controls the left and right extreme of
the horizontal movement. The period of the pulse should be around 20ms.
I have modified the Portdio.c to create the square wave required. I am
not sure if it is going to work?!
outp(0xf0, DDRD);
outp(0x0f, PORTD);
mask = 0x10;
for (;;)
{
outp(inp(PORTD) | mask, PORTD);
NutSleep(2); // this should move the camera to
one extreme.
outp(inp(PORTD) & ~mask, PORTD);
NutSleep(20); // produce a delay of 20ms. pull
down.
}
Will this code work?!
I have created a thread to run this. is that the right way to do it?!
Do I need to use timers? I am not too familiar with timers?
Hope someone can put me into the right direction.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20030608/d61ec381/attachment.html>
More information about the En-Nut-Discussion
mailing list