Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
servo_left(){PORT_ON(PORTD,4);delay_cycles(50);PORT_OFF(PORT,4);delay_cycles(200);servo_right(){PORT_ON(PORTD,5);delay_cycles(50);PORT_OFF(PORT,5);delay_cycles(200);
servo_left(){PORT_ON(PORTD,4);delay_cycles(50);PORT_OFF(PORT,4);delay_cycles(200);delay(X)
That clears things up a bit with the pulses and timing that need to be sent to the servo. I guess my next question would be around the internal clock speed of the Atmega16. The data sheet indicates that it comes from the factory with the internal oscillator running a 1mhz, a2d conversion takes place at 16mhz, but when I code and LED to blink with a delay cycles line of code I get ~25 cycles per ms.
I can't find the relation in those clock speeds, I've struggled with this in the past and got by so far. This probably explains the lack of speed control I'm seeing in the servos. Maybe someone could provide a little more insight into how the clock speeds affect things in the Atmega? Are there pieces of code that are run in the background that make the 1mhz clock appear as ~25 cycles per ms in my code? I'm only loading aver/io.h and avr.interrupt.h for libraries, I can't imagine these would take significant processor time once I enter the main portion of my code.
For the benefit of anyone who might search this in the future, this link was quite helpful in understanding the timer functions of the chip:http://tom-itx.dyndns.org:81/~webpage/abcminiuser/articles/avr_timers_index.php