Pages: [1]   Go Down
Author Topic: Help! High Speed RS485 Serial Software  (Read 1713 times)
0 Members and 1 Guest are viewing this topic.
France
Offline Offline
God Member
*****
Karma: 11
Posts: 642
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I plan to use my Arduino as slave connected to a 921 600 bauds RS485 master. I can't lower the 921 600 speed of the bus.

On the Arduino, I changed the standard 16 MHz crystal for a 14,7456 MHz one so the frequency divider is clean: 14 745 600 / 16 = 921 600
The RS485 to serial converter is a SN65176B / SN75176B.

Now, on the software part:
  • Does the standard Arduino Serial library manage the 921 600 bauds speed?
  • Could I use the NewSoftSerial library with 921 600 bauds speed, in order to connect the SN65176B / SN75176B to other Arduino pins (eg. 2 and 3) and keep standard 0-RX / 1-TX pins for debugging?
  • In case there's no answer to the previous questions, has someone written or used a specific high-speed serial library I could use?

I really appreciate your help! Thank you.

I've read so far
http://real2electronics.blogspot.com/2009/09/arduino-and-rs485-english-version.html
http://arduino.cc/forum/index.php/topic,36561.0.html
as well as mentioned links.
Logged


nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8531
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's nearly a character every uS. If the data is non-stop you will never keep up. If it's in bursts you should be able to, but I don't know if the standard hardware serial library will cope, I doubt it because it uses interrupts and I can't see an interrupt approach working at this speed, it takes longer than a uS just to service the interrupt.

None of the softserial libs have a chance.

I think a very tight loop that polls the char available flag and saves to RAM would work.

How many bytes are you receiving and how often?

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
That's nearly a character every uS.

Rob, it's late in the evening and I'm sitting here on my couch with a nice brandy - just right atmosphere for hair splitting. 921600 is only 1 bit every µs, so he'll have 10µs per character. But that doesn't really change matters and all you wrote about the timing being tight and forgetting all those soft serials are still true.

However, if he isn't receiving data but mostly sending, the whole thing will probably just work fine. One doesn't need to send at full speed.

Korman
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8531
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Doh, yes that's right. A 10:1 difference isn't to be sneezed at smiley, still tight but not as bad as I said.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

France
Offline Offline
God Member
*****
Karma: 11
Posts: 642
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour,

Thank you for the answers.

Presently, I'm fighting to set the right speed:
  • I updated boards.txt and added a specific entry for the Arduino Board 5V 14,7456 MHz ATmega328
  • I built the specific ATmegaBOOT_168_atmega328_14_7MHz.hex
  • I hope to perform the update today through Arduino ISP

Another solution would be to swap the crystal, using a 16 MHz for downloading and a 14,7456 MHz for running, and perform some trick on Serial.begin(1000000).

Stay tuned!
Logged


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

I just want to point out that whilst you can get 92,160 bytes per second at 921,600 baud, you can get 333,000 bytes per second using SPI. That's over three times as fast. Now I know you said you need to use a a 921600 bauds RS485 master, but if the reason for doing that is just speed, consider SPI instead.

If you Google "protocol conversion spi RS485" you will find quite a few protocol converters. It might be practical to just get one of those chips, fire off your data at it using SPI, and let it do the work.
Logged


France
Offline Offline
God Member
*****
Karma: 11
Posts: 642
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bonjour Nick,

Thank you very much for the tip.

I'm presently facing two issues:
  • upload without auto-reset and
  • speed not in accordance with the 14.7456 MHz crystal.

So I opened a new thread Help! ATMega328P at 14.7456 MHz.
Logged


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

I doubt that software (bit-bang) serial would work at that rate. If you must debug with serial, swap them around. Use hardware serial for your gadget, and low-speed software serial to send out debug messages.
Logged


Pages: [1]   Go Up
Jump to: