Society of Robots - Robot Forum

Software => Software => Topic started by: subhechha on January 27, 2011, 09:58:14 PM

Title: please help it's urgent
Post by: subhechha on January 27, 2011, 09:58:14 PM
hii ....there is occurance of error while burning through avrdude ...we use atmega16 n ide is avr studio4....can u plzz help us ...it's really urgent...the is herewith....
Code: [Select]
#include<avr\io.h>
#include<util\delay.h>
#include<compat\deprecated.h>
#include<inttypes.h>


#define F_CPU 1000000UL  // 1 MHz
//#define HIGH 1
#define SETBIT(a,b) a|=(1<<b)
//#define CLEARBIT(a,b) a&=(1<<b)

//#define inp(a) a
//#define cbi(x,y) x&=~(1<<(a))
//#define sbi(x,y) x|=(1<<(a))

volatile int r1,r2;
 
unsigned char ch , pinaa;

void settimer()
{
TCCR1A=0b10100001;
TCCR1B= 0b00001001;
TCCR0=0b01101011;

}




void forward()
{
cbi(PORTC,1);
sbi(PORTC,2);
cbi(PORTC,3);
sbi(PORTC,4);
}

void reverse()
{
sbi(PORTC,1);
cbi(PORTC,2);
sbi(PORTC,3);
cbi(PORTC,4);
}



void rightturn()
{
sbi(PORTC,1);
cbi(PORTC,2);
cbi(PORTC,3);
cbi(PORTC,4);

}


void leftturn()
{
cbi(PORTC,1);
cbi(PORTC,2);
sbi(PORTC,3);
cbi(PORTC,4);
}


void brake_move()
{
sbi(PORTC,1);
sbi(PORTC,2);
sbi(PORTC,3);
sbi(PORTC,4);
}





void see_wall()
{

if ((PINA==10000010)||(PINA==11000010)||(PINA==11100010)||(PINA==11111010)||(PINA==11111110)||(PINA==10111010)||(PINA==10011110)||(PINA==10001110)||(PINA==10000110)||(PINA==10010010)||(PINA==10011010))
{
brake_move();
}
}



void shiftleft1()                   // to shift bot to more amount in clockwise direction
{
volatile int i;
ch=00001;
for(i=0;i<3;i++)
{
ch=ch<<i;
leftturn();
_delay_ms(1);
}
forward();
}

void shiftleft2()               // to shift bot to slightly less amount in clockwise direction
{

ch=00011;
volatile int i;
for(i=0;i<2;i++)
{
ch=ch<<i;
leftturn();
_delay_ms(1);
}
forward();
}


void shiftleft3()
{
ch=00010;
volatile int i;
for(i=0;i<1;i++)
{
ch=ch<<i;
leftturn();
_delay_ms(1);
}
forward();
}


void shiftright1()               // to shift bot to more amount in anti-clockwise direction
{
 ch=0x10;
volatile int i;
for(i=0;i<3;i++)
{
ch=ch>>i;
rightturn();
_delay_ms(1);
}
}

void shiftright2()              // // to shift bot to slightly less amount in anti-clockwise direction
{
 ch=0x8;
volatile int i;
for(i=0;i<2;i++)
{
ch=ch>>1;
rightturn();
_delay_ms(1);

}
}




void shiftright3()
{
volatile int i;
ch=00100;
for(i=0;i>1;i++)
{
ch=ch>>i;
_delay_ms(1);
rightturn();
}
}






void found_intersection()
{
_delay_ms(50);
forward();
}






void read_sensor()
{
pinaa=(PINA);

while(1)
{

if((pinaa==00111000) || (pinaa==00010000))
{
see_wall();
OCR1A=180;
OCR1B=180;
forward();
}
else if((pinaa==00011000) ||(pinaa==00001000) || (pinaa==00011100))
{
//n=2;
see_wall();
OCR1A=120;
OCR1B=120;
shiftleft3();
_delay_ms(2);
forward();
}
else if(pinaa==00001100)
{
//n=3;
see_wall();
OCR1A=90;
OCR1B=90;
shiftleft2();
_delay_ms(2);
forward();
}
else if(pinaa==00000100)
{
//n=4;
see_wall();
OCR1A=70;
OCR1B=70;
shiftleft1();
_delay_ms(2);
forward();
}

else if((pinaa==01111100) || (pinaa==00111100) || (pinaa==01111000))
{
see_wall();
found_intersection();
}


else if((pinaa==00110000) || (pinaa==01110000) ||  (pinaa==00100000))
{
see_wall();
OCR1A=120;
OCR1B=120;
shiftright3();
_delay_ms(2);
forward();
}


else if(pinaa==01100000)
{
see_wall();
OCR1A=90;
OCR1B=90;
shiftright2();
_delay_ms(2);
forward();
}
else if(pinaa==01000000)
{
see_wall();
OCR1A=70;
OCR1B=70;
shiftright1();
_delay_ms(2);
forward();
}

else
;

}

}






/*void set_pwm(volatile int left_spd , volatile int right_spd)
{
OCR1A=left_spd;
OCR1B=right_spd;
}
*/



int main(void)
{
DDRA=0x00;
PINA=0x00;

/*
SETBIT(DDRC,0);
SETBIT(DDRC,1);
SETBIT(DDRC,2);
SETBIT(DDRC,3);
SETBIT(DDRC,4);
SETBIT(DDRC,5);
*/


DDRC=0xFF;

PORTC=0x00;
/*
SETBIT(PORTC,0);
SETBIT(PORTC,1);
SETBIT(PORTC,2);
SETBIT(PORTC,3);
SETBIT(PORTC,4);
SETBIT(PORTC,5);
*/



 settimer();
 _delay_ms(100);
 OCR1A=180;
 OCR1B=180;
// forward();

while(1)
{
if(PINA==00000000)
{
return 0;
//exit(0);
}
else
{
forward();
_delay_ms(500);
read_sensor();
_delay_ms(500);

}
}
}

Title: Re: please help it's urgent
Post by: hopslink on January 28, 2011, 02:37:00 AM
Please carefully read this >LINK< (http://www.societyofrobots.com/robotforum/index.php?topic=1480.0) and give your posts a meaningful title - 'Error while burning through avrdude' would have been good. Your situation may seem urgent... but actually it's only urgent to you.  :P

Back to your problem, you included your code, but there should be an error code and message from avrdude. That would be helpful in this case.

Also try adding the -v (verbose) option to your avrdude command to get more detailed feedback.

Title: Re: please help it's urgent
Post by: walkercreations on January 28, 2011, 06:42:58 PM
From what little I have learned so far with the programming thing, I don't see where the ATMega has been defined. I see where the CPU speed has been set to 1 MHz.