Johnny said:
FPGA is not necessary. The AVR has 16 bit timer with two 16bit
compare registers and interrupts. I suggest this application can be
implemented by sorting the array of 16 channels into sequence of
pulse
width, and then just reloading the same compare register. The
second 16bit comapare register can be used to reload or clear the
timer, and
thus determine the timebase. The AVR is plenty fast enough to make
this work, especially the new mega series that process 16MIP/s @
16MHz, but codevision compiler is a bit of a handicap. Imagecraft
make a much more efficient one. Never tried any gcc though.
IMO it is not that simple ;-(
If you start all pulses at ones, you get trouble if some servos have
(almost) equal pulse lengths.
The classic way to avoid this would be to send one pulse after the
other. However, a servo requires a pulse every 20ms. So you can do at
most 10 servos in sequence, no matter how hard you optimize the code.
I would suggest one of the following:
1) One interrupt every 20ms that starts all pulses. Another interrupt
1ms later, here you do a hand-timed loop that stops the pulses one by
one. The drawback is that you are in a loop (with disabled
interrupts) for 1ms, i.e. that you shouldn't use 19.2kBaud or higher
for UART (or SPI).
2) Start pulses in turn every 1ms. Problem here is, that you don't get
pulse lengths near 1ms and near 2ms.
The choice depends on the application.
BTW: Every interrupt (other than pulse generation) has to be
interruptable to achieve the desired accuracy.
Jan-Hinnerk