NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Servo not responding.

January 05, 2010
by Solorbob
Solorbob's Avatar

I found a project that uses a servo, so I thought I would hook one up to my nerdkit to see what I could learn. I used the same setup as the LED example with the servo control going to MCU pin #16. Servo was plugged into the 5v Vcc and Gnd. I tried both the servo squirter code as well as the example code that lcruz007 posted back in October.

The servo just pulsed in one direction and "ba" kept writing to the HyperTerminal screen with each pulse.

I will try again to see if I get the same results.

Thanks, Shawn

January 05, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Solorbob,

"ba" coming over the serial port means your chip is restarting. The bootloader sends "b" when it is about to run the bootloader, then "a" when it is about to run the application. Most likely you have a low battery, or something misswired, such that when the motor attempts to turn the voltage drops and the chip resets. This ends sending "ba" again. Hope that helps.

Humberto

January 05, 2010
by Solorbob
Solorbob's Avatar

Thanks Humberto,

I did find that I had to keep wiggling my Vcc wire going to the voltage reg to get it to accept the code upload. I bet that is the problem. I'll solder a wire to it and try again.
Thanks for the fast reply.

January 05, 2010
by Solorbob
Solorbob's Avatar

I adding a piece of wire to the battery clip leads which took care of the problem. Thank you very much.

January 05, 2010
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Would one of you kind gentlemen please give me a quick rundown on hyperterminal and connecting to the mcu. The one I got is only good for phones?? thx

January 06, 2010
by Solorbob
Solorbob's Avatar

I found the info on the hyperterm in the servo squirter project. Here is the link http://www.nerdkits.com/videos/servosquirter/

November 16, 2010
by kapkunal
kapkunal's Avatar

Hi, i am working on a robotic arm project. i tried to rotate the servo, but it didnt rotate. plz tel me what prescalar should i take..as the clock frequency is 14745600. i have EXI 312f servo. also plz tel me can i change the crystal to change the clock frequency. i used the following program:

// servosquirter.c
// for NerdKits with ATmega168
// mrobbins@mit.edu

#define F_CPU 14745600

#include <stdio.h>

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/uart.h"

void main()
{
      TCCR1A = (1<<COM1B1) | (1<<WGM11) | (1<<WGM10);
      TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS11);
      OCR1A = 36864;    // sets PWM to repeat pulse every 20.0ms

       DDRB|= (1<<PB2);   //PWM Pins as Out

   while(1)
   {

      OCR1A = 1844; //0 degree
      OCR1A = 2765; //90 degree
      OCR1A= 3686; //180 degree

   }
}

also tel me if this is correct??

November 16, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi kapkunal,

Please take a little time and go over the protocol for talking to servos again, and how we do that with the PWM out put on the chip. The video tutorial for the servo squirter is a great place to start. Particularly focus on how we have both a TOP value which is set by OCR1A to set the 20ms repeat rate. We then use OCR2B to actually do the PWM output, and create a 1-2ms pulse. You are going to want to leave OCR1A alone, and vary OCR2B to change the position of your servo.

You also definitely also want to add some delays in your code between the positions so the servo has time to get to the next position.

If I were you I would use an LED on the PWM output at first to make sure you have the PWM output correct before putting your servo into the loop.

Humberto

Post a Reply

Please log in to post a reply.

Did you know that spinning a permanent magnet motor makes a voltage? Learn more...