stannickel / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

SoftwareSerial at 57600 baud in Uno gives garbled characters #971

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Connect XBee module running at 57600 baud to e.g. pins 8 and 9
2. Send data to XBee from e.g. a PC
3. Receive data from XBee using SoftwareSerial at 57600 baud

You would expect the data to be properly received in Arduino, but this only 
works correctly for 1 byte packets. If I send larger packets of data, only the 
first character is read correctly, the rest of the characters are garbled.

This does not happen when using serial speeds lower than 57600. 

This happened to me using Arduino 1.0.1 on Windows 7, with an Arduino Uno (have 
not tried any other versions of software or hardware).

I do not know if this is just a slight mismatch of the exact speeds, combined 
with perhaps the XBee not using exactly 57600 baud either (I remember seeing 
some info on the net saying the XBee serial speeds are also approximations). 
However, by slightly tweaking the delay constants in SoftwareSerial.cpp I was 
able to fix the problems. The following settings seemed to work for me:

  //  baud    rxcenter   rxintra    rxstop    tx
  { 57600,    10,        36,        36,       33,    },

Someone with an oscilloscope or logic analyzer could perhaps verify these 
slightly adjusted timings. I would also suggest modifying the debug code in 
SoftwareSerial to only output a DebugPulse for the stop bit, so the debugging 
would not mess with the actual timings so much..

Original issue reported on code.google.com by kri...@gmail.com on 30 Jun 2012 at 11:39

GoogleCodeExporter commented 9 years ago
Could you try this application with my AltSoftSerial library?

http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

Please be aware that AltSoftSerial requires specific pins for transmit and 
receive.  You can't just select any pins you want, as with normal 
SoftwareSerial.  But it uses the 16 bit timer's input capture and waveform 
output features (which are only on specific pins) to dramatically reduce 
interrupt latency.

Original comment by paul.sto...@gmail.com on 3 Jul 2012 at 7:43

GoogleCodeExporter commented 9 years ago
I've just seen this same problem when using a Uno with an RFD900 radio modem 
(http://www.rfdesign.com.au/rfd900) which has an Si1000 uC on it. The nominal 
error of its baudrate generator at 57600 is 0.15%.

The suggested new timings work correctly.

Original comment by pel...@gmail.com on 11 Feb 2013 at 8:15

GoogleCodeExporter commented 9 years ago
I have seen this on an Uno also 38,400 worked best with my Xbee Arduino system

http://kiwitricopter.blogspot.co.nz/2012/10/simple-arduino-rx.html

Original comment by nickatre...@gmail.com on 11 Feb 2013 at 8:23