# $Id: README,v 1.5 2001/10/21 16:44:03 tramm Exp $

Read their input from the control pin as a pulse width modulated (PWM)
data stream.  This diagram is not to scale, but shows the two values
of interest:
   _____          _____          _____
__|     |________|     |________|     |_______________
  ^     ^        ^              ^
  |     |        |              |
  |     |        Frame rate is the distance between pulses.
  |     |        Most servos want 11 ms.
  |     |
  Pulse width controls the servo position.  It has a minimum and a
  maximum value.  This varies between servo manufacturers.  Some known:

	Brand		Min	Max (us)
	--------	---	---
	Futaba		1000	2000
	Cirrus		 400	2000
	JR		1000	2000

For an 8 Mhz system clock and 1 cycle instructions, we have roughly
0.125 us per instruction.  That allows us up to 3200 instructions for
the fastest Cirrus servo.  If we stick with the Futaba and JR servos,
we have a far more managable 12,500 instructions for the low end,
quite enough for the system to manage.

The task structure right now allows 256 us per cycle through the
dispatch loop.  That only allows four discrete servo positions,
which is far less than we need.  Clearly this approach will not
work.


A better approach is to use the PWM timers.  Since the servos can
deal with a frame rate of more than 20 ms and the maximum servo
length is 2 ms, 8 servos will give us a frame rate of only 16 ms.
So we cycle round-robbin through the servos, outputing a pulse
for the length of time required for each one in turn.  In psudeo
code:

	interrupt( pwm_count_finished )
	{
		zero the current servo output
		select the next servo
		bring its output high
		initialize the countdown timer for the proper length
		of time.
	}

	

Time critical tasks:
	Servo output
	Servo input (for the gyros)

Time uncritical tasks:
	Rate integration
	Serial input
	NMEA data stream


Wiring to the ports:
	A:		Gyros
	B:		LED's (on STK300)
	C:		Servos
	D:		Buttons (on STK300)
	E:		Unused (UART)

It appears that PORTE does all sorts of double duty and can not be
used for driving the servos.  See 13-89 in the big Atmel book.
So we use port C, which is output only for the 8 servos.
This is also convient for the 40 pin header cable.


