# High-speed RS232 logging

Does anyone have any recommendations on an embedded platform that would be able to handle RS232 at 921600 baud and log it to a microSD card or something similar?

-

According to my reading of the datasheet, an Atmel ATmega running at 20MHz (the max) can run its UART at up to 2222222 baud rate (~2.2Mbps), more than double the speed you need.

(BAUD = Fosc / (8 * UBBRn + 1))
with Fosc = 20000000 (20MHz)
and UBBRn = 0 (the minimum)


So the UART reading part should be no problem. The only question now becomes the writing to the SD card. You can do that over SPI, which is separate from the UART, so you can run them both in parallel with little overhead. According to this site, when running an ATmega at 8MHz (thus 4MHz SPI clock), you can write to a SD card at up to 140kB/sec. You only need ~128kB/sec, and ATmega's can run up to 20MHz (thus 10MHz SPI clock), so there shouldn't be a problem there.

-
I would consider that too close for comfort. –  starblue Jul 17 '10 at 8:56
@starblue: What's too close for comfort? Both the UART and the SD write speed are more than double he needs? (UART = 2.2MBps theoretical vs 0.92Mbps needed, SD = 350 kb/sec theoretical vs 112 kb/sec needed). @JustJeff: Since the AVR wont be doing much else, my idea is that you can use the internal memory of the AVR to have a larger buffer. Ideally you'd read a single byte from UART and write that byte to SPI, but I think there may be some delays inbetween each block when writing to SD, so you might need to buffer a few bytes inbetween? –  davr Jul 17 '10 at 15:50
Ah, I missed the factor of 2.5 in the clock frequency for writing the SD card. –  starblue Jul 17 '10 at 18:29

The Parallax Propeller will do serial full-duplex at 3 Mbps .

Of course, it will run out of memory in a hurry unless you put the data somewhere. Also, since the serial interface is run in one of the internal processor cores, in software, it is basically infinitely adjustable to any frequency between 0 and ~3 Mbps.

Here is the serial interface module
Also, there is a SD-Card module that supports FAT16/32 cards
I'm not sure if it can keep up with the serial interface though.

There are a lot of other useful pre-written object in the object exchange too.

Basically, the Propeller is awesome.
For those of you who aren't familiar, it's an 8-Core 32 bit microprocessor, with both a interpreted high level language, and a custom assembly language for speed-critical stuff.

I've found that it's possible to get away without actually having to use assembly at all, since there are so many available libraries. You mostly just need to write glue-logic to link them together.

-

Sparkfun has the OpenLog which does exactly that albeit at 9600 baud. It has a maximum configurable baud rate of 115200 though, perhaps at such a high speed you are better off using a logic analyser as discussed in here.

-
no it does not, I can't think of any 8 bit micros that have a high enough clock speed to work with 921600 –  penjuin Jul 17 '10 at 1:14
here is a much more powerful ARM7 board: sparkfun.com/commerce/product_info.php?products_id=8627 Unfortunately the max baud rate is still 115200 without modification (even on a much faster chip). I would also imagine that at such a high speed you would need to use specialised crystals or your error rate will be through the roof. Depending on your application, it may be easier just writing straight to the SD card from your hardware as opposed to sending it via RS232. –  penjuin Jul 17 '10 at 1:21
@penjuin: I think AVR at 20MHz can handle UART at (just under) 1MHz without too much trouble. –  davr Jul 17 '10 at 5:10