NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » UART maximum safe transfer rate

July 17, 2011
by nimaaj
nimaaj's Avatar

Hello

I am trying to send information obtained using the adc to a pc. I am using the uart to communication with a c++ program that I've made on my laptop. I am trying to determine what my rate limitation is.

If i set the adc to 8 bit resolution I see that in theory 115200 bits per second I can send 14400 bytes per second. but how many bytes of information can I actually safely send through the usb converter cable?

furthermore I'm not sure howmany low resolution, reasonably error-free adc readings I can make per second?

Also is there any other way of communicating with a laptop that is faster than the uart?

Any help from people that have had experience with this issue is very much appreciated. thanks

July 18, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

Hi nimaaj,

The UART protocol can go faster than 115200 baud, but the UART module on the chip can't clock out anything faster than that.

The ADC (the way we set it up in the temp sensor project) uses a clock/128 prescaler, and it takes 13 of those clock cycles to get one ADC conversion. This can be sped up by trading off resolution. With these chips I don't think there is any way you can get anything faster than the serial port as far as communications with your PC. I can conceive of some sort of USB module that acts as true USB device, and you communicate with that over SPI, but I think ultimately you are going to be limited by the ADC if you are doing ADC stuff. Hope that helps.

Humberto

July 18, 2011
by nimaaj
nimaaj's Avatar

that helps a lot. Thanks.

i have a question tho.if modify the register for the adc to scale the clock to 1/2, does that mean that I can make 14745600/(2*13)= 567138 every second?

July 19, 2011
by bretm
bretm's Avatar

Only if you can wait for the result, read the value, and start a new conversion all in zero clock cycles. If you want the full 14745600/(2*13) rate you would probably need to configure the ADC for free-running mode, and you'd need to read each value and write it to the UART all in 26 clock cycles or less.

July 19, 2011
by hevans
(NerdKits Staff)

hevans's Avatar

The ADC also has an upper limit to how fast its clock can be set to. Page 248 of the datasheet (I highly suggest you read the ADC part of the datasheet if you are using the ADC), says the ADC has a maximum frequency of 200 kHz. The prescaler of 128 is the fastest you can do and still be in that limit. If you set the prescaler to 1/2 the readings would not mean anything. As it was mentioned before, you can push past this limit if you are willing to trade off resolution.

Humberto

Post a Reply

Please log in to post a reply.

Did you know that the printf format string "%.3f" will show three digits after the decimal point? Learn more...