Using Serial I/O - first time

I wanted to see if I could get my Duemilanove talking to my MacBook Pro.
All of my projects have been output only- using DigitalWrite. This is the first time I've tried using
Serial I/O instructions and the serial port monitor.

I'm using the Arduino Ide ver 0022 on OSX 10.6.6.
I'm able to compile & download to the Arduino.

I've made a very short sketch to send serial data to the serial port monitor.

void setup() {
	Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
}


void loop() {

  Serial.println("Serial test");
  Serial.println("Serial 1");
  Serial.println("Serial 2");
  Serial.println("Serial 3");

}

The sketch compiles & runs just fine.
I can see the text in the serial port monitor.

So I thought- why not test it at a higher baud rate.

When I change Serial.begin(9600) to 38400 and anything higher (and set the baud rate in the monitor appropriately),
the text going to the monitor is much slower and jerky, than at 9600.

Is this simply because the monitor can't scroll fast enough to show the text cleanly at higher baud rates, or
am are my expectations wrong?

Is this simply because the monitor can't scroll fast enough to show the text cleanly at higher baud rates

Yes.

Is this simply because the monitor can't scroll fast enough to show the text cleanly at higher baud rates, or
am are my expectations wrong?

Well you can prove it to yourself by placing delays between the print statements and see if output is as you would expect at whatever baudrate you want to test at:

void setup() {
	Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
}


void loop() {

  Serial.println("Serial test");
  delay(500);
  Serial.println("Serial 1");
  delay(500);
  Serial.println("Serial 2");
  delay(500);
  Serial.println("Serial 3");
  delay(500);

}

Lefty

I'll try this shortly.

I forgot to mention- that when I switched to 115200, the Arduino IDE & monitor locked up.
I had to kill the process in order to launch the IDE again, to restore the baud rate to 9600.

cappy2112:
I'll try this shortly.

I forgot to mention- that when I switched to 115200, the Arduino IDE & monitor locked up.
I had to kill the process in order to launch the IDE again, to restore the baud rate to 9600.

That is expected. No matter how good your computer is, having all that data to process is going to slow it to a halt.
115kbps
Try adding some delays between strings being sent over the terminal to give some time for the computer to receive and process all the data or send strings while a button is pushed so you can see this.

Normally the Arduino software would be doing something inbetween sending strings to the computer.

cappy2112:
I'll try this shortly.

I forgot to mention- that when I switched to 115200, the Arduino IDE & monitor locked up.
I had to kill the process in order to launch the IDE again, to restore the baud rate to 9600.

That seems to have made some difference, it now takes longer to hang the Arduino IDE, and the Mac.
I did this on the Mac because I thought OSX was a better OS than Windows.
After unplugging the Arduino from the USB port, the Mac was no longer able to see the Arduino when I plugged it back in.

When I tried restarting the system, the OS began to shut down but stopped. I had to press the power button to turn the machine off.
A serial stream of data shouldn't be so harmful to an app or an OS. Look how fast SATA comes across the wire. Its up to 6Gb/sec.

cappy2112:
A serial stream of data shouldn't be so harmful to an app or an OS. Look how fast SATA comes across the wire. Its up to 6Gb/sec.

Considering that the SATA bus is, although thinner than parallel, much wider than the serial connection and that it has dedicated hardware to deal with those signals, I think it isn't a valid comparison.

Add the fact that the Arduino is not native USB and is communicating through a driver... and the speeds get quite a big reduction.

But, a good test to be made is to repeat the experience in Windows. Please, don't take this as a fanboy remark. I'm genuinely interested in knowing how both OS's will behave under these conditions. :slight_smile: Share the results if you can, please! :slight_smile:

USB also has dedicated hardware on both ends.
SATA isn't a bus, it's a point to point interface.
SATA is just as serial as USB. The fact that the cable is "wider" is irrelevant. The data is sent over a differential twisted pair of wires in each direction. That requires 4 wires, the other 3 wires are grounds. Commands and data are still sent serially even though two wires are used for transmission.

I'll try to repeat the experiment on Windows and report what happens.

Given that this is the first time I'm using serial i/o on the arduino and the results have been quite disappointing,
what other problems should i know about in advance?

I would like to report the monitor problem with the serial stream to the developers.
The app shouldn't be crashing. Terminal programs have been around since computers first existed and can deal with high baud rates just fine.

I always use 115200 for comms to a PC, and while I've never written an explicit test I've also never noticed a missed character and it's never even got close to locking up or even noticeably slowing the computer.

However I don't use the IDE serial monitor, I use a proper terminal program.


Rob

That makes sense.

I will do that in the future. I hadn't used the monitor in the IDE before because my previous Arduino projects just turned pins on or off statically.
It's actually pretty useful to be able to send data to the arduino using the monitor for debugging purposes, but this too could be done from a terminal program.
The user would just have to keep opening/closing the ports when switching between the IDE & the terminal program, which is inconvenient.

Graynomad:
I always use 115200 for comms to a PC, and while I've never written an explicit test I've also never noticed a missed character and it's never even got close to locking up or even noticeably slowing the computer.

However I don't use the IDE serial monitor, I use a proper terminal program.

Speaking of "proper terminal programs"...

Nice user interface but drops / corrupts data at all baud rates...

Horrible user interface but rock-solid data handling...
http://realterm.sourceforge.net/

I use Tera Term

Nice clean UI I think and as far as I know reliable.


Rob

Yeah, but its old as the hills and hasn't been updated since 2002
We use this at work though. The later version supports 256 com ports