Author Topic: wheels always go in the opposite direction 50$  (Read 3078 times)

0 Members and 1 Guest are viewing this topic.

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
wheels always go in the opposite direction 50$
« on: March 09, 2009, 02:49:32 PM »
SO i just got everything working but the wheels always go in the opposite direction of each other is this normal
First Robotics - 2009
Canada Skills Robotics - 2009

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: wheels always go in the opposite direction 50$
« Reply #1 on: March 09, 2009, 03:06:05 PM »
seems either a servo modding error or a programming error. and are your sensors plugged in properly? this could cause false readings.
Howdy

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #2 on: March 09, 2009, 03:09:14 PM »
The servos came modded so i dont think its that so could it be that the resistor in the sensors is to strong
First Robotics - 2009
Canada Skills Robotics - 2009

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: wheels always go in the opposite direction 50$
« Reply #3 on: March 09, 2009, 03:12:19 PM »
well yes, id say that the resistor plays a huge part in this. check your photosensor values in both light and dark with a multimeter. and make sure the resistor is a 1.62k??? or whatever the right resistance is.
Howdy

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #4 on: March 09, 2009, 03:13:37 PM »
one servo always has to be mounted the opposite way of the other servo.

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #5 on: March 09, 2009, 03:15:04 PM »
if i flip the servo over it changes directions
« Last Edit: March 09, 2009, 03:16:51 PM by sean22 »
First Robotics - 2009
Canada Skills Robotics - 2009

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #6 on: March 09, 2009, 03:16:14 PM »
if you put a mirror in between your servos and looked at one servo in the mirror does the one behind the mirror look just like that servo? or is it backward?

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #8 on: March 09, 2009, 03:37:19 PM »
First Robotics - 2009
Canada Skills Robotics - 2009

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #9 on: March 09, 2009, 04:09:46 PM »
oh ok your good with that then.

Just reverse the code for one servo in your robot_go_straight macro

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: wheels always go in the opposite direction 50$
« Reply #10 on: March 09, 2009, 04:10:46 PM »
If you shine a torch into 1 photoresistor and then the other, do the servo's change direction?

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #11 on: March 09, 2009, 04:38:54 PM »
how do i change the robot go straight
First Robotics - 2009
Canada Skills Robotics - 2009

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #12 on: March 09, 2009, 04:45:06 PM »
Can you post up the servo code in SoR_Utils.h? I don't have it in front of me and I don't wanna download it at work.

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #13 on: March 09, 2009, 04:47:46 PM »
this is the Sor_utils.h

/****************************************************************************
*
*   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.
*
*   SoR Utilities v1, March 10th, 2007
*
****************************************************************************/

//AVR includes
#include <avr/io.h>          // include I/O definitions (port names, pin names, etc)
#include <avr/interrupt.h>   // include interrupt support

//AVRlib includes
#include "global.h"      // include global settings
//#include "buffer.h"      // include buffer function library
//#include "uart.h"      // include uart function library
//#include "rprintf.h"   // include printf function library
//#include "timer.h"      // include timer function library (timing, PWM, etc)
#include "a2d.h"      // include A/D converter function library

//define port functions; example: PORT_ON( PORTD, 6);
#define PORT_ON( port_letter, number )         port_letter |= (1<<number)
#define PORT_OFF( port_letter, number )         port_letter &= ~(1<<number)
#define PORT_ALL_ON( port_letter, number )      port_letter |= (number)
#define PORT_ALL_OFF( port_letter, number )      port_letter &= ~(number)
#define FLIP_PORT( port_letter, number )      port_letter ^= (1<<number)
#define PORT_IS_ON( port_letter, number )      ( port_letter & (1<<number) )
#define PORT_IS_OFF( port_letter, number )      !( port_letter & (1<<number) )


//************CONFIGURE PORTS************
//configure ports for input or output - specific to ATmega8
void configure_ports(void)
   {
   DDRC = 0x00;  //configure all C ports for input
   PORTC = 0x00; //make sure pull-up resistors are turned off
   DDRD = 0xFF;  //configure all D ports for output
   DDRB = 0xC7;  //configure B ports 0, 1, 2, 6, 7 for output (google search '0b11000111 to hex')
   }
//***************************************

//************DELAY FUNCTIONS************
//wait for X amount of cycles (23 cycles is about .992 milliseconds)
//to calculate: 23/.992*(time in milliseconds) = number of cycles
void delay_cycles(unsigned long int cycles)
   {
   while(cycles > 0)
      cycles--;
   }
//***************************************

//*********SIMPLIFIED FUNCTIONS**********
//functions to make coding easier for a beginner
//but could cause port mixup confusion for intermediate users
void LED_on(void)
   {
   PORT_OFF(PORTD, 4);//turn LED on
   }
void LED_off(void)
   {
   PORT_ON(PORTD, 4);//turn LED off
   }
void servo_left(signed long int speed)
   {
   PORT_ON(PORTD, 0);
   delay_cycles(speed);
   PORT_OFF(PORTD, 0);//keep off
   delay_cycles(200);
   }
void servo_right(signed long int speed)
   {
   PORT_ON(PORTD, 1);
   delay_cycles(speed);      
   PORT_OFF(PORTD, 1);//keep off
   delay_cycles(200);
   }
//***************************************
First Robotics - 2009
Canada Skills Robotics - 2009

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #14 on: March 09, 2009, 05:22:22 PM »
if i shine a light into the left photo resistor the right servo changes direction, if i shine a light into the right photo resistor it left servo cahnges direction and slows down quite a bit. when the light is equal the wheels go in opposite directions.
« Last Edit: March 09, 2009, 05:24:19 PM by sean22 »
First Robotics - 2009
Canada Skills Robotics - 2009

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #15 on: March 09, 2009, 05:50:47 PM »
Seems like you're missing some macros I found a copy of my header file I posted on here a while back

Code: [Select]
//*********SIMPLIFIED FUNCTIONS**********
//functions to make coding easier for a beginner
//but could cause port mixup confusion for intermediate users
void LED_on(void)
{
PORT_ON(PORTD, 4);//turn LED on
}
void LED_off(void)
{
PORT_OFF(PORTD, 4);//turn LED off
}
void servo_left(signed long int speed)
{
PORT_ON(PORTD, 2);
delay_cycles(speed);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(1600); // 200 * 8
}
void servo_right(signed long int speed)
{
PORT_ON(PORTD, 3);
delay_cycles(speed);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(1600); // 200 * 8
}
void servo_scan(signed long int speed)
{
PORT_ON(PORTD, 4);
delay_cycles(speed);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(1600); // 200 * 8
}
void robot_turn_left(void)
{
servo_left(200); // 25 * 8
servo_right(200); // 25 * 8
}
void robot_turn_right(void)
{
servo_left(352); // 44 * 8
servo_right(352); // 44 * 8
}
void robot_go_straight(void)
{
servo_left(200); // 25 * 8
servo_right(352); // 44 * 8
}
void hold_position(void)//37
{
servo_left(312);//39 * 8
servo_right(280);//35 * 8
}


You can see individually the macro for left and right is the same, but to get them to go straight in the same direction you have to pulse them differently


NOTE: I multiplied all the values by 8, because I was running at 8MHz not 1MHz


I later added a Macro to make the robot go backwards, where to go forward is:

Code: [Select]
void robot_go_straight(void)
{
servo_left(200); // 25 * 8
servo_right(352); // 44 * 8
}

Going backward would be:

Code: [Select]
void robot_go_back(void)
{
servo_left(352); // 25 * 8
servo_right(200); // 44 * 8
}


The best way to calibrate your servos is to sent it a hold position macro, and tweak the numbers inside that macro until your robot holds still, then you can offset the rest of the macros by that difference.


EDIT: Sorry when I say macro, I mean function
« Last Edit: March 09, 2009, 05:55:47 PM by pomprocker »

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #16 on: March 09, 2009, 05:55:54 PM »
this is working but, the servos don't move anymore but as a bonus the LED turns on
First Robotics - 2009
Canada Skills Robotics - 2009

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: wheels always go in the opposite direction 50$
« Reply #17 on: March 09, 2009, 05:57:15 PM »
Those functions I beleive are for the microcontroller at 8mhz, he might be running at 1mhz (using smaller numbers for servo like around 30 instead of around 200)

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #18 on: March 09, 2009, 05:58:41 PM »
Yes, like I said those numbers are multiplied by 8 for running at 8MHz if you're running at 1MHz then divide them all by 8. See the comments in the code.

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #19 on: March 09, 2009, 06:03:08 PM »
well my chip is broken again i pressed "auto" insted of "AVR" and it did something with the fuses so i have to wait another 2 week for sparkfun to deliver
First Robotics - 2009
Canada Skills Robotics - 2009

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: wheels always go in the opposite direction 50$
« Reply #20 on: March 09, 2009, 06:07:24 PM »
You should always order at least 5 of everything when it comes to electronic parts. Let that be a lesson to ya :P

That way you could easily do this:

http://www.societyofrobots.com/member_tutorials/node/239

EDIT: yeah don't order electronic components from sparkfun.com they jack up the price like 3 times what they cost at mouser.com. I only order specialty breakout board from sparkfun.com
« Last Edit: March 09, 2009, 06:08:22 PM by pomprocker »

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #21 on: March 09, 2009, 06:55:18 PM »
Mouser is cheaper for alot of thing but $4.74 for the atmeaga 8 and only $3.81 at SFE

Total + shipping to Canada at SFE       = 6.99

Total + shipping to Canada at Mouser  = 24.74

its really the shipping that gets you
First Robotics - 2009
Canada Skills Robotics - 2009

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: wheels always go in the opposite direction 50$
« Reply #22 on: March 09, 2009, 06:59:09 PM »
I also don't like their service at Sparkfun... always seemes rushed and hurried. I called once to ask about my order and they basically said "if it isnt important GTFO of our phone lines."  Also you can't even change your order after you place it... most of the time all you have to do is call and the store will fix things up with you.

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #23 on: March 09, 2009, 07:06:01 PM »
Intersting..

ive had the exact opposite experience  they sent me the wrong programmer i called them and then they sent me the new one right away, and i shipped the old one back and they credited my account with the shipping charges but i do see what you mean when you say they rush you
First Robotics - 2009
Canada Skills Robotics - 2009

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
Re: wheels always go in the opposite direction 50$
« Reply #24 on: March 09, 2009, 07:13:04 PM »
I guess its more like if it's Sparkfuns fault, they will hold your hand and fix everything right away. If it's your fault, it IS your fault so they won't do anything about it...

Offline sean22Topic starter

  • Jr. Member
  • **
  • Posts: 45
  • Helpful? 0
Re: wheels always go in the opposite direction 50$
« Reply #25 on: March 20, 2009, 07:07:30 PM »
i just got my new micro controller today and a Sharp IR sensor even with the new code and sensors my wheels still go in the same direction could this be beacuse im using the newest version of AVR Studio. here is the same kind of code i posted as last time but for the sharp

//*********SIMPLIFIED FUNCTIONS**********
//functions to make coding easier for a beginner
//but could cause port mixup confusion for intermediate users
void LED_on(void)
   {
   PORT_OFF(PORTD, 4);//turn LED on
   }
void LED_off(void)
   {
   PORT_ON(PORTD, 4);//turn LED off
   }
void servo_left(signed long int speed)
   {
   PORT_ON(PORTD, 0);
   delay_cycles(speed);
   PORT_OFF(PORTD, 0);//keep off
   delay_cycles(200);
   }
void servo_right(signed long int speed)
   {
   PORT_ON(PORTD, 1);
   delay_cycles(speed);      
   PORT_OFF(PORTD, 1);//keep off
   delay_cycles(200);
   }
void servo_scan(signed long int speed)
   {
   PORT_ON(PORTD, 2);
   delay_cycles(speed);      
   PORT_OFF(PORTD, 2);//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)//37
   {
   servo_left(39);//39
   servo_right(35);//35
   }
//***************************************



now that i look closer at this i think this could be a servo pulse problem here is the description on the servos im using


1.5mS means it stayed still. Go down towards 1.0mS, and it would turn one way, faster as you moved further away from the 1.5mS "neutral" signal. Then by changing the signal up to 2.0mS, you could make the servo spin the other way.
« Last Edit: March 20, 2009, 07:41:45 PM by sean22 »
First Robotics - 2009
Canada Skills Robotics - 2009

 


Get Your Ad Here

data_list