Write some code and try the demo versions. Using AvrStudio to
simulate the code operation, its easy to time the code execution using
the timer in the 'processor' window. When I tried this, with my
sample code I found the Imagecraft compiled code was smaller and
executed about twice as fast as the some code compiled with
codevision. Imagecraft have 45 day evaulation version, and I think
codevision offer something similar.
AVR studio compatibility is something you should also investigate. I
have heard that Imagecraft is better than the others in this regard,
but only used codevision with Version 3 of avr sudio. Avr Studio
4.07 is not 100% stable though (can say the same for V3.56 also), so
it is difficult to tell if the problem is with the compiler listing
file compatilibility, or some bug in avr studio.
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.
On the other hand, if you have two timer compare registers, you can
be sending two pulses at a time; this lets you run two sets of up
to 10 servos each in the allotted 20ms, which is is enough to do
what the original poster wanted.
10-bit accuracy corresponds to about 1us of pulse-length accuracy,
or about 16 instructions at 16MIPS. As long as the interrupt latency
has less jitter than that, it should be ok.
Wim Lewis < email@example.com>, Seattle, WA, USA. PGP keyID 27F772C1
You will get problems when both interrupts overlap, because you can
only execute one ISR at a time. However, I'm not sure that 10-bit
accuracy is needed (is the servo really able to act that accurate???)
@Pang Fu: Do you really mean 10-bit accuracy on the output variation,
i.e. 1024 different servo positions?
Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here.
All logos and trade names are the property of their respective owners.