What is the fastest way to get an int from one Arduino to another

So I am doing a Signal converter using two Arduino mini pros. One Arduino is collecting the incoming signal and applying time changes, then I send the int variable to the other Arduino, the int value can be between 20-64000 so I am using an unsigned int. This is happening at a rather quick pace and I need to keep the value changes quick so that they do not interrupt the outgoing signal, and I need to keep the code small and simple as well. I have been reading several posts but I am not sure what method is best, I2C seems the most dominate or commonly used but some seem to think its slow. I have tried I2C a little but the values have gotten mixed up a few times. SPI seems to be another option though I have not used it yet. I am not sure which one is quicker. Is there any other methods?

Do you mean “fastest” as in “least amount of cpu cycles needed” or as in “shows up the fastest at the destination”?
The UART has a two-byte output buffer, so you can dump 16bits to it in two cycles (sort of), but them it will dribble over to the other system at a somewhat slower rate…

I mean in the fastest deliverable but I don't want to be slowing the CPU up either. At full pace the code I am currently running is capturing the incoming code, applying an algorithm to it and making the changes for the out going signal all in less then 0.5 milliseconds. I found out that if statements take up a bit more time then for and while statements, at least in my current application. my current code using I2C has a few issues that I have found, and need to work out, once I get that done I will post it if there are any interested parties, and possible suggestion on speed.

So I am doing a Signal converter using two Arduino mini pros.

Have you considered using an FPGA for this job? Perhaps hooked to an arduino, if necessary, to provide some sort of controller UI?

FPGA is new to me thanks for the heads up I will look in to it.

DavidAsh: I mean in the fastest deliverable but I don't want to be slowing the CPU up either.

This is like "how long is a piece of string"

In your project, how much time (in microsecs or millisecs) is available for sending a value?

...R

SPI = 8MHz for arduino @16MHz (top speed). Clocks 16 bits out at 8MHz = 500KHz
So that’s like 32 “cycles” of the 16MHz.

SPI is a serial interface…

You could maybe save a smidge of time using a parallel interface?
Using 2 PORTS to give 16 bits…you can write your 16 bit value to 16 arduino pins:

PORTx = my_int << 8
PORTy = my_int

Then the receiving arduino:

got_in = (PORTx + PORTy)

sort of idea?

Any confirm the may be “faster”?

This is happening at a rather quick pace and I need to keep the value changes quick

“Quick” is not a unit of Time…

I am currently running is capturing the incoming code, applying an algorithm to it and making the changes for the out going signal all in less then 0.5 milliseconds.

That does not tell us much either…

The true question is How fast is your incoming signal changing - what timing is acceptable?

Other question (related) is why do you think you need two arduinos - depending on the frequency of the incoming signal you might be able to do everything you need only in one arduino maybe? Have you assessed that option? What do you do on the second arduino?

Johnny010: Then the receiving arduino: got_in = (PORTx + PORTy)

Well not quite an addition, missing a shift by 8 for the MSB

Challenge with this approach is that you have no way to sync —> you need also one more pin to act as a clock signal to let the receiving arduino know when data is ready and depending on what you want to do a way to know from the sender that the data has been read... if you have some burst of data sending, with this approach you can’t really buffer, would need additional code.

J-M-L: Well not quite an addition, missing a shift by 8 for the MSB

Challenge with this approach is that you have no way to sync —> you need also one more pin to act as a clock signal to let the receiving arduino know when data is ready and depending on what you want to do a way to know from the sender that the data has been read... if you have some burst of data sending, with this approach you can’t really buffer, would need additional code.

An interrupt could just tell the receiving arduino to run that in an ISR to update a list of the values?

And yeah, the 8 bit shift I forgot. Oops.

Johnny010: An interrupt could just tell the receiving arduino to run that in an ISR to update a list of the values?

yes the clock could be connected to an interrupt pin of the target UNO indeed

DavidAsh: FPGA is new to me thanks for the heads up I will look in to it.

Would very much like to get into these things and Verilog, but there doesn't seem to be an OSX toolchain for the board I have. :(