Pages: [1] 2   Go Down
Author Topic: Faster Serial  (Read 1843 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone. I can't manage to get reliable SoftwareSerial (Arduino 1.0) communication to happen between two Arduino Unos if I use over a 9600 baud rate. Bytes get mixed up above that speed. Has anyone managed to get a fast and reliable HARDWARE serial baud rate between two MCUs? What do we do if we need a serial baud rate of say, 250,000 baud?

Thanks,
Greg
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Hello everyone. I can't manage to get reliable SoftwareSerial (Arduino 1.0) communication to happen between two Arduino Unos if I use over a 9600 baud rate.
With what connected to what? Running what code?

Quote
Has anyone managed to get a fast and reliable HARDWARE serial baud rate between two MCUs?
If you are trying to get hardware serial going, why are you using SoftwareSerial?

Quote
What do we do if we need a serial baud rate of say, 250,000 baud?
Get a different microcontroller that supports that speed. The fastest supported speed on the Arduino is 115200.

What are you trying to send between the boards that requires that speed?
Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 719
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Paul,

I presume you are referring to the Arduino IDE, not the Atmel microprocessor, right?

Per the Atmel spec sheet, the 328P appears to support 1,000,000 baud connections in hardware with a 0% error rate while running at a 16MHz system clock.  (see page 201 in http://www.atmel.com/dyn/resources/prod_documents/doc8025.pdf, the relevant datasheet). Is there a particular reason that the IDE does not offer more speeds for users to choose amongst? Consider that the error rate appears to be lower at 250,000 baud than at 56,700 baud...

Or is there a way to modify a preference somewhere within the Arduino IDE to expand the range of baud settings? I couldn't find any references to allowable baud speeds in the preferences.txt file... just the last one used.

I am sure there is a very good reason why some of the baud rates that Atmel lists as superior in performance to the ones used by the IDE are not used. I just don't know know enough about the subject... but if you happen to have that info handy, I'd appreciate being enlightened. Many thanks!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I'll try again... I need to find a way to interface one arduino (master) with multiple arduino devices (slaves) via TTL serial at a decent baud rate with a low error rate. I was thinking SoftwareSerial might be a solution as you can have multiple serial outs but I'm not finding good speeds with low error.

Can HardwareSerial be hacked in order to let me use a higher baud rate than 115,200? Even if not is there a solution for some sort of TTL serial switch IC where I can switch between sending commands to multiple devices over one hardware serial UART?

Thanks!
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I'll try again... I need to find a way to interface one arduino (master) with multiple arduino devices (slaves) via TTL serial at a decent baud rate with a low error rate. I was thinking SoftwareSerial might be a solution as you can have multiple serial outs but I'm not finding good speeds with low error.

Can HardwareSerial be hacked in order to let me use a higher baud rate than 115,200? Even if not is there a solution for some sort of TTL serial switch IC where I can switch between sending commands to multiple devices over one hardware serial UART?

Thanks!

Is there a reason why you can't use SPI or I2C? It would seem your need for a such a bus is justified (now, there might be distance issues)...
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 524
Posts: 26473
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Am I missing something here as far as connections go?
Master sends to all slaves, only selected slave (software address - "Hey, that's me!") responds...

With TTL connections between parts, lines are low between data bytes so any high from a slave becomes a high out of the OR gate.
(unless I have it backwards, then use a 4 input AND gate instead, and any low becomes a low of the AND gate).
So the slave have to play nice or data get garbled.

At 115,200, you only got 86uS to read the data from the serial port, decide what to do with, etc, before the next byte comes in.
That's 138 clock cycles, not a lot of instructions to be doing stuff.

You don't want to be wasting time sending out 2 address lines to be switching some kind of mux chip. That would imlpy your slaves are out of control and sending stuff willy nilly, and then you lose even more time getting ones attention to send you proper stuff.
Or letting them ramble, and lose some time figuring where the state a  data sequences is.


* Serial Master Slaves.png (8.57 KB, 693x349 - viewed 12 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a reason why you can't use SPI or I2C? It would seem your need for a such a bus is justified (now, there might be distance issues)...

I can't use i2c due to distance being too short (I need at least 10 meters) and SPI is already in use for interfacing with some flash memory...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Am I missing something here as far as connections go?
Master sends to all slaves, only selected slave (software address - "Hey, that's me!") responds...

With TTL connections between parts, lines are low between data bytes so any high from a slave becomes a high out of the OR gate.
(unless I have it backwards, then use a 4 input AND gate instead, and any low becomes a low of the AND gate).
So the slave have to play nice or data get garbled.

At 115,200, you only got 86uS to read the data from the serial port, decide what to do with, etc, before the next byte comes in.
That's 138 clock cycles, not a lot of instructions to be doing stuff.

You don't want to be wasting time sending out 2 address lines to be switching some kind of mux chip. That would imlpy your slaves are out of control and sending stuff willy nilly, and then you lose even more time getting ones attention to send you proper stuff.
Or letting them ramble, and lose some time figuring where the state a  data sequences is.

Would it be OK if I split the TX line 6 ways (serial is going to 6 devices)? I am a little worried about line loss over 10 meters+. Do people use distribution amplifiers for this kind of stuff?

I'm not constantly sending out a stream of bytes to all the serial devices - only every 2ms each device is sent 4 bytes of data to be processed and integrated into a closed-loop PID. I would like the baud rate to be as high as possible (has anyone gone above 115200 on HardwareSerial??) so that the PID can be as tight as possible.
« Last Edit: January 01, 2012, 03:16:25 am by gcotten » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 524
Posts: 26473
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, buffer it & send to as many as you want.
Can use RS232 , RS422 drivers & recievers even if you wanted.
MAX232, MAX3488 or equivalent type parts.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 719
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Crossroads!

In my particular application, I have a 328P talking to a 1284P, hardware serial, sending short data packets (a couple of bytes) every second. Basically, the 328P acts as a DAQ, manipulating the results, and sending summaries to the 1284P which samples other data meanwhile before writing it to micro-SD and/or transmitting via NRF+. Speeding up the serial bus increases the number of samples/s the 328P is able to collect. Using a serial bus between the Atmels is convenient for debugging purposes and EasyTransfer makes getting the data from one Atmel to the other one almost trivial. I just found out that someone implemented EasyTransfer via I2C, that certainly sounds interesting!
Logged

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

Quote
The fastest supported speed on the Arduino is 115200. ...

Note that the Arduino can send faster but the IDE is the limiting factor here. Switch to a (real) terminal program like putty.exe or ...

More see - http://arduino.cc/forum/index.php/topic,61381.msg444421.html#msg444421 -
Logged

Rob Tillaart

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

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 719
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, Rob. That link contains good info and seems to confirm my interpretation of the Atmel 328P datasheet. I wonder if you would have any luck with a 1Mbit/s transfer rate since Atmel seems to indicate this as one of their 'legal' serial speeds. I plan on trying it out tonight...
Logged

Peoples Republic of Cantabrigia
Offline Offline
God Member
*****
Karma: 6
Posts: 719
Arduino happiness
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

FWIW, and that is probably purely academic, the Atmels are communicating fine via serial at 1Mbit/s.  smiley-lol

The resultant improvement is fairly marginal in impact (~60 additional samples/second, IIRC, for the 328P or about 1.5%) but I'll take the free additional samples... even if there is some impact on usability thanks to the IDE not supporting that speed. Cheers!
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Glad to hear that. You might look into RS485 for cabling the longer cable runs. Since you are writing to an SD card (an inherently slow operation) I would have thought that really high speed transfers wouldn't really be required. As for SPI, you can deselect the SD card and address another device. My timings indicate you can transfer around 333,333 bytes per second using SPI, but I'm not sure about the long cable runs. Using I2C you should be able to look at around 40,000 bytes per second.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
FWIW, and that is probably purely academic, the Atmels are communicating fine via serial at 1Mbit/s.
Which version of the IDE are you using? With 1.0, outgoing serial data is buffered, so the Serial.write() function is no longer blocking. I would think that generating the data to send would take longer than actually moving the data to the buffer, so I'd think that moving the data out of the buffer 8 times as fast would have nearly no impact.

Prior to 1.0, serial output was blocking, so moving it out faster would have a small effect on samples per second.
Logged

Pages: [1] 2   Go Up
Jump to: