Pages: [1]   Go Down
Author Topic: Stuck in Uploading to I/O Board with Mega 2560  (Read 9285 times)
0 Members and 1 Guest are viewing this topic.
Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am currently running into a condition where my sketch will not complete uploading to my Arduino. The upload never seems to complete (even after 30min or so).

There are 4 commented lines in the attached code that appear to cause the problem. Removing the comments will cause the trouble readily. With those lines commented (and it appears to be the if specifically) the sketch uploads just fine.

Code:
int CurrentMin = 1345;
int Alarm1 = 1355;
boolean Alarm1Triggered = false;

void setup() {
  Serial.begin( 9600 );
}

void loop() {
  delay( 5000 );
  CurrentMin = CurrentMin + 1;
  Serial.println( CurrentMin );
  Serial.println( Alarm1 );
  if ( Alarm1Triggered == false ) {
//    if ( CurrentMin == Alarm1 ) {
//      Alarm1Triggered = true;
//      Serial.println( "Alarm has gone off!!!" );
//    }
  }
}

Please note that this sketch is just a sample to demonstrate the problem and is actually a very simplified subset of a bigger sketch. I am basically a beginner with the Arduino so maybe I missed something simple.

So can someone tell me what I am doing wrong?
Logged

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

You can try tu update your software. or recup an more old version. have you rightly selected your board?
« Last Edit: January 08, 2011, 03:07:16 am by yeroddyn » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just tried uploading the code to a Duemilanove, after uncommenting the lines. It uploaded with no problems. It even works.

The numbers that are printed should have some identifiers in front of them, to define what they are, but that is all that I see is wrong.
Logged

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using Arduino IDE 0022, so I already have the latest. I have my board selected correctly (Arduino Mega 2560) from the Tools - Board selection.

It is very odd. If I comment them everything uploads fine but with them uncommented it does not work. I tried adding the identifiers but that did not affect it at all. I wonder why it works differently on an Duemilanove (ie: it works). Are you using Windows or a different OS?

What is most frustrating is that without those lines it works fine. I have a whole webserver input/output sketch I have made that works fine and can be uploaded without trouble but I really want to have an alarm timer built in and this if statement is making that look doubtful.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using Windows 7, 64 bit.

The identifiers a trivial. Whenever I print a number, I always print some identifier in front of it, so I can tell what the number means. I prefer that other people do that, too. If you don't want/need to, that's fine.

The only other thing I can think of that might explain the difference is that maybe one of the variable names is some sort of reserved keyword on the Mega, but that's really a stretch. You could try changing them to see if it makes any difference.

Perhaps someone else with a Mega 1280 or Mega 2560 could try uploading the sample, to see whether it uploads.
Logged

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok. So no difference in OS (I am using Windows 7, 64bit also). I renamed all the variables and did a search on the site for any matches to those names (no hits for exact matches). Still failing.

I think if someone has a Mega 2560 to check this on it might be useful. I would not think it is a flaw with the bootloader... BUT I was in software QA and I still have that wonderful computer aura of what can go wrong around me at times.

Here is the latest "failing" code. Note: Problem is not commented at this time. If someone DOES have a Mega and has the problem, comment out the if statement for the IncrementingInteger == AlarmTriggerInteger and see if it still fails.
Code:
int IncrementingInteger = 1345;
int AlarmTriggerInteger = 1355;
boolean BooleanAlarmTriggered = false;

void setup() {
  Serial.begin( 9600 );
}

void loop() {
  delay( 5000 );
  IncrementingInteger = IncrementingInteger + 1;
  Serial.print( "Incrementing integer: " );
  Serial.println( IncrementingInteger );
  Serial.print( "Alarm trigger integer:" );
  Serial.println( AlarmTriggerInteger );
  if ( BooleanAlarmTriggered == false ) {
    if ( IncrementingInteger == AlarmTriggerInteger ) {
      BooleanAlarmTriggered = true;
      Serial.println( "Alarm has gone off!!!" );
    }
  }
}
Logged

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

Hi, I've tried your code on my 2560 and I get a 'avrdude: stk500_2_ReceiveMessage(): timeout' error. This is on OSX with version 22 of the arduino IDE.

If I delete one of the exclamation marks it works. Seems that the compiler doesn't like strings containing more than 2 exclamation marks in a row!!!

Hope that helps.
Logged

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That was it?! I just tried it and sure enough it works just fine. I would say this is a definite bug for the 2560. Might be something in the bootloader. Fairly minor problem overall but who would think of it? I will check the problem lists to see if there is anything about this yet. If not I will submit it. Thanks very much for the help.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I had a similar problem and found this thread. After removing the exclamation marks in my code uploading works again.

I also tried your code. With the exclamation marks it won't finish uploading. Always displaying the following:
Quote
avrdude: stk500_2_ReceiveMessage(): timeout
Without the exclamation marks uploading works.

I'm using an Mega 2560 with an EthernetShield. And Ubuntu 10.04 with Arduino 0021 64bit.
Logged

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

I meant to say IDE instead of compiler, but the same error on three different systems points to a bug specifically with the Mega. As you say, definatly a wierd one!
Logged

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I created this thread in the Bugs & Suggestions category:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294536128/0#0

I will edit it to add the point about you trying with Ubuntu and using 0021. I do not know if anything would result from it but it does not hurt to include all the details.

Does anyone reading this have an Uno they could try this out on? I am curious about whether it is a Mega 2560 problem or both of the new Arduinos being affected.
« Last Edit: January 09, 2011, 10:19:51 am by fillibar » Logged

Leighton Buzzard, UK
Offline Offline
Edison Member
*
Karma: 21
Posts: 1339
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just tried it on a UNO
works fine
uploaded ok and serial monitor is showing

Alaarm trigger integer xxx
Incrementing integer xxx
Alarm has gone off!!!
Logged

there are only 10 types of people
them that understands binary
and them that doesn't

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Excellent, thanks for the input about the Uno. So as much as can reasonably be tested this is a Mega 2560 specific problem.
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 42
Posts: 3285
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Did anyone try with longer strings??? replacing the exclamation mark with another character and trying again?

It might be something else than an exclamation mark...
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Rochester, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried with a variety of strings including many that are longer (since I have many debug strings built in as I learn) but I have not tried other specialty characters. Something to check... I will come back with some results.

Edit - Tried with sets of the following characters and all succeeded:
` ~ @ # $ % ^ & * ( ) - _ = + [ { ] } | ; : ' , < . > / ?

Obviously using the following will not work (and yes I tried to prove it):
\ "
And the infamous !
« Last Edit: January 11, 2011, 08:38:55 pm by fillibar » Logged

Pages: [1]   Go Up
Jump to: