Pages: [1]   Go Down
Author Topic: AVRDUDE is fighting me...  (Read 497 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I've sleuthed pretty hard for a solution to this problem, but before I drop a new chip into my arduino, I want to try and understand why I am having this issue, so as not to simply end up where I am once again.

Basically I have an arduino UNO R3 with ATMega 328P. Working on it with mac OS10.8.2.
Things were going along swimmingly until I got into reading and writing to/from EEPROM. Even that was working perfectly, until it wasn't. I wanted to verify that I was saving data between power cycles, so I pressed the reset button. I had done this a few times without issue. This time, once the board reset, it started driving my stepper motors [hooked up via driver boards [sparkfun BED's to be specific]] at full throttle. I pulled the power before they could reach their stops and hurt themselves, but now whenever I try to load code onto board it gives me the following issue:

Code:
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0003
         0x00 != 0x80
avrdude: verification error; content mismatch
avrdude: Send: Q [51]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done.  Thank you.

Happy to paste the full verbose output if that would be helpful.

So from what I've been able to find out, this seems to be an issue that pops up sometimes if one has been uploading programs with lots of 0XFF in them. I have nothing like that in my code. At this point I can't even upload 'blink'. Whats more, it won't let me reburn the bootloader, giving me the following error:

Code:
avrdude: Version 5.11, compiled on Sep  2 2011 at 18:52:52
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/robertcollier/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb"

Whenever I try to upload anything, both TX and RX flash, but thats about it.

Here's the original code I was trying to upload:
Code:
//Robert Collier, David Reuss, Ben Cunkelman

#include <AccelStepper.h>
#include "EEPROMAnything.h"
#include <EEPROM.h>

int maxSpeed = 800; //maximum steps per second (about 3rps / at 16 microsteps)
int maxAccel = 500; //steps/second/second to accelerate

int inStop = 11000;
int outStop = 0;

int motor1DirPin = 4;
int motor1StepPin = 5;

int motor2DirPin = 6;
int motor2StepPin = 7;

int motor3DirPin = 8;
int motor3StepPin = 9;

int I_potX = A4;
int I_potY = A1;
int I_potZ = A2;

int I_force = A3;

int I_stickButton = 12;
int I_home = 3; //interrupt attached

float Xpot, Ypot, Zpot, Aspeed, Bspeed, Cspeed, force;
int userEN = 0;

int step1add = 0;
int step2add = 10;
int step3add = 20;

long stepper1pos = 0;
long stepper2pos = 0;
long stepper3pos = 0;

int O_LEDred = 11;
int O_LEDgrn = 13;
int O_LEDblu = 2; //pin 2 can serve as an interrupt

int O_enable = 10; //low=boards enabled. PD resistor on their side.

int HOME = 5500;

//set up the accelStepper intances
//the "1" tells it we are using a driver
AccelStepper stepper1(1, motor1StepPin, motor1DirPin);
AccelStepper stepper2(1, motor2StepPin, motor2DirPin);
AccelStepper stepper3(1, motor3StepPin, motor3DirPin);

  void setup(){
    stepper1.setMaxSpeed(maxSpeed);
    stepper2.setMaxSpeed(maxSpeed);
    stepper3.setMaxSpeed(maxSpeed);
  
    stepper1.setSpeed(maxSpeed);
    stepper2.setSpeed(maxSpeed);
    stepper3.setSpeed(maxSpeed);
  
    stepper1.setAcceleration(maxAccel);
    stepper2.setAcceleration(maxAccel);
    stepper3.setAcceleration(maxAccel);
  
    pinMode(O_LEDred, OUTPUT);
    pinMode(O_LEDgrn, OUTPUT);
    pinMode(O_LEDblu, OUTPUT);
  
    pinMode(I_home, INPUT_PULLUP);
  
 //   EEPROM_readAnything(step1add, stepper1pos);
 //   EEPROM_readAnything(step2add, stepper2pos);
 //   EEPROM_readAnything(step3add, stepper3pos);
    
    stepper1.setCurrentPosition(stepper1pos);
    stepper2.setCurrentPosition(stepper2pos);
    stepper3.setCurrentPosition(stepper3pos);
  
    stepper1.moveTo(HOME); //set target as home
    stepper2.moveTo(HOME); //set target as home
    stepper3.moveTo(HOME);
  
    attachInterrupt(1,goHome,LOW); //interrupt1 is on pin 3 - takes the buttons on the housing pressed simultaneously, while they are held, goHome drives the thing home
  
    digitalWrite(O_LEDgrn, HIGH);
  
     // goHome(); //set it home
  
      Serial.begin(9600);
  }

    void loop(){
      Xpot = analogRead(I_potX);  
      Ypot = analogRead(I_potY);
      Zpot = analogRead(I_potZ);
    
      Aspeed = (Xpot+Zpot-1024)/1024;
      Bspeed = (-Xpot+Zpot)/1024;
      Cspeed = (-Ypot+Zpot)/1024;    //All [-1,1]. All take input from correct pots... not necessarily the right sign
    
      stepper1.setSpeed(maxSpeed*Aspeed); // Serial.println(Aspeed);
      stepper2.setSpeed(maxSpeed*Cspeed); // Serial.println(Cspeed);
      stepper3.setSpeed(maxSpeed*Bspeed);  //Serial.println(Bspeed);
    
 /*      if((stepper1.currentPosition() == inStop) || stepper1.currentPosition() == outStop){
      // stepper1.setSpeed(0);
       stepper1.run();
       }
       if((stepper2.currentPosition() == inStop) || stepper2.currentPosition() == outStop){
      // stepper2.setSpeed(0);
       stepper2.run();
       }
       if((stepper3.currentPosition() == inStop) || stepper3.currentPosition() == outStop){
      // stepper3.setSpeed(0);
       stepper3.run();
       }*/
    
      if((userEN != digitalRead(I_stickButton)) && userEN){
        stepper1pos = stepper1.currentPosition();
        stepper2pos = stepper2.currentPosition();
        stepper3pos = stepper3.currentPosition();
        Serial.println(stepper1pos);
        Serial.println(stepper2pos);
        Serial.println(stepper3pos);
        
      //  EEPROM_writeAnything(step1add, stepper1pos);
      //  EEPROM_writeAnything(step2add, stepper2pos);
      //  EEPROM_writeAnything(step3add, stepper3pos);
      }
    
      if(digitalRead(I_stickButton)){
        stepper1.runSpeed();
        stepper2.runSpeed();
        stepper3.runSpeed();
        userEN=1;
      }
      else{
        userEN=0;
      }
    
    
    
      force=analogRead(I_force);
      if(force<50){
        digitalWrite(O_LEDred, HIGH);
        digitalWrite(O_LEDgrn, LOW);
        digitalWrite(O_LEDblu, LOW);
      }
      else if(force<220){
        digitalWrite(O_LEDred, LOW);
        digitalWrite(O_LEDgrn, LOW);
        digitalWrite(O_LEDblu, HIGH);
      }
      else{
        digitalWrite(O_LEDred, LOW);
        digitalWrite(O_LEDgrn, HIGH);
        digitalWrite(O_LEDblu, LOW);
      }
    
    }

void goHome(){
  stepper1.moveTo(HOME);
  stepper2.moveTo(HOME);
  stepper3.moveTo(HOME);

  while( (stepper1.distanceToGo()!=0) && (stepper2.distanceToGo()!=0) && (stepper3.distanceToGo()!=0)){
    stepper1.run();
    stepper2.run();
    stepper3.run();
  }

}

So, I have a new ATMega chip in the mail, ready to be put in... but before it gets here [tomorrow hopefully] I would really love to understand how this became a problem... what did I do wrong? Any work around with my current chip?


Moderator edit: [code] [/code] tags added.
« Last Edit: February 27, 2013, 02:41:11 am by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Basically I have an arduino UNO R3 with ATMega 328P.
Using Programmer              : stk500v2

You have the wrong board selected.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Confused how that could be. I selected Uno back when I started working with this board, and it is still selected now:
When I go to tools -> Board, there are many boards to choose from, but the check mark is next to the only option for Arduino Uno
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The bootloader can't be programmed without some kind of programmer, which one are you using?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was trying to bootload from a working arduino onto this one. Ultimately I just swapped over the ATmega chip, and now my old one works fine. But I am still confused why this was an issue in the first place. I've located a possible intermittent external short to ground though, so I'm thinking I may have just fried my old chip. I'm going to run with the new one for now, and hope it doesn't happen again....
Logged

Pages: [1]   Go Up
Jump to: