PDA

View Full Version : [Question(s)] Arduino IDE Serial Monitor output on Linux



Stephen
10-02-2010, 01:49 PM
Hello all!

I've begun coding for the ArbotiX and the Dynamixel AX-12 servos using the Arduino IDE on Ubuntu Linux (with the BioloidController library). I've installed and configured everything according to the online instructions for the Arduino and the ArbotiX, and I'm able to load programs and control my servos no problem.

My problem lies with the Serial Monitor in the Arduino IDE. I'm trying to display servo data like position, load etc., and program debug output, but nothing will output to the Serial Monitor. Even a simple "Hello World!" produces no output.

e.g.

#include <ax12.h>

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

void loop() {
Serial.println("Hello World!");
delay(1000);
}

I read somewhere that the Serial Monitor on Linux will not work correctly with certain versions of GCC (edit: programs compiled with certain versions of GCC). I'm hoping someone here can help!

My setup is as follows (some of which I realise is redundant given my problem, but just in case... ;) ):

Ubuntu 10.04 LTS (32-bit version)
ArbotiX Robocontroller and the Pololu ISP
AX-12 servos (from the Bioloid Comprehensive Kit)
Arduino 0018 (with the BioloidController library)

From a terminal my versions of gcc (gcc --version) and avr-gcc (avr-gcc -version) are as follows:

gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
avr-gcc (GCC) 4.3.4

Does anyone else have a similar setup to mine and experience or knowledge of this issue?

Thanks,
Stephen

lnxfergy
10-02-2010, 03:01 PM
I've not had issues on Ubuntu. How are you connected to the ArbotiX? (the ISP doesn't act as a serial pass through, you need either XBEEs or an FTDI cable to see the serial output).

-Fergs

Stephen
10-02-2010, 03:22 PM
I've not had issues on Ubuntu. How are you connected to the ArbotiX? (the ISP doesn't act as a serial pass through, you need either XBEEs or an FTDI cable to see the serial output).

-Fergs

I'm only connecting via the ISP to upload programs right now, I have two XBees and the SparkFun board for USB connection to my laptop, I've just not connected or configured them for use yet. Sounds like I need to do just that! Is this pretty straightforward to do on Linux? I'll look around the online documentation and these forums for info on setting up and using my XBees.

Thanks for the quick reply Fergs! I'm hoping to get output in the Serial Monitor today so I can continue "playing" with some real code!

Cheers,
Stephen

lnxfergy
10-02-2010, 03:33 PM
I'm only connecting via the ISP to upload programs right now, I have two XBees and the SparkFun board for USB connection to my laptop, I've just not connected or configured them for use yet. Sounds like I need to do just that! Is this pretty straightforward to do on Linux? I'll look around the online documentation and these forums for info on setting up and using my XBees.

Thanks for the quick reply Fergs! I'm hoping to get output in the Serial Monitor today so I can continue "playing" with some real code!

Cheers,
Stephen

Yep, as soon as you get a serial connection with your XBEEs, you should be seeing your output.

Take a look in the tutorials section here on the site, there is an XBEE tutorial that should get you setup.

-Fergs

Stephen
10-02-2010, 04:27 PM
Success! I've added one XBee to the arbotiX board and connected the other to my laptop. In the Arduino IDE I compile my program and select the corresponding USB port for my ISP programmer (Tools -> Serial Port), then upload my program. I then select the corresponding USB port for my XBee (again from Tools -> Serial Port) and open the serial monitor. I also found that I needed to set the baud rate to 9600, which I believe is the default for the XBees (I originally had this set to 38400, but would then just get incomprehensible output in the monitor).

Next step, change the default baud rate of the XBee! Most code examples I see around here seem to use 38400. Is 38400 the recommended baud rate for the XBee with the arbotiX?

Also I just need to remember to switch the serial port within the Arduino IDE every time I recompile and upload a new program, then bring up the serial monitor. Does anyone know of an easier way to do this? Perhaps add a default setting to a config file somewhere?

Thanks,
Stephen

P.s. I learned a valuable lesson here too... I became stuck with this lack of serial monitor output problem a day or two back, and went Googling for answers. I found a little information which did not actually relate to my problem and the reason for my lack of output. One quick post to these forums, and within minutes the exact answer to my issue! Issue resolved and lesson learned; use these forums first and foremost! Exceptionally knowledgeable and helpful people here! Thanks again Fergs!

lnxfergy
10-02-2010, 04:55 PM
Next step, change the default baud rate of the XBee! Most code examples I see around here seem to use 38400. Is 38400 the recommended baud rate for the XBee with the arbotiX?

The bootloader on the ArbotiX runs at 38400, so if you want to upload wirelessly, 38400 is a must (note our precautions about this, although, having an ISP, it's not much of an issue for you, but for future readers, read all precautions about wireless uploading). For that reason, we've settled on 38400 as the "standard" ArbotiX baud -- it's the baud rate all of our tools (such as PyPose, or the beta ROS support) default to 38400. Changing that baud rate is as simple as changing a line in code of course.

On a slightly different note, the XBEEs themselves operate best in the 38400-57600 range. While they support higher baud rates, if you are saturating the higher baud (i.e. you're sending a continuous stream of data at 115200bps) you'll start to see dropped packets, because there isn't enough bandwidth left to do packet resend/recovery.


Also I just need to remember to switch the serial port within the Arduino IDE every time I recompile and upload a new program, then bring up the serial monitor. Does anyone know of an easier way to do this? Perhaps add a default setting to a config file somewhere?

As far as I know, there's no way to get around this -- one of the reasons that some people like wireless downloading, or, like me, just use a different serial monitor (GTKterm is very good in Ubuntu, and is what I use).



P.s. I learned a valuable lesson here too... I became stuck with this lack of serial monitor output problem a day or two back, and went Googling for answers. I found a little information which did not actually relate to my problem and the reason for my lack of output. One quick post to these forums, and within minutes the exact answer to my issue! Issue resolved and lesson learned; use these forums first and foremost! Exceptionally knowledgeable and helpful people here! Thanks again Fergs!

We tend to respond quickly when it's a very direct, focused question, like this one. You'll probably note that we often don't respond to "Help me build this project, by giving me a complete parts list" type questions.

-Fergs