how much time, does comunication (serial or I2C) take??

hello forum. i was wandering. if you have 2 ATmega238. and you want to mesure some analog inputs, and then do some calculations, and give outpouts, , but VERY rapidly ( maybe have , a complete cycle of inputs/calc/outpouts, in under 10milliseconds)
BOTH atmegas, have to give outpouts,based on the inputs. but one, dosent have to do it so fast.
is it better, to give the inputs, to both chips, and have them do calculations, OR is it better, to have the one chip, do all the comunications, and then send the results, via SERIAL to the other???

so basically, how much time, does SERIAL comunication between the 2 of them take??
and how would it be different if you where to use I2C??

Serial can be quite quick - you can select 115,200 for sure, and I think 230,400 will work with no mods needed as well.
I2C can transmit at 400Kbits/sec, it can be faster because there is a dedicated clock line to tell the slave when the data is valid.
SPI can be even faster, up to 8000 Kbits/sec.

Hard to say how long yours will take without knowing how many bytes need to be transferred.
With SPI set to system clock/2, the fastest speed possible, it can take as little as just over one microsecond to send a byte out.

Succesfully used Serial @ 500Kbaud (note this is a whole divider of the 16Mhz clockspeed)

I2C - many devices also work with 800Kbps. You can modify the TWBR register to optimize your speed.
I2C can be one master multiple slave

SPI is winner in performance.

nice! so , sending and receiving, even with Serial, for serials like
"n1,n2......n15" where n = 3digit numbers, takes very little time...
but, converting this serial to Integers?? will this be fast, or bottleneck??

takes very little time

Well it's all relative, it takes forever by CPU standards, pretty quick by human standards.

converting this serial to Integers?? will this be fast, or bottleneck??

Depending on exactly how you send the values that will probably take a 1000x less time than transmitting them.


Rob

Graynomad:
Depending on exactly how you send the values that will probably take a 1000x less time than transmitting them.

what do you mean???
i could send them, one by one, as integers??

nice! so , sending and receiving, even with Serial, for serials like
"n1,n2......n15" where n = 3digit numbers, takes very little time...
but, converting this serial to Integers?? will this be fast, or bottleneck??

Why do you want to do that conversion if you're sending from one Arduino to the other? Just send the bare integer, which takes 2 bytes at most. With SPI you have the SS line to synchronize your packets.

If you tell us more about your project we might be able to give you more in-depth hints.

so i could indeed send the bare integers?? how would i do this??? can it be done with simple Serial, or I2C , or does it need SPI??

every data structure consists of bytes. Just split it in bytes, then send the bytes one by one,
On the receiving side you reconstruct the data structure from the individual incoming bytes.

In practice you might need extra bytes to indicate the begin and end of a set of bytes and possibly more bytes for error detection/correction.