Go Down

Topic: USB communications on mega 2560 (Read 1 time) previous topic - next topic

jferg

here'a the code, look familiar?:
Code: [Select]
/*
  Character analysis operators

Examples using the character analysis operators.
Send any byte and the sketch will tell you about it.

created 29 Nov 2010
by Tom Igoe

This example code is in the public domain.
*/

void setup() {
 
  // Open serial communications:
  Serial.begin(9600);

  // send an intro:
  Serial.println("send any byte and I'll tell you everything I can about it");
  Serial.println();
}

void loop() {
  // get any incoming bytes:
  if (Serial.available() > 0) {
    int thisChar = Serial.read();

    // say what was sent:
    Serial.print("You sent me: \'");
    Serial.write(thisChar);
    Serial.print("\'  ASCII Value: ");
    Serial.println(thisChar);

    // analyze what was sent:
    if(isAlphaNumeric(thisChar)) {
      Serial.println("it's alphanumeric");
    }
    if(isAlpha(thisChar)) {
      Serial.println("it's alphabetic");
    }
    if(isAscii(thisChar)) {
      Serial.println("it's ASCII");
    }
    if(isWhitespace(thisChar)) {
      Serial.println("it's whitespace");
    }
    if(isControl(thisChar)) {
      Serial.println("it's a control character");
    }
    if(isDigit(thisChar)) {
      Serial.println("it's a numeric digit");
    }
    if(isGraph(thisChar)) {
      Serial.println("it's a printable character that's not whitespace");
    }
    if(isLowerCase(thisChar)) {
      Serial.println("it's lower case");
    }
    if(isPrintable(thisChar)) {
      Serial.println("it's printable");
    }
    if(isPunct(thisChar)) {
      Serial.println("it's punctuation");
    }
    if(isSpace(thisChar)) {
      Serial.println("it's a space character");
    }
    if(isUpperCase(thisChar)) {
      Serial.println("it's upper case");
    }
    if (isHexadecimalDigit(thisChar)) {
      Serial.println("it's a valid hexadecimaldigit (i.e. 0 - 9, a - F, or A - F)");
    }

    // add some space and ask for another byte:
    Serial.println();
    Serial.println("Give me another byte:");
    Serial.println();
  }
}

Exact same thing that comes with the download.  After more fussing, I find if i load it to the MEGA 2560 from Ubuntu installation of Arduino 1 IDE, it appears to load but will not run and the "L" led flashes slowly. If i change the board to UNO, and load it same way it works.  I thought it might matter WHEN I switched the board selection in the IDE so i went all the way out, then reloaded IDE, switched board to MEGA 2560, and no joy - works with UNO, doesn't with MEGA.

Now we come to the good part.  It works fine with either board on the Windows XP Arduino 1.0 IDE installation. AND, if I load it using the Windows IDE, it will run both on Windows and Ubuntu, so it must have something to do with the way the IDE loads the code under Ubuntu - possibly something's messed up in the Ubuntu cores, or ??

So i submit that there is a difference in the way the Ubuntu loader works between the UNO and the MEGA 2560 which matters.  If there is a difference between the UNO and MEGA loaders in Windows, it doesn't matter.

I might add that I had the same trouble everyone else has loading new sketches over earlier short sketches on the UNO from Ubuntu until I started putting delay(5000) at the head of the setup.  Before i caught on to that, I would have to go to the windows installation, which didn't seem to have this timing interface problem, and load a trivial example, which i could then overwrite in ubuntu.

to summarize, problem could be:
1. UNO and MEGA do not treat USB port same and it matters on Linux but not on pc.
2. Ubuntu loader that works on UNO but not on MEGA has software problem in cores (maybe)?
3. soemthing else related to Ubuntu handling of loading on MEGA.

I'm going to try loading my serious code from Windows next to see if it loads properly.

What does the slow flashing "L" mean?



SurferTim

Where did you get the IDE v1.0? Is that version now available on the Ubuntu repository, or did you download it from the Arduino site?

I haven't checked the repository version in a while.

jferg

#7
Feb 17, 2012, 04:29 pm Last Edit: Feb 17, 2012, 05:10 pm by jferg Reason: 1
Hi Tim,
both windows and ubuntu IDE's were downloaded from Arduino site.  A more complex sketch which loads on UNO from Ubuntu IDE does not load correctly on MEGA and produces flashing L. So far, i have not been able to load anything to the MEGA from Ubuntu Arduino 1.0 IDE.  I'm running Ubuntu 10.10 and I surely cannot be the only one, can I?

This isn't something that is going to shatter my day, but it does seem odd.  It could be that there actually is a bug in the Ubuntu MEGA load, or the Ubuntu based libraries and core contain something that's hostile to usb serial, that is not in the pc version.  

now that I know i can make this work by loading on windows, it isn't a big problem, but I'd much rather be running on Linux.

It also appears that Sparkfun's Screwshield which is a very nice prototyping connection board that works fine with the UNO, doesn't work with the MEGA.  Symptom is bizarre LED flashing which bespeaks reset interface on shield??

i might add that the traces on the prototyping section of this board are connected in a pattern which seems beyond my imagination to use.  It would have been nice to have a row down the middle that would support installation of max232 so i could get some rs232 signals in and out, but if there is a way to do this without a lot of trace cutting which is difficult on this very well-made board, i havn't figured it out, but then topology was never a strong suit of mine.

If anyone wants to pursue any this, I'll be glad to try other things.

and thanks to all who tried to help me with this.

john

SurferTim

Did you download the Ubuntu repository version of the Arduino IDE before downloading v1.0 from the Arduino site?

I know this sounds strange, but I would recommend installing the IDE from the Ubuntu repository. It is not just the IDE it installs, but all the avr-gcc and avr-libc files will be upgraded to the debugged versions.

IDE v1.0 on Ubuntu v11.10 works great, if you download v0022 from the repository first. It does for me anyway.


jferg

#9
Feb 17, 2012, 06:19 pm Last Edit: Feb 17, 2012, 06:23 pm by jferg Reason: 1
Tim,
this sounds good.  I'll let you know.  urk! you say ubuntu 11.10?  I'm running 10.10.  is it possible that the debugged code is only available for 11.10 ?



best regards, john

Go Up