Pages: [1] 2   Go Down
Author Topic: Changing Baud Rate Doesn't Work  (Read 1900 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to change the baud rate on the serial transfer higher and there is no reason for this not to work with a barebones program.

Code:
void setup() {
Serial.begin(14400);
}

void loop() {
Serial.println("Test");
}

I have an Arduino Uno and tried this originally with no answer or solution and thought it was a hardware problem. I now have a new Arduino Mega and it gives me the same problem. I've tried every single Baud Rate in code and in the serial monitor's drop down menu.

Why am I getting random ASCII characters? This is clearly a software problem, seeing as I tried this on over 2 Arduino boards. Do I have to change the USB settings on my laptop?

Thanks, and please help with this.. This has gone unanswered for too long. Most forums with this question have it randomly start working for no reason which doesn't help me find out why.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13921
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you must change the baudrate in the serial monitor too (did you do that?)
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

And if you do not put a delay in your loop it's going to execute the serial.println statement thousands of times every second which will result in totally unpredictable results.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26538
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And if you do not put a delay in your loop it's going to execute the serial.println statement thousands of times every second which will result in totally unpredictable results.
What will be unpredictable?
Irritating and repetitive, maybe, but not unpredictable.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I've changed the baudrate in the serial monitor as I mentioned in the question.

I'll test it later but can anyone verify the answer to add a delay?
« Last Edit: February 22, 2013, 07:16:36 pm by dmor574 » Logged

California
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3443
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll test it later but can anyone verify the answer to add a delar?

It takes about 20 seconds to test...
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7272
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is no reason this won't work. Anyway, have you tried the examples in Arduino example yet?
Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I wasn't home when I posted this question. The following code gives me an output of: "áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'á" endlessly with the serial monitor set to 14400 baud with newline. I tested other options in serial monitor drop down as well.

Code:
void setup() {
  Serial.begin(14400);
}

void loop() {
  Serial.println("Test");
  delay(100);
}

I also looked at other examples, but most have a baud rate with 9600 (which always works perfectly).
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 75
Posts: 7272
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Some why do you have to use that non-working baud rate? Read the source code and see what actual rate is used?
Logged


Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bump.

Edit: I recently purchased a Pololu Dual VNH5019 Motor controller and tested it for the first time using their arduino library downloaded here: https://github.com/pololu/Dual-VNH5019-Motor-Shield

I uploaded the "demo" example to my Mega and the serial connection worked with 115200 baud rate! This makes no sense since I tried this earlier today with a barebones program like the following without success:

Code:
void setup() {
Serial.begin(115200);
}

void loop() {
Serial.println("Test");
}

I tried it again now and it works. Although no other baud rates work still. For those telling me to deal with it or just use what works, this doesn't answer my question! Why could this possibly happen... All I did was drag-n-drop the library into my arduino folder and a new baud rate works.

It appears all the answers to these questions just "randomly work"..I don't accept this smiley-razz
« Last Edit: February 22, 2013, 08:45:09 pm by dmor574 » Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Entirely predictable  smiley-wink That's the sequence* you get when serial monitor is set at 9600 baud.

What is the baud rate you see when you open the serial monitor? 9600, 14400? The serial monitor can be overloaded by the stuff it receives from the Arduino, and your changes will be ignored. So, in your sketch try to set a delay such as 5000 - it will not overload the serial monitor and allow you to set the baud rate. Then change again the delay in the sketch to a smaller value and see what happens.

[edit]* I was referring to áfr'áfr'áfr'á...
« Last Edit: February 22, 2013, 08:51:49 pm by spatula » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to be safe, I tried the following:

Code:
void setup() {
  delay(5000);
  Serial.begin(14400);
  delay(5000);
}

void loop() {
  Serial.println("test");
  delay(500);
}

The results are: "ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;CË4ÈK;"

PS: Post any program and i'll try it and let you know the results.
Logged

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

Try this. Press and hold down the reset button on your board. Now close the serial port. Recheck that you have the correct serial port number selected in the tools menu. Then reopen the serial monitor and make sure the baudrate shown in the lower right is correct or change it if it's not. Now release the reset button.

Lefty

Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What will be unpredictable?
Irritating and repetitive, maybe, but not unpredictable.

If the receiving device is overwhelmed by the amount of crap you are sending to it,
the result may well be unpredictable.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 35
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Same program with the long delays

result: "nr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'ánr'"

And it has 5 second delays before calling serial begin and after, as well as a half second delay between loops.. this is plenty
Logged

Pages: [1] 2   Go Up
Jump to: