Society of Robots - Robot Forum

Software => Software => Topic started by: ert481 on August 07, 2008, 05:28:08 AM

Title: $50 robot programing
Post by: ert481 on August 07, 2008, 05:28:08 AM
I need to know how to make the $50 robot to go straight, turn left  and do a couple of other things. I posted another forum about this and thought i had it all figured out but then i started getting errors. i don" want pseudocode or whatever that is. i only want things like this:

{
servo_left(44);
servo_right(44);
}

nothing like this either.

robot_go_straight();

this is what i have: (i have everything else that admin had in hiscode i just deleted the servo part and  return0)

   while(1)
      {
      //store sensor data
      sensor_left=a2dConvert8bit(5);
      sensor_right=a2dConvert8bit(4);

      {
      servo_left(25);
      servo_right(44);
      }
   
      delay_cycles(10   i tried doing more   );

      {
      servo_left(39);
      servo_right(35);
      }

      }
   

   }


ive spent three night messing around with this and i still can't get it to work :P
Title: Re: $50 robot programing
Post by: dsheller on August 07, 2008, 05:40:10 AM
So you don't want pseudo-code? Essentially you want us to do your project for you, I'm all for helping but I'm not going to explicitly write code for you for something so simple that you should be able to experimentally figure it out. Sorry to come off so harsh, but if you want to continue building robots, or any electronics really, you need to learn to experiment and figure out things based off your experiments. I will tell you what i'd do though...

+ throw out the sensor variables,  you don't need them if you're just making the bot turn drive straight etc, and they're just wasted cycles

+ Now, because I've never built the $50 robot I don't know what the servo_left ( int ) and servo_right ( int ) functions will necessarily do... so go to that function and figure out what it does, once you understand that function everything else is just mechanics that you can figure out with a little math and some experimentation
Title: Re: $50 robot programing
Post by: Kohanbash on August 07, 2008, 06:40:32 AM
Hi
Go back and reread the other post. http://www.societyofrobots.com/robotforum/index.php?topic=4897.0

As pomprocker pointed out you probably dont want to use servo_left(int) since there are already functions available such as robot_turn_left.

You need to look in the SoR_Utils.h file to see what those functions are!




Title: Re: $50 robot programing
Post by: Kohanbash on August 07, 2008, 06:41:50 AM
Also if you post what the errors/error messages are we can help you debug it
Title: Re: $50 robot programing
Post by: ert481 on August 07, 2008, 07:01:16 AM
i looked at that  SoR_utils.h file. it didn't have:   robot_turn_left();   etc.

and dsheller i don't want want you to write the code for me. i just want you to try it and tell me if you can get it to work because i've tried working with it and i could never get it to work. so if you get it to work you can tell me and then i'll know what i'm doing wrong
Title: Re: $50 robot programing
Post by: dsheller on August 07, 2008, 07:19:59 AM
Here is a post I found on google by pomprocker from early in July...
http://www.societyofrobots.com/robotforum/index.php?action=printpage;topic=4650.0

But here is the code he is using at 1 MHz, if you want it to work at 8 MHz multiply the constants by 8... I reallly don't know what you're running your Micro at, you'll have to figure that out.

Code: [Select]
void servo_left(signed long int speed)
{
PORT_ON(PORTD, 2);
delay_cycles(speed);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);
}

void servo_right(signed long int speed)
{
PORT_ON(PORTD, 3);
delay_cycles(speed);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);
}

void robot_turn_left(void)
{
servo_left(25);
servo_right(25);
}

void robot_turn_right(void)
{
servo_left(44);
servo_right(44);
}

void robot_go_straight(void)
{
servo_left(25);
servo_right(44);
}

void hold_position(void)
{
servo_left(39);
servo_right(35);
}
Title: Re: $50 robot programing
Post by: ert481 on August 07, 2008, 07:22:25 AM
the only things in SoR_utils.h is the top two ;D

in avr studio is it supposed to be on AVR simulater? or something else?