Author Topic: circling robot?  (Read 6304 times)

0 Members and 1 Guest are viewing this topic.

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
circling robot?
« on: April 25, 2009, 05:14:50 PM »
Im building the $50 robot (the roboduino version) and I programmed it following the tutorial and it appears to be right but when i power it up it just goes in circles. One servo rotates quickly and the other rotates in the same direction but much slower
I searched and everyone who has problems like this are different, like with one servo rotating in the opposite direction or one not working at all etc.

I cant pin down the problem. The programming seemed to go ok so I dont think its that. The photoresistors might be messed up. I plugged it into the roboduino board at the "analog in" pin 0 and 1 and it doesnt effect it at all. I played around with all the analog pins and it doesnt effect the movement. I can cover them up or expose them to light and nothing happens. Even having no photoresistors at all plugged in doesnt affect the movement. It just keeps rotating in circles. I did heatshrink the wires and I guess I could have done it too long. does it sound like the photoresistors are the problem?

I read some things that suggest that maybe its the voltage or battery. Im using a tenergy 6v 2300mah battery. Could this be the problem?

The servos should be fine. I didnt even need to modify them. They are just parallax continuous rotation motors. I can also switch the servo postions and whichever one is in position 5 goes faster.

Please help?!
« Last Edit: April 25, 2009, 05:36:57 PM by I Am Blashyrkh »

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: circling robot?
« Reply #1 on: April 25, 2009, 05:23:53 PM »
have you tried playing around with servo values in the code?
Howdy

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #2 on: April 25, 2009, 05:31:57 PM »
What would I need to do? I didnt mess with the code at all, I just followed the instructions in the tutorial. It is pin 5 that rotates faster and pin six that goes slowly. What should I look for?
I know I probably sound like an idiot

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: circling robot?
« Reply #3 on: April 25, 2009, 05:45:29 PM »
where it says "servo [47]" or something along those lines, try changing the values in one of them.
Howdy

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #4 on: April 25, 2009, 06:29:37 PM »
I played around with some of the values. the one that was going really fast is now going close to the speed of the other one. (a little faster) I could probably play with the values to get it to go the same speed but its still not responding to the photoresistors. Should it even work if there are no resistors plugged in? Does that mean that the photocells are the problem? I can make a couple more but I didnt want to if I dont need to.

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: circling robot?
« Reply #5 on: April 25, 2009, 06:35:33 PM »
i should drive with no photo sensors plugged in but not necessarily "work". another photo sensor may help you test it too see where the problem allies but is not needed. i think the photocells may be the problem if the servos go the same whether or not they are plugged in.
Howdy

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #6 on: April 25, 2009, 06:59:01 PM »
Ill try and make a couple new photoresistors in case I screwed something up when heat shrinking or something. I kind of think its either those or something in the programing. I followed everything in the programming and there is literally no variation when I unplug the photoresistors. Ill try that next.

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: circling robot?
« Reply #7 on: April 25, 2009, 07:11:29 PM »
that would explain the behavior if the photo resistors were down.
Howdy

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #8 on: April 25, 2009, 10:01:42 PM »
So I made two new resistors and the problem persists. I know its not he motors. That leaves the power supply which I doubt and programming issues.
Heres a question. When I got my roboduino board I tested my servos with the arduino software and it worked fine. Could I just copy the code into the arduino software or could I just open the hex file i was working with in avr studio in arduino and upload it that way? Would that work?
or if not, does anyone know of a basic photovore code that can be used with the arduino software? Alas! I am running out of time! Anyone who can help in any way it would be much appreciated. Thanks Smash for contributing so much already.
« Last Edit: April 25, 2009, 10:07:23 PM by I Am Blashyrkh »

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: circling robot?
« Reply #9 on: April 26, 2009, 03:06:56 AM »
You should write a small test program where the roboduino prints the analogue voltage value of your photoresistor out over serial.

Try to isolate and test everything separately.
Imperial College Robotics Society
www.icrobotics.co.uk

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: circling robot?
« Reply #10 on: April 26, 2009, 05:44:43 AM »
Paste the code you are working with in Arduino software here and let us see what caould be the problem. Don't forget to mention what pins the servos and light sensors are connected. If the pins are labeled wrong, the program will not work or will work unespected.
Check out the uBotino robot controller!

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #11 on: April 26, 2009, 10:47:53 AM »
I wasnt working with a code in Arduino. I dont know enough about programming to write my own code. I was just wondering if I could use the code that is being used in the $50 robot (roboduino version) found here: http://www.societyofrobots.com/member_tutorials/node/288
and use it in the arduino software?

Ive been looking relentlessly for basic photovore source codes using arduino and Ive found a few but the page is old enough that the link for the uploaded source code is dead. *sigh*

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: circling robot?
« Reply #12 on: April 26, 2009, 11:26:59 AM »
You arent able to use that in the arduino software...

Anyway, the code for a photovore can be really simple, and implementing it in the arduino software is kinda trivial if you know the concepts of programming and a bit of C syntax. There is a nice tutorial here - http://www.howstuffworks.com/c.htm

I'd say if you learn what variables are, how to branch and loop, the concept of functions, and how to use the basic operators then you are set to write the code yourself. It shouldn't take too long i think.

It might be frustrating having the hardware there and not being able to do anything with it... but it will feel great if you knew you did it all yourself.
Imperial College Robotics Society
www.icrobotics.co.uk

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #13 on: April 26, 2009, 03:18:52 PM »
I tried playing around with some values in AVR studio again and I got both servos to go in the same direction and at the same speed. But they still dont respond to the photoresistors. Can anyone look at the code and see why that would be?

This is the code for the photovore_v1

/****************************************************************************
*
*   Copyright (c) 2007 www.societyofrobots.com
*   (please link back if you use this code!)
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License version 2 as
*   published by the Free Software Foundation.
*
*   Alternatively, this software may be distributed under the terms of BSD
*   license.
*
*   Photovore v1, March 10th, 2007
*   Simple case-based method for a robot that chases light.
*
*
****************************************************************************/

//SoR Include
#include "SoR_Utils.h" //includes all the technical stuff


int main(void)
   {
   //declare variables here
   //int i=250;//a 'whatever' variable
   int sensor_left=3;//left photoresistor
   int sensor_right=3;//right photoresistor
   int threshold=8;//the larger this number, the more likely your robot will drive straight
   

   /****************INITIALIZATIONS*******************/
   //other stuff Im experimenting with for SoR
   //uartInit();  // initialize the UART (serial port)
   //uartSetBaudRate(9600);// set the baud rate of the UART for our debug/reporting output
   //rprintfInit(uartSendByte);// initialize rprintf system

   //timerInit(); // initialize the timer system
   
   configure_ports(); // configure which ports are analog, digital, etc.
   a2dInit(); // initialize analog to digital converter (ADC)
   a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
   a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

   //rprintf("Initialization Complete\r\n");
   /**************************************************/

   
   /*********ADD YOUR CODE BELOW THIS LINE **********/
   LED_off();//turn LED on


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


      //detects more light on left side of robot
      if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
         {//go left
         servo_left(44);
         servo_right(25);
         }

      //detects more light on right side of robot
      else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
         {//go right
         servo_left(25);
         servo_right(44);
         }

      //light is about equal on both sides
      else
         {//go straight
         servo_left(25);
         servo_right(25);
         }


      /* Servo Test Code
      i=250;
      while(i>0)
         {
         servo_left(40);
         i--;
         }

      i=250;
      while(i>0)
         {
         servo_left(40);
         i--;
         }
      */

      //rprintf("Initialization Complete\r\n");
      
      //output message to serial (use hyperterminal)
      //print("Hello, World! Read My Analog: %u\r\n", sensor_0);

      delay_cycles(500);//a small delay to prevent crazy oscillations
      }
   /*********ADD YOUR CODE ABOVE THIS LINE **********/

   return 0;
   }


/*********************COMMAND LIST*************************

delay_cycles(cycles);
Delays - you can make your robot wait for a certain amount of time with this function.
Put the number of computational cycles to delay in the ().
23 cycles is about .992 milliseconds
to calculate: 23/.992*(time in milliseconds to delay) = cycles
Check servo datasheet where it says: 'Direction: Clockwise/Pulse Traveling 1500 to 1900usec'


servo_left(speed); and servo_right(speed);
Commands your servos to rotate at a certain speed.
Vary speed (which represents a delay in cycles) from 20 to 50.
Left is for port D0 and right is for port D1.


LED_on(); and LED_off();
Turns on and off your LED. The LED is on port D4.
By bringing port D4 low, you are turning on the LED.


variable=a2dConvert8bit(pin);
Reads analog pin. For example, set 'pin' to 5 to read PC5.
'variable' will store the value.

***********************************************************/

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #14 on: April 26, 2009, 03:34:22 PM »
So the problem is solved! the robot is now responding to the light!!!! But I do have a question, where in the code that I posted above would I have to add or modify in order to make the robot stop when it does not pick up on any light? I dont want it to just go straight endlessly if there is no light.

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: circling robot?
« Reply #15 on: April 26, 2009, 03:36:23 PM »
You should use the software in this tutorial, not in the normal arduino tutorial.

The analogue ports used are different so that would change things and affect your robot in the way you are describing...

EDIT:: How did you solve it?
« Last Edit: April 26, 2009, 03:37:46 PM by hazzer123 »
Imperial College Robotics Society
www.icrobotics.co.uk

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #16 on: April 26, 2009, 04:44:08 PM »
That is the tutorial that I was originally working off of. I had issues in the programming and couldnt figure out what was causing the strange behavior. So I had planned on using arduino software instead. But that wasnt working out so I went back to that tutorial and played around with the values. Some of the values in the code werent working so I changed some of them so that it made sense to me and now it responds to light. Thats all i did and apparently its fixed.
I do want to ask however, how do I modify the code so that the robot stops when there is no light present? I dont want it to just endlessly walk forward if there is no light. Thanks a lot to everyone for your help thus far.

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: circling robot?
« Reply #17 on: April 26, 2009, 04:48:39 PM »
So you would define a threshold for the minimum light level. Then you would compare the two sensor reading against it. If they are both lower than it, then you tell both servos to stop.

Heres some pseudo code (used to get the idea across, but won't actually work in AVR studio...)

Code: [Select]
if((sensorLeft < minLight) and (sensorRight < minLight)) then
      stopLeftMotor;
      stopRightMotor;
endif

Try something like that.
Imperial College Robotics Society
www.icrobotics.co.uk

Offline I Am BlashyrkhTopic starter

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 0
Re: circling robot?
« Reply #18 on: April 26, 2009, 09:55:57 PM »
      //detects more light on left side of robot
      if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
         {//go left
         servo_left(44);
         servo_right(25);
         }

      //detects more light on right side of robot
      else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
         {//go right
         servo_left(25);
         servo_right(44);
         }

      //light is about equal on both sides
      else
         {//go straight
         servo_left(25);
         servo_right(25);
         }


Thats the code Im working with. Where it says threshold, is that the issue? If I add a value where it says threshold (like 5 or whatever) would that make it stop so long as the light is below that value?
I tried taking the pseudo code you gave me and writing it the way I saw in the code but it looks like garbage. I plan on learning c but I cant for this project because Im pretty much out of time.
I also apologize for the displaying the code that way. I dont know how to add code like you did.
« Last Edit: April 26, 2009, 10:00:59 PM by I Am Blashyrkh »

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: circling robot?
« Reply #19 on: April 27, 2009, 12:36:34 AM »
Actually if you look higher in the code (where the variable threshold is initialised) you'll see it has a value of 8. Try changing that number higher and lower and observe the effects on your robot.

This code structure is the if...else if... else....

You could add another else if (...){...} which would handle the situations where your robot stops in its tracks.

Seriously, you should look at the link i sent you - http://www.howstuffworks.com/c.htm - studying up to functions would be fine for now i think.
Imperial College Robotics Society
www.icrobotics.co.uk

Offline Crunchy Theory

  • Full Member
  • ***
  • Posts: 80
  • Helpful? 0
  • "Well great is ok, but amazing would be great."
Re: circling robot?
« Reply #20 on: November 14, 2010, 07:27:01 PM »
Im building the $50 robot (the roboduino version) and I programmed it following the tutorial and it appears to be right but when i power it up it just goes in circles. One servo rotates quickly and the other rotates in the same direction but much slower
I searched and everyone who has problems like this are different, like with one servo rotating in the opposite direction or one not working at all etc.

I cant pin down the problem. The programming seemed to go ok so I dont think its that. The photoresistors might be messed up. I plugged it into the roboduino board at the "analog in" pin 0 and 1 and it doesnt effect it at all. I played around with all the analog pins and it doesnt effect the movement. I can cover them up or expose them to light and nothing happens. Even having no photoresistors at all plugged in doesnt affect the movement. It just keeps rotating in circles. I did heatshrink the wires and I guess I could have done it too long. does it sound like the photoresistors are the problem?

I read some things that suggest that maybe its the voltage or battery. Im using a tenergy 6v 2300mah battery. Could this be the problem?

The servos should be fine. I didnt even need to modify them. They are just parallax continuous rotation motors. I can also switch the servo postions and whichever one is in position 5 goes faster.

Please help?!

This is exactly the same problem I'm having now, right down to the same battery! Both servos are rotating in the same direction (from the perspective of mounted on a robot) so the robot is moving in a forward, curved line but are non-responsive to the photoresistors. OP said that he solved the problem by replacing "bad" values. Anyone have an idea of what values he was referring to?
The only way to top an upright screen, keyboard, and mouse is to eliminate the need for humans to touch a PC at all. Oh, hello there Mr. Robot... what would I like you to do, you ask?

 


data_list