Author Topic: $50 robot programming error  (Read 4996 times)

0 Members and 1 Guest are viewing this topic.

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
$50 robot programming error
« on: July 08, 2010, 12:12:35 AM »
Hey, this is my second attempt at this tutorial and the only problem is that i can't program the Atmega8 MCU

I'm using the AVRISP MKII programmer with 10 pins, and AVR studio 4.18 SP2

the problem I have is that when i click the connect dialogue it keeps saying "connecting failed"

if anyone has had and fixed this problem or you know how i can fix it please reply, thanks


Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #1 on: July 08, 2010, 01:06:45 AM »
1st as you say you have a 10 pin programmer i assume you have a 10 pin header on the board. if so ensure that it is connected in the right orientation.

2nd make sure your circuit is all good by using a multi meter or continuity tester to test all the connections and parts of the circuit. if this is all good plug in the power and test with the multi meter the power connections on the power bus for the sensor and the servos also test the vcc and the GND pins on the programming header.

3rd make sure that your power supply is constant. eg no breaks in the power line etc. (at one stage i had a break in my power line and was also getting the connection failed problem and was ready to buy a new programmer but at the last minute i tried a different battery and it worked.)

and when you program the board make sure you have the battery plugged in as the MCU needs power so it can be programmed.

i am sure others will give you other things to check that may be the problem but these are what i have run into in the past.

cheers

Joker94

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #2 on: July 08, 2010, 02:00:36 AM »
ok just tested the voltages on the programmer's pins, these are all between the said + pin and the common ground.

Pin 1= 0.01V
Pin 2= 0V
Pin 5= 4V
Pin 7= 0.02V
Pin 9= 0.02V

these are measured while the programmer is not connected to the microcontroller, do these values sound about right?

and the other problems that joker mention are all fine.

This is getting extremely frustrating, I just want to get it working now lol

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #3 on: July 08, 2010, 02:09:13 AM »
yeah they sound rigth, pin 5 is the vcc pin. and is correct.

i am sure other people will give you more ideas about what to check but i am out of ideas from my experience and i am sure there is something that i have forgotten.

cheers

Joker94

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #4 on: July 08, 2010, 02:24:33 AM »
lol ok

well maybe i might just be doing it wrong, this is how i do it

connect programmer header to the board
connect power supply
run AVR Studio 4
click connect to programmer, i select [ARVISP MKII] over USB
end receive this error "unable to connect to programmer"

Should i be using a different program to program the MCU or should i be clicking on something else.

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #5 on: July 08, 2010, 03:25:13 AM »
ah i had the wrong error in my head.

for that it should connect as long as the programmer is connected. and then make sure you have the right comm port selected.if you know what one you are using select it but if not select 'auto'. you can find out by clicking on the icon you
would click on to eject USB's.

if i was going to connect the programmer to the computer i would ddo the following

-connect the programmer to the computer
-open AVR studio
- open you project and hit the program button
-make  sure you connect the right comport and programmer
-hit ok adn you should be in business

if this doesnt work power it up before pressing ok but i have never had a problem before

goodluck

Joekr94

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #6 on: July 08, 2010, 03:39:47 AM »
well thanks, but still no luck lol

I did buy the programmer off ebay and i saw somewhere on here about ppl making clones and selling them,
so i wonder if i bought a dodgy clone lol, should it have any marking or say AVR or something on it, mine doesn't.
it just has a sticker on the bottom with a barcode and a serial number.  ???

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #7 on: July 08, 2010, 03:47:13 AM »
well it should still work!

are you sure it is a AVRISP MKII and not a stk500, they all look the same and that mistake can be made easily.

and i assume you have the 10 pin header on the board to go with the 10 pin header on the programmer?


Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #8 on: July 08, 2010, 03:52:39 AM »
yes i have a 10 pin header on the board lol, someone here did say they were some dodgy clones on ebay that why i mentioned it
i'll try it as an stk500 then  ;D

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #9 on: July 08, 2010, 03:55:24 AM »
yeah all the ones on ebay will be clones regardless. i bought a STK500 and it has worked well for the last 13 months.

it should say in your instructions or on the ebay name what type you bought.

and another AUSSIE!  ;D

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #10 on: July 08, 2010, 03:55:50 AM »
ok awesome i have it, do i program the .hex into the Flash or eeprom?

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #11 on: July 08, 2010, 03:59:35 AM »
awsome

program the flash section

glad it all worked, well at least connecting the programmer ;D


Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #12 on: July 08, 2010, 04:01:30 AM »
yeah lol, awesome thanks.

i've programmed the flash and the led flashed on the board (hope that was normal lol)

now just plugging in my sensors and servos to see if it works lol.
and thanks again joker!

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #13 on: July 08, 2010, 04:06:21 AM »
no worries and i am glad it all worked for you.

any more questions just yell out

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #14 on: July 08, 2010, 07:50:38 AM »
ok now its programming the MCU and that's all fine.

but its doing some strange things, the value outputs for the servos i have changed to get it to go straight and turn right.

for straight i have Left Servo = 50
                         Right Servo = 25

turning right i have Left Servo = 55
                          Right Servo = 48

and I can't get it to turn left and I can't think what values i need to to turn left.
normally I could just work out the values from the ones I already have but I cant see any distinct pattern

I may even be doing something wrong so please lend me a hand lol. Thanks :D

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #15 on: July 08, 2010, 07:09:47 PM »
have you tried to get the photovore code working?

if so just play with that code E.g. changing the values, changing the if statements etc and you should be able to get it to do what you want to do.

unless you post all the code it is hard for us to know what is going on but you should be able to get their by experimentation.

cheers

Joker94

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #16 on: July 08, 2010, 08:26:49 PM »
yeah i tried the original code and it did weird shit lol, like the servo's turned really slowly unless turning

here's code im using now to make it turn left and go straight, but it also keeps crashing, the mcu just freezes and i have to reset the power to start it again.
Code: [Select]
//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=0;//left photoresistor
int sensor_right=0;//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(5);
sensor_right=a2dConvert8bit(4);


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

//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(25);
}

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


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

i=250;
while(i>0)
{
servo_left(24);
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;
}


Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #17 on: July 08, 2010, 08:34:13 PM »
i'll email you A .hex file that has beene tried and tested and see what happens then

if it is not working right there is no point trying to change the code

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #18 on: July 08, 2010, 08:53:32 PM »
no good :(

when I program it the servo's do nothing at all,

at least with my code it runs for a short period before it crashes lol.
do you reckon it could be a dodgy MCU because when i first attempted it and couldn't
program it i thought that it was a dud when i bought it so i left it laying around in junk for a while
so it could of been exposed to static electricity pretty often lol

but besides from that I'm completely out of ideas

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #19 on: July 08, 2010, 10:02:32 PM »
give me a bit and i'll set up my MCU($50 one) and see what happens

and i'll send you a .hex that definatly works

how did you mod your servos without a working MCU?

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #20 on: July 08, 2010, 10:38:25 PM »
i bought them already modified lol, and I know they work because i have the robot connected to my plane receiver and and transmitter and the bot works fine RC.

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #21 on: July 08, 2010, 11:07:24 PM »
well i have re compiled all of the code and tested it and it works

give it a go and see what happens

goodluck

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #22 on: July 08, 2010, 11:37:04 PM »
ok this time its an improvement

when both photoresistors have light both wheels turn in the right direction but the left one turns really slowly

when i block the right sensor it turns left with both wheels turning full speed

when i block the left sensor both wheels turn really slowly in the right direction

it seems that they want to go fast in a clockwise direction but go slow in an anti-clockwise direction, is this a common problem? lol

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #23 on: July 09, 2010, 12:01:45 AM »
well for me there is a very very slight difference in speed.

are your photoresistors both of the same value?

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #24 on: July 09, 2010, 12:11:53 AM »
yeah, they are higher then the ones in the tutorial, dark ~250K light ~30K but they are the same

nah, this isn't a slight difference in speed but when either of them rotate anti-clockwise they rotate at ~2rpm and clockwise rotate at ~20 rpm

Offline Alfa_ZuluTopic starter

  • Full Member
  • ***
  • Posts: 92
  • Helpful? 1
Re: $50 robot programming error
« Reply #25 on: July 09, 2010, 12:14:16 AM »
hey do you have a steam or msn?
this could be moving alot faster lol  ;D

Offline Joker94

  • Supreme Robot
  • *****
  • Posts: 1,119
  • Helpful? 26
Re: $50 robot programming error
« Reply #26 on: July 09, 2010, 12:18:44 AM »
oh i see, that big of a difference.

it shouldn't matter what resistance they are as long as they are both the same.

i assume you have checked the connections you made when making the sensor to ensure they are made correctly and the like.

do they both behave the same when the light intensity changes?

go to sor robot chat.
http://www.societyofrobots.com/robotforum/chat/

 


Get Your Ad Here