Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: garriwilson on July 21, 2007, 05:00:39 PM

Title: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 21, 2007, 05:00:39 PM
So if I broke one of the pins on my microcontroller!!! :'( Is that it? Or can i put super glue or something. I cried.  I seriously did. My dad is gonna kill me. IF there is any way to fix it tell me please. I don't know what I'm going to tell my parents they spent like 200 bucks on this! I broke the one on the edge on the left side trying to take it out of the socket because it didn't go in enough. Can I solder it back in or something? Or can I put a wire from that pin and put it around and solder it to the back of the socket? Any other ideas? Does anyone know of any stores that sell those microcontrollers? Like Radioshack, Fry's, or other well-known stores? PLZ respond
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: JonHylands on July 21, 2007, 06:12:55 PM
Well, it would really help if you could take a picture of this thing, and tell us what kind of chip it is.

- Jon
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Kohanbash on July 21, 2007, 07:51:43 PM
Don't worry yet.
On many micros a lot of the pins are not (need not be) used. Check the data sheet to see what that pin does. if its not connected than your lucky, but if its an I/O, clk, etc... you might be able to get away with not using that function while the rest of the micro works.
Also is the pin completely broken or is there a spec of metal showing from where the pin was? If there's a little you might be able to wire wrap it?
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 22, 2007, 10:51:13 AM
If it turns out to be an important pin and not repairable, consider upgrading when you get a new one:
http://www.societyofrobots.com/step_by_step_atmega168_swapout.shtml

Also, try mouser.com to buy it (they dont rape and pillage you for shipping).
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 22, 2007, 03:01:45 PM
Thanx guys, I got one from mouser.com! The total digikey price with shipping is  like 6 times the price of the micro!!! What's up with that? And the pin that broke is for the servo its PD0. Do you think I could use PD3 or do I have to modify the programming? I'll probably use it later.
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 22, 2007, 03:36:58 PM
Quote
And the pin that broke is for the servo its PD0. Do you think I could use PD3 or do I have to modify the programming?
Yeap just use PD3 instead of PD0. In the code, just change that 0 to a 3.
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 22, 2007, 08:04:44 PM
1. Admin can you tell me your name so I don't have to call you Admin?
2. Which code should I change it in? Makefile, Photovore v1, or other?
3. Those codes are really long or maybe I'm looking in the wrong place?
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 22, 2007, 08:09:48 PM
My name is John.

Look in the SoR_utils.h file. Look at the servo control code. You will see a pin number being called. Its all well commented so it shouldnt take you long to figure it out.
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 22, 2007, 09:13:42 PM
Thank you for everything John. I can't believe someone would actually make a website for noobs to make a robot. I mean all these tutorials must've taken you weeks. And it's at no cost for people. I guess you are really devoted to robotics. Oh I'm going to high school next year and they have a robotics club called the Circuit Breakers. Should I join? Maybe you know this school: it's called Clark Magnet High School. I think they're famous for their robotics club.
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: HDL_CinC_Dragon on July 22, 2007, 10:35:02 PM
Oh I'm going to high school next year and they have a robotics club called the Circuit Breakers. Should I join? Maybe you know this school: it's called Clark Magnet High School. I think they're famous for their robotics club.

I would suggest you go. I joined the robotics club at my highschool at it was a great experience. The club probably competes in the FIRST Robotics competitions. If so, learn as much as you can from the older members of the club (mostly the seniors that have been there for 3 years already). MY advice is ask them if you can watch and work with them on building the "brain" of the robot. Not only can they help you a lot with questions and stuff but you might be able to take home extra parts and stuff. Thats what I did. "Hey, do you think were gunna need this ever?" ".... nah, whatever. Want it?" And its yours =) I got some good stuff too. I should have payed more attention when they were building the brain... I regret not watching closely and learning it all.
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 23, 2007, 08:50:30 PM
Sorry John I made a little mistake. hehe :-[ The pin that broke is for the first sensor. Port PC5 (ADC5/SCL).
Can I still fix the programming if yes which file is it in?
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 24, 2007, 05:26:24 AM
No problem. I designed it to hook I think up to 6 sensors. So if one pin breaks, just use a different one. The code is in the same file, but look where it reads in the sensors in the code. You will see a number that represents a pin. Just change that one number to the pin you use.
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 24, 2007, 11:04:57 AM
Is it this part?

//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) )

Should I put in the letters and numbers if this is the one?
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 24, 2007, 11:19:22 AM
Nope. Keep lookin :P

It will be obvious when you find it. Its the line that says something like 'read in analog from a sensor' or something like that. And it will have a port number/letter with it.

(Im not just telling it to you because I have faith in you :P)
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 24, 2007, 01:41:40 PM
Sorry I've looked and looked but still didn't find it. I'm kind of disappointed in myself.  :-[   I wanted to find it myself but haven't found anything and my eyes hurt. Here is the whole thing could you highlight the things I have to change plz?

/****************************************************************************
*
*   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
   }
//***************************************

//************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);
   }
//***************************************
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 24, 2007, 02:35:25 PM
lol wrong file.

Its in the photovore file.

(sorry if I wasnt clear on that)
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 24, 2007, 05:04:11 PM
Is it this part?

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

and do i change 5 to 3 if the pin that broke is the first one which is number 28 on the schematic for microcontroller in step 3B
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: Admin on July 25, 2007, 07:29:18 AM
Yeap thats it. Those numbers just represent the analog pin.

The analog can be between 0 and 5 on the ATmega8, representing pins 23 to 28.

So if you ever wanted to add another sensor, you can do something like:

sensor_new=a2dConvert8bit(0); //attach sensor to pin 23
Title: Re: I broke one of the damn pins on my microcontroller! Help!
Post by: garriwilson on July 25, 2007, 10:27:46 AM
Thanks for everything guys!