Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Lycus on July 19, 2008, 09:33:01 PM

Title: Servos not moving
Post by: Lycus on July 19, 2008, 09:33:01 PM
Hello Everybody,

I'm following the $50 robot tutorial, and have come apon a slight problem. I'm using an ATmega168, which from reading other posts, doesn't need any changes in the wiring, only a couple of changes in the makefile. I'm also using the AVR ISP2 programmer through AVR Studio, which tells me the ATmega168 is programmed correctlywhen I load the hold_servo.hex file:

Getting isp parameter.. SD=0x3e .. OKOK
Reading FLASH input file.. OK
Setting mode and device parameters.. OK!
Entering programming mode.. OK!
Erasing device.. OK!
Programming FLASH ..      OK!
Reading FLASH ..      OK!
FLASH contents is equal to file.. OK


Leaving programming mode.. OK!

My problem is that there is no output to the servos on the D pins. I've tried to read the output with a multimeter, via the ground line and the power line, but the is no reading at all. I'm 90% sure I have no shorts in the cicuit, so does that mean I've blown the microcontroller, or that the 10% that I'm unsure about the short is correct.

Thanks in advance for any help. BTW love the site!

Lycus
Title: Re: Servos not moving
Post by: bulkhead on July 19, 2008, 09:53:42 PM
Check if you have the right pins by setting them high, then measuring with a multimeter.  When the PWM signal is being generated, a multimeter can at best show a time average voltage.  For example, a 5V 1ms pulse sent every 50ms would be expected to show ~1/50*5V = 0.10V on a multimeter.
Title: Re: Servos not moving
Post by: Lycus on July 19, 2008, 11:06:15 PM
I've followed your instructions bulkhead, and the multimeter is reading 5V on the D port, so the microcontroller is fine, I assume. So it must be something else? Since I'm just using admin's code to hold the servo (HS-425BB, BTW), would the fact that it is a .hex file for an ATmega8 and not an ATmega168 make any difference? Or should I stop being such a lazy bastard and learn to programme the microcontroller from scratch!

Thanks for giving me a direction to follow though, very useful.
Title: Re: Servos not moving
Post by: Lycus on July 19, 2008, 11:43:39 PM
Thanks for the help, bulkhead. I found the problem, the CKDIV8 (divide clock by 8 internally) fuse was set. Once I turned it off, and reset the frequency of the ISP to 1.0 MHz, everything worked. Now I can continue and modify the servos. Yay!

Hold that. The servos spun using the test code in the photovore_v1.c file, however, when I loaded the hold_servo.hex file, nada. Would it have to do with the servo being an HS-425BB rather than an HS-311 or the fact that the ATmega168 is running faster than the ATmega8? I thought the only difference was the memory sizes between the two chips. Getting rather frustrated with this little issue. So close and yet so far :-\

Cheers
Lycus
Title: Re: Servos not moving
Post by: izua on July 20, 2008, 04:11:21 AM
IF you're running on 1 MHz you'll probably have to recompile the code for that crystal frequency. Not sure what the $50 robot uses as main clock frequency though. It's just easier to switch crystals, IMO.
Title: Re: Servos not moving
Post by: Admin on July 25, 2008, 09:41:06 PM
Quote
The servos spun using the test code in the photovore_v1.c file, however, when I loaded the hold_servo.hex file, nada. Would it have to do with the servo being an HS-425BB rather than an HS-311 or the fact that the ATmega168 is running faster than the ATmega8? I thought the only difference was the memory sizes between the two chips.
The hold_servo.hex file was compiled for the ATmega8. You need to recompile it for the ATmega168.

This is the modify servo code. Just put it at the top of your main loop, compile, and upload it to your bot.

Code: [Select]
while(1)
{
wheel_left(35);//modify this number so that servo is centered before being modified
delay_ms(20);
}