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.
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??
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.
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.