Offline
Newbie
Karma: 1
Posts: 35
|
 |
« on: February 22, 2013, 01:18:20 pm » |
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. 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
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 100
Posts: 9548
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #1 on: February 22, 2013, 01:19:32 pm » |
you must change the baudrate in the serial monitor too (did you do that?)
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen / Denmark
Offline
Edison Member
Karma: 5
Posts: 2346
Do it !
|
 |
« Reply #2 on: February 22, 2013, 01:25:34 pm » |
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
Online
Brattain Member
Karma: 142
Posts: 19339
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: February 22, 2013, 01:34:07 pm » |
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.
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 35
|
 |
« Reply #4 on: February 22, 2013, 01:46:47 pm » |
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
Edison Member
Karma: 50
Posts: 2157
|
 |
« Reply #5 on: February 22, 2013, 03:03:21 pm » |
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
Faraday Member
Karma: 37
Posts: 6042
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #6 on: February 22, 2013, 03:30:24 pm » |
There is no reason this won't work. Anyway, have you tried the examples in Arduino example yet?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 35
|
 |
« Reply #7 on: February 22, 2013, 07:10:20 pm » |
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. 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
Faraday Member
Karma: 37
Posts: 6042
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #8 on: February 22, 2013, 08:38:43 pm » |
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
Newbie
Karma: 1
Posts: 35
|
 |
« Reply #9 on: February 22, 2013, 08:42:59 pm » |
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-ShieldI 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: 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 
|
|
|
|
« Last Edit: February 22, 2013, 08:45:09 pm by dmor574 »
|
Logged
|
|
|
|
|
Rome, Italy
Offline
Sr. Member
Karma: 20
Posts: 442
|
 |
« Reply #10 on: February 22, 2013, 08:49:22 pm » |
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'á...
|
|
|
|
« Last Edit: February 22, 2013, 08:51:49 pm by spatula »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 35
|
 |
« Reply #11 on: February 22, 2013, 08:56:36 pm » |
Just to be safe, I tried the following: 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
Brattain Member
Karma: 282
Posts: 15435
Measurement changes behavior
|
 |
« Reply #12 on: February 22, 2013, 09:00:44 pm » |
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
God Member
Karma: 9
Posts: 839
|
 |
« Reply #13 on: February 22, 2013, 09:06:19 pm » |
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
Newbie
Karma: 1
Posts: 35
|
 |
« Reply #14 on: February 22, 2013, 09:06:43 pm » |
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
|
|
|
|
|
|