go away spammer

Author Topic: Problem while programming 50$ robot  (Read 2155 times)

0 Members and 1 Guest are viewing this topic.

Offline FereTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Problem while programming 50$ robot
« on: December 29, 2009, 08:17:43 PM »
Hi there.
I built the 50$ robot using an ATMega168.
Now I try to modify my servos or run a simple program on my robot.

Like it is described here [ http://www.societyofrobots.com/robotforum/index.php?topic=7565.0 ] I created a new GCC project and included the SoR_Utils header:

Code: [Select]
#include "SoR_Utils.h"
int main()
{
LED_on();
while(1)
{
servo_left(50);
}
return 0;
}

Compiling the code is possible!

When I try to send the code to my ATMega everything is fine (the transmittion), but the robot doesnt act like he is supposed to do...

While sending the code the servo moves for a very short time, but after this nothing happens.
The LED is off and the servo isnt moving (although it is in a loop (code)...).

What is my fault?
Thanks for your help!
Greetings

Edit: I just noticed, that there is (sometimes) a quiet sound  produced by the servo. But it isnt moving...
Edit2: That strange! When I move the servo, it sometimes moves a little bit...
Edit3: Tried to reverse the LED (with a new one). Its still not working
Fere

Offline metaknecht

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Problem while programming 50$ robot
« Reply #1 on: December 29, 2009, 08:32:21 PM »
what did you want it to do?

on an unmodified servo, it would just move to its position, then stop moving

perhaps you want it to keep it spinning?

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Problem while programming 50$ robot
« Reply #2 on: December 29, 2009, 09:00:56 PM »
If you move the servo, does it move back to the first position?
Howdy

Offline rgcustodio

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 0
  • Use "Search" and ye might find answers!
Re: Problem while programming 50$ robot
« Reply #3 on: December 29, 2009, 09:20:22 PM »
@Fere
1) a servo has limited motion most have 180 - 210 degrees of motion only, unless you specifically buy a modified servo that can do continuous rotation.
2) the pulse width sent to the servo (in millisecond units) determines the direction of the motion. For example a 1.5ms pulse returns the servo to neutral position (most of the time 90 degrees). 1.25ms pulse rotates to 0 degrees. 1.75ms pulse rotates to 180 degrees. If you send the 1.5ms pulse while the servo is already in neutral position it will not do anything, same goes to the positions.

I think the servo used in the 50 buck robot is a standard servo, thus it can not do continuous rotation.
You mentioned in your original position that the "servo moves for a very short time", I assume the servo has also moved as far as it can go. So the loop is useless.
Try varying the pulse width.

HTH
The best thing one can do when it's raining is to let it rain. - H. W. Longfellow

understanding is the path to enlightenment

Offline FereTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Problem while programming 50$ robot
« Reply #4 on: December 29, 2009, 10:08:41 PM »
If you move the servo, does it move back to the first position?
Thats the problem: It doesnt!
It always moves a bit, but the same code (look above) does not move it to the same position.
Could someone give me a piece of code which should center it?
Then I could try wether the problem appears cause of my code or cause I did some configurations wrong...

Thanks a lot!

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: Problem while programming 50$ robot
« Reply #5 on: December 29, 2009, 10:10:28 PM »
Is the servo getting adequate power?
Howdy

Offline FereTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Problem while programming 50$ robot
« Reply #6 on: December 30, 2009, 09:22:38 AM »
Ok... I opened the servo and noticed that the motor is moving all the time. But if I touch the cable it instantly stops... Oo

But only if I touch it with my hands. If I use a screwdriver it continious moving...

I think it gets emough power. cause sometimes it moves very well and fast. And why should the power change ?  ???

Which code do I have to use to set the servo to his 0 position?
Thank you!

btw: Sry for my bad English. I know its a bit difficult to understand me :(
« Last Edit: December 30, 2009, 09:58:56 AM by Fere »

Offline FereTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Problem while programming 50$ robot
« Reply #7 on: December 30, 2009, 10:35:08 AM »
I figured out something new.
When I use servo_right(30) with an unmodified servo, it does not move to an position but move slowly to the right until it hits the maxi. angle. Then it stops.
So the value I give to servo_right does not change the aim-angle, but the speed it moves to max.
Which code should I use to set the servo to its 0 position?  ???

I copied and pasted (and tried understand) this code:
Code: [Select]
#define F_CPU 1000000        // 1 MHz
#define SERVOMAX 4377                //1,9ms => +100% => (F_CPU / 8 / 1000 * 1,9) -1
#define SERVOMIN 2533                //1,1ms => -100% => (F_CPU / 8 / 1000 * 1,1) -1
#define SERVOCENTER 3455            //1,5ms => 0% => (F_CPU / 8 / 1000 * 1,5) -1
#define SERVOFRAME 2500            //20ms => (F_CPU / 8 / 1000 * 20) -1

#include <avr/io.h>
#include <util/delay.h>

void init(void) {
     DDRB |= (1<<PB1) | (1<<PB2);    //OCR1x Ports auf Ausgang
   
    //Timer0, Mode 14 Fast-PWM, prescaler 8
   
    TCCR1A |= (1<<COM1A1) | (1<<COM1B1) |(1<<WGM11);
    TCCR1B |= (1<<WGM13) | (1<<WGM12);

    ICR1=SERVOFRAME;                //Impulswiederholzeit 20ms
    OCR1A=SERVOCENTER;                //Servo 1 Mittelstellung
    OCR1B=SERVOCENTER;                //Servo 2 Mittelstellung

    TCCR1B |= (1<CS11);

}

int main(void) {
    init();
    _delay_ms(1000);
    while(1) {
        //Servos auf MIN
        OCR1A = SERVOMIN;
        OCR1B = SERVOMIN;
       
        _delay_ms(1000);
       
        //Servos auf CENTER
        OCR1A = SERVOCENTER;
        OCR1B = SERVOCENTER;
       
        _delay_ms(1000);
       
        //Servos auf MAX
        OCR1A = SERVOMAX;
        OCR1B = SERVOMAX;
       
        _delay_ms(1000);
       
        //Servos auf CENTER
        OCR1A = SERVOCENTER;
        OCR1B = SERVOCENTER;
       
        _delay_ms(1000);
    }
    return(1);
}

In my opinion this code looks good, but the servo isnt moving like it does with servo_right(30).
What do I have to add?!
I posted the old values for Servomax etc. Of cause I changed them with F_CPU = 1000000
Do I
Thank you!
« Last Edit: December 30, 2009, 11:42:55 AM by Fere »

 


Get Your Ad Here

data_list