Strange behavior with screen and Arduino uno serial port

Hi There,

I have an arduino uno that I'm playing with. I've written an extremely simple sketch:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Test");
}

void loop() {
  // put your main code here, to run repeatedly: 
 // while(Serial.available()){
 //    Serial.print((char)Serial.read()); 
 // }
 Serial.println("BLAH!\n");
 delay(50);
}

I compile/download and then open up the terminal on my mac. I run screen:

screen /dev/tty.usbmodemfa131 -115200

I get a bunch of garbage out. If, however, I use the serial console provided by the arduino IDE I get the expected output. The interesting thing is that if I chance the baud rate in the sketch to 9600 screen does just fine and I see the expected output. Any ideas? I really can't stand the arduino IDE and don't like being tied to it. Thanks,

D

This has something to do with the speed the arduino IDE is setting the serial port at, not very close to the actual 115200 number. That was for a past IDE version. What IDE version are you using?

Interesting.. I'm using 1.01. When you say that the IDE is setting the serial port do you mean the computer's port or the hardware's port?

doov:
Interesting.. I'm using 1.01. When you say that the IDE is setting the serial port do you mean the computer's port or the hardware's port?

I don't know what you mean by hardware port, arduino hardware port?
The 115200 is not very accurately set since 16MHz and 115200 are not matching. This offset can be compensated if the usb ttl chip is set at a proper rate, not exactly 115200. I thought arduino ide does that.

You stated that the arduino ide sets the port at something close to, but not exactly 115200. There are two ports - one on the computer and one on the physical arduino. When I use screen and say:

screen /dev/tty.whatever -115200

I tell my computer to configure my computer's port at 115200 baud.

When I say:

Serial.begin(115200)

I tell the arduino's port to be configured to 115200 baud.

Given that the arduino IDE's serial port monitor feature does capture data correctly and screen does not I'm wondering if you meant that the IDE is setting the arduino's hardware to something not quite 115200 or if it's configuring my machine's port to something not quite 115200 or both.

In all cases one of the nice things about uart/rs-232 communication in general is that the baud shouldn't have to be exact. You should be able to take a 16 MHz clock and use proper prescalers to get something close enough to 115200. If the hardware design is remotely good then it'll typically try to sample in the middle of a bit such that some shift/skew can be tolerated. That stated if it's really far off then there are problems.

Are you suggesting that the arduino IDE is really misconfiguring the port to something significantly different than 115200? And then I'd assume you suggest that the IDE's serial monitor correctly configures my computer's port to whatever that offset frequency is?