Society of Robots - Robot Forum

Software => Software => Topic started by: javila on September 20, 2010, 10:48:56 PM

Title: webbotlib with servos
Post by: javila on September 20, 2010, 10:48:56 PM
hello:
I am having some issues with webbotlib controlling one servo. I have an atmega328 with a crystal of 18.43Mhz, if I try to  program the microcontroller to use the servo from the laptop(Xbee) then the microcontroller keeps reseting everytime I try to move the servo.
 Then I decided to change the fuses back to use the internal 8Mhz crystal and the servo works perfectly. but everytime that I go back to using the crystal it does not. If I use a 20Mhz crystal it works fine. Can anybody tell me why is this happening?
I have used the microcontroller with the 18.43 Mhz crystal to receive information from the blackfin and it works fine, so the crystal itself does not seem to be the problem.
I am using a baud rate of 115200 which is the one the blackfin uses and the 18.43Mhz crystal was selected to eliminate the error with that baud rate (datasheet).
And yes everytime I change from crystal to crystal and internal crystal I change the project configuration the reflect the new speed.
Any help???
Just in case, if I use the 20Mhz crystal with the blackfin, is the -1.4% error in the transmition that is shown on the datasheet something to worry about???
thanks in advance.
Title: Re: webbotlib with servos
Post by: Admin on September 25, 2010, 02:03:19 PM
Quote
then the microcontroller keeps reseting everytime I try to move the servo.
Simply changing the crystal, or the timing, won't cause a reset.

When a servo is commanded to move, it'll cause a power drain. If the power drain is too high for your battery, voltage drops, and it'll cause a mcu reset. A servo PWM, if programmed to be too fast, can greatly increase the power a servo requires . . . your servo will vibrate a lot, overheat, and burn out.

In other words, it sounds like a power supply issue with your circuit ;D
Title: Re: webbotlib with servos
Post by: Webbot on September 25, 2010, 02:14:09 PM
Are you using hardware PWM or software PWM to control the servo?

Once I know then I'll take a look under the AVR simulator to see whats happening.

Note on crystals: IMHO its always best to use a power of 2 ie 1MHz, 2Mhz, 4MHz, 8MHz, 16Mhz etc. The reason being that the crystal frequencies are normally divided down by timers etc by a power 2 and so will always give a much better accuracy than a non power of 2 like 18.43Mhz.