go away spammer

Author Topic: $50 robot programing  (Read 4988 times)

0 Members and 1 Guest are viewing this topic.

Offline ert481Topic starter

  • Jr. Member
  • **
  • Posts: 32
  • Helpful? 0
  • yo young?
$50 robot programing
« 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
« Last Edit: August 07, 2008, 05:34:13 AM by ert481 »
young people can build robots to!!!

Offline dsheller

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 0
Re: $50 robot programing
« Reply #1 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

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: $50 robot programing
« Reply #2 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!




Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline Kohanbash

  • Supreme Robot
  • *****
  • Posts: 430
  • Helpful? 1
Re: $50 robot programing
« Reply #3 on: August 07, 2008, 06:41:50 AM »
Also if you post what the errors/error messages are we can help you debug it
Robots for Roboticists Blog - http://robotsforroboticists.com/

Offline ert481Topic starter

  • Jr. Member
  • **
  • Posts: 32
  • Helpful? 0
  • yo young?
Re: $50 robot programing
« Reply #4 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
young people can build robots to!!!

Offline dsheller

  • Full Member
  • ***
  • Posts: 72
  • Helpful? 0
Re: $50 robot programing
« Reply #5 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);
}
« Last Edit: August 07, 2008, 07:21:45 AM by dsheller »

Offline ert481Topic starter

  • Jr. Member
  • **
  • Posts: 32
  • Helpful? 0
  • yo young?
Re: $50 robot programing
« Reply #6 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?
« Last Edit: August 07, 2008, 08:05:10 AM by ert481 »
young people can build robots to!!!

 


Get Your Ad Here