Pages: [1]   Go Down
Author Topic: Using Serial I/O - first time  (Read 891 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.

Code:
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?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 547
Posts: 45995
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16470
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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:

Code:
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
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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.
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).

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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. smiley Share the results if you can, please! smiley
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).

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8433
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Rob Gray aka the GRAYnomad www.robgray.com

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12285
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
https://sites.google.com/site/terminalbpp/

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

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 121
Posts: 8433
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I use Tera Term

http://ttssh2.sourceforge.jp

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

______
Rob


Logged

Rob Gray aka the GRAYnomad www.robgray.com

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: