by tum » Mon May 19, 2008 6:48 pm
by tum
Mon May 19, 2008 6:48 pm
i-Bot wrote:The firmware is totally dependant on clock speed with lots of software timing loops. Higher clock speed could be used with new firmware, but backwards compatibility would be lost unless speed was switched.
Yeah my goal is to rewrite the firmware and provide an open source C library for dynamic feedback & control.
Assuming the hitec servos really can be used at 19200, I've done a few calculations.
Assuming clock speed of 7372800 Hz
And baud rate of 19200
So we get 7372800/19200=384 clock cycles per bit
It takes 9 clock cycles to bang a single bit in assembly
So we get 384/9=42 bits we can bang simulataneously
Which basically means we have the CPU power to control 42 servos simultaneously.
Now assuming we're only using 24 servos, we have 168 clock cycles free every time we write a bit. Those clock cycles are wasted and we use them to time the bit bang.
Now, a write pos takes 70 bits, a read packet takes 70+70 bits. That's 210 bits for every servo. That gives us a refresh rate for each servo (assuming every refresh we're writing a position and getting a reading of the position) of 91Hz.
We probably want to be processing other things so we will end up with less than 91Hz.
I guess if we use a timer (for the 168 clock cycles between bits) then we can use the spare time to process stuff. I'm not yet sure how many clock cycles setting up a timer and responding to a timer takes so it might not be worth the trouble. Another better option might be to use the 168 clock cycles to perform ADC caching on all the inputs (I'm not sure if you can do ADC synchronously and not sure how many clock cycles it would take).
Another idea is to only send the position information every few seconds (to take care of unplugged/replugged servos). This would increase the refresh rate by 33%.
Using a 16Mhz Atmega AVR128 or reducing usable servos to 18 (pretty reasonable) would make things fit more comfortably.
All this ofcourse assumes that the hitec servo serial interface does work as expected and is not simply an advertised but nonfunctional feature! Errors (etc) would have to be taken care of which would take more clock cycles and would have to be carefully tuned.
i-Bot wrote:The firmware is totally dependant on clock speed with lots of software timing loops. Higher clock speed could be used with new firmware, but backwards compatibility would be lost unless speed was switched.
Yeah my goal is to rewrite the firmware and provide an open source C library for dynamic feedback & control.
Assuming the hitec servos really can be used at 19200, I've done a few calculations.
Assuming clock speed of 7372800 Hz
And baud rate of 19200
So we get 7372800/19200=384 clock cycles per bit
It takes 9 clock cycles to bang a single bit in assembly
So we get 384/9=42 bits we can bang simulataneously
Which basically means we have the CPU power to control 42 servos simultaneously.
Now assuming we're only using 24 servos, we have 168 clock cycles free every time we write a bit. Those clock cycles are wasted and we use them to time the bit bang.
Now, a write pos takes 70 bits, a read packet takes 70+70 bits. That's 210 bits for every servo. That gives us a refresh rate for each servo (assuming every refresh we're writing a position and getting a reading of the position) of 91Hz.
We probably want to be processing other things so we will end up with less than 91Hz.
I guess if we use a timer (for the 168 clock cycles between bits) then we can use the spare time to process stuff. I'm not yet sure how many clock cycles setting up a timer and responding to a timer takes so it might not be worth the trouble. Another better option might be to use the 168 clock cycles to perform ADC caching on all the inputs (I'm not sure if you can do ADC synchronously and not sure how many clock cycles it would take).
Another idea is to only send the position information every few seconds (to take care of unplugged/replugged servos). This would increase the refresh rate by 33%.
Using a 16Mhz Atmega AVR128 or reducing usable servos to 18 (pretty reasonable) would make things fit more comfortably.
All this ofcourse assumes that the hitec servo serial interface does work as expected and is not simply an advertised but nonfunctional feature! Errors (etc) would have to be taken care of which would take more clock cycles and would have to be carefully tuned.