Society of Robots - Robot Forum

Software => Software => Topic started by: pk44 on January 18, 2011, 04:01:01 PM

Title: avrisp mkii noy connecting to axon
Post by: pk44 on January 18, 2011, 04:01:01 PM
i have the avrisp mk2 hooked up to my usb port and axon. when i go to the connect button and select the avrisp mk2 and hit connect it first says connection failure and then after the second try the program always freezes. also for some reason my left servo slowly turns when i hook up the usb port,that might have something ti do with it. thanks for any help, im obviously new at this.
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 19, 2011, 10:08:14 AM
What are the colors of the two LEDs on the AVRISP mk2 programmer?

Also, try restarting your computer.
Title: Re: avrisp mkii not connecting to axon
Post by: pk44 on January 20, 2011, 11:25:29 AM
the light is green so it should be connecting and i restarted my computer but that didn't work. i tried running the bootloader in DOSBox but that did not work either. :(
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 20, 2011, 07:15:53 PM
Are both lights green, or just one light is green?

What is your battery voltage (check with multi-meter).

Also, what is your operating system?
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 22, 2011, 04:32:20 PM
There is only one light on this. It says mkii though. My operating system is windows 7. My battery is 6 volts if it is functioning properly. Thanks for the help.
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 22, 2011, 04:40:38 PM
i think i might have just figured out why it does not work. The driver software for the isp doesn't seem to be compatible, even when installing manually using the hardware wizard. but does that explain why the bootloader doesn't work on my VM?
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 22, 2011, 04:46:32 PM
Quote
There is only one light on this.
There must be TWO green lights for it to program properly.

Unplug it from both the Axon and your computer. Then only plug it into your computer. Does only one green light turn on when plugging it in?

Quote
My battery is 6 volts if it is functioning properly.
Measure it with a multimeter.
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 23, 2011, 12:45:02 PM
Sorry, i mean there is only one LED on the programmer, there are not two, the only one there is lights up. I don't have a multimeter. I really do think that it is a problem with the driver not installing correctly though.
Title: Re: avrisp mkii noy connecting to axon
Post by: Webbot on January 23, 2011, 02:38:03 PM
The user guide for the programmer http://www.atmel.com/dyn/resources/prod_documents/AVRISPmkII_UG.pdf (http://www.atmel.com/dyn/resources/prod_documents/AVRISPmkII_UG.pdf) may help - re the lights. Apologies if you've already got that link.
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 23, 2011, 05:20:58 PM
Unplug it from both the Axon and your computer. Then only plug it into your computer. Does only one green light turn on when plugging it in?

Good chance your battery is dead. Try another 6V battery thats fully charged.
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 26, 2011, 07:56:13 PM
well i finally got some code to upload using the bootloader in windows xp mode :). thanks for the help. But there is one more thing i would like to ask. i have this code in my control.c file that i wrote to make my robot which has two modified servos turn left when it detects a wall. i am good a C++ but know nothing about programming microcontrollers. here it is:

int range;

void update(void)
void robot(void)

void control(void)
{
       robot();
}
void update(void)
{
       range= sharp_IR_interpret_GP2D12(a2dConvert8bit(0));
}
void robot(void)
{
      update();
      while(1)
      {
             update();
             if(range < 10 )
         {//go left
          servo( PORTE,7,550);
          servo( PORTJ,6,550);
          }
             else
             {
                     servo(PORTE,7,600);
                     servo(PORTJ,6,800);
             }
       }
}

i have included sensors.c and hardware.c in my source files. thanks for any help!
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 26, 2011, 08:37:03 PM
Whats wrong with the code/robot?
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 26, 2011, 10:01:32 PM
i cant believe i neglected to say the most important part! well, it just doesn't seem to do anything. the servos never move at all in any direction no matter how many times i put my hand or a box in front of the sensor. i think i need to calibrate the sensor or set it up to function in the code somehow but i couldn't find a clear explanation of how to do this on the source code page. thanks for your help, i really appreciate people taking the time to answer my very uneducated questions! but since this is my first robot i am hoping that i can just learn by doing.
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 26, 2011, 10:07:01 PM
right before this line:
if(range < 10 )

add this line:
rprintf("\nrange is %d",range);

It'll be obvious why it's not working after you do that :P

Also, change:
int range;

to be:
unsigned int range;
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 27, 2011, 09:15:26 AM
where does printf() output to if i do  not have and lcd screen attached? can i leave the axon hooked up to the usb port and have it output to the computer?
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 27, 2011, 09:47:51 AM
can i leave the axon hooked up to the usb port and have it output to the computer?
Yeap. Use hyperterminal to view the data. It's by far the best way to debug software, by outputting data to your PC.
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 27, 2011, 02:53:52 PM
i added the printf and connected in hyperterminal but nothing seems to be happening. no information is being displayed in hyperterminal for some reason. could i learn what is wrong without hyperterminal?
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 27, 2011, 03:14:13 PM
You will need hyperterminal to debug problems in the future, not just the one here. Trust me on this, it'll save you tons of time in the future for a small time investment now.

follow this tutorial:
http://www.societyofrobots.com/programming_data_logging.shtml (http://www.societyofrobots.com/programming_data_logging.shtml)
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 27, 2011, 05:18:27 PM
i followed the tutorial word for word but it still isnt working. i have tried now a couple times but it hasnt work. i re-checked my code too. any advice?
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 27, 2011, 07:46:35 PM
You need to get a multi-meter, or at least a fully charged battery before we continue. I suspect your battery is dead. :P
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 27, 2011, 09:00:39 PM
okay, so i plugged my other battery in and it didn't work either. so i guess i'm out to buy a charger or a multimeter...
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 28, 2011, 01:22:47 PM
i changed my code to webbotlib. here it is, still doesn't work:


#include "sys/axon.h"
#include "servos.h"
#include "a2d.h"
#include "Sensors/Distance/Sharp/GP2D12.c"

 
// Define two servos
SERVO left = MAKE_SERVO(FALSE, E3,1500, 500);
SERVO right = MAKE_SERVO(TRUE , E4,1500, 500);
 
// Create the list - remember to place an & at the
// start of each servo name
SERVO_LIST servos[] = {&left,&right};
 
// Create a driver for the list of servos
SERVO_DRIVER bank1 = MAKE_SERVO_DRIVER(servos);

//make sensor
Sharp_GP2D12 sensor = MAKE_Sharp_GP2D12(ADC0);
 
//the larger this number, the more likely your robot will drive straight
#define threshold 8
 
// In my initialising code - pass the list of servos to control
void appInitHardware(void){
    // Initialise the servo controller
    servoPWMInit(&bank1);
    // Give each servo a start value of 'stop'
    act_setSpeed(&left, 0);
    act_setSpeed(&right,0);
   distanceInit(sensor);
}
TICK_COUNT appInitSoftware(TICK_COUNT loopStart){
    return 0;
}
 
// This is the main loop
TICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
   distanceRead(sensor);
    if(sensor.distance.cm < 10){
        // go left
        act_setSpeed(&left,DRIVE_SPEED_MIN);
        act_setSpeed(&right,DRIVE_SPEED_MAX);
    }else{
        // Go forwards
        act_setSpeed(&left,DRIVE_SPEED_MAX);
        act_setSpeed(&right,DRIVE_SPEED_MAX);
    }
    return 20000; // wait for 20ms to stop crazy oscillations
}

could the battery explain the code not working (if it is right) as well as hyperterminal?
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 28, 2011, 04:08:20 PM
could the battery explain the code not working (if it is right) as well as hyperterminal?
Yeap.

Also, programming the Axon on a low/dead battery can on very rare chance brick it (a very bad thing).
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 28, 2011, 08:00:37 PM
i charged my battery for about an hour, it might need more, but still nothing is working. not even the bootloader. does the red power light still come on if it is 'bricked'?
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 28, 2011, 09:24:08 PM
The red LED should turn on if the Axon is receiving power, no matter what. My bet is your battery is the problem.

Are you sure you are plugging in the battery the right way? :P
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 28, 2011, 09:41:04 PM
yes, black cable on the outside, right? the red light still turns on so i was just wondering if it wouldn't be on if it was 'bricked'.but since it can still be on there is a possibility i might have bricked it because it is not programming anymore. thanks.
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 28, 2011, 11:49:09 PM
If it is bricked, it will give you an error when trying to program it. Are you plugging the battery into the BAT pin?

Do the servos twitch when you plug the battery in? If not, power is probably too low. Definitely get a multi-meter to check the battery.

Also, what else do you have plugged into your Axon? Just two servos and one sharp IR?
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 29, 2011, 10:34:43 AM
well i got an error last night but today it programmed smoothly, so that's strange but i guess its not bricked :).the servos do not twitch when i plug the battery in but i charged it for 2 hours(the amount of time recommended). but yes, all i have plugged in is two servos and a sharp ir.
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 29, 2011, 11:25:31 AM
What was the error you got?
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 29, 2011, 11:44:39 AM
well, the bootloader has been working strangely lately, i think that my code that is running is now preventing it from connecting. is there a way to manually clear the flash? in debugging my program it looked like it didn't even make it to the main loop so i need to reupload code to see what is going on. so i think it might be the code and not the battery.
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 29, 2011, 11:59:45 AM
I'm confused . . .

Are you programming it with the AVRISP, or the bootloader?

If you use the AVRISP, you delete the bootloader in the process. If the bootloader is working, that means your AVRISP never programmed the Axon.

I still think it's the battery, and I'm going to wait to hear back about that.
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 29, 2011, 01:04:49 PM
yes, my situation is very confusing. i was never able to get the avrisp to connect to the axon. i finally got the correct driver for the isp but it does not connect now either, i was able to program the axon a couple times with the bootloader though. the avrisp has never connected, but now that it should with the correct drivers we think that the running code is preventing it from connecting. see, right after my last successful program with the bootloader the green status light was constantly flashing. now sometimes when the axon is not plugged into the computer the green light flashes also. it appears to be resetting constantly. i have no clue what is going on with it, but something it is doing is preventing the programmer from connecting, so i am not able to remove my current code, which is what i think is causing the bootloader not to connect. sorry for being such a hassle, but basically everything that could go wrong has gone wrong with this robot.  :-[
Title: Re: avrisp mkii noy connecting to axon
Post by: Admin on January 29, 2011, 01:17:07 PM
Quote
now sometimes when the axon is not plugged into the computer the green light flashes also. it appears to be resetting constantly.
Constant resetting and flashing green light are good (bad?) signs of a low battery :P

How many mAh does your battery have? How many amps and what voltage does your charger charge at?
Title: Re: avrisp mkii noy connecting to axon
Post by: pk44 on January 29, 2011, 02:33:58 PM
my battery is 2500mAh. my charger charges at a selective 1 to 4 amps. can't find the voltage but the store said this is what would work. maybe the batteries are just bad? but that still doesn't explain the bootloader or connection problems. ???