Go Down

Topic: Changing Baud Rate Doesn't Work (Read 2130 times) previous topic - next topic

dmor574

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: [Select]

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.

robtillaart

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

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

MikMo

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.

AWOL


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

dmor574

#4
Feb 22, 2013, 07:46 pm Last Edit: Feb 23, 2013, 01:16 am by dmor574 Reason: 1
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?

Arrch


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


It takes about 20 seconds to test...

liudr

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

dmor574

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: [Select]
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).

liudr

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

dmor574

#9
Feb 23, 2013, 02:42 am Last Edit: Feb 23, 2013, 02:45 am by dmor574 Reason: 1
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: [Select]
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 :P

spatula

#10
Feb 23, 2013, 02:49 am Last Edit: Feb 23, 2013, 02:51 am by spatula Reason: 1
Entirely predictable  ;) 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'á...

dmor574

Just to be safe, I tried the following:

Code: [Select]
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.

retrolefty

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


michinyon

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.

dmor574

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

Go Up