I'm wondering if there is any way to make two arduinos talk each other very fast, and, if possible, using only one pin. I have two devices, a sender and a receiver, and they never swap their roles.
I tried to connect one pin of the sender (configured as output) to one pin of the receiver (configured as input), then to send an 1 the sender sets the port to for 48us, then clears the port for 16us, to send a 0 the port is set for 16us and cleared for 48us.
In the receiver an interrupt is called every time the port changes it status, and measures the times between interrupts. But this works about one third of the times I send someting, and I don't know why some time works perfectly and some times it don't. I've also tried to send 1000 times longer signal, maybe they were too fast for the receiver, but it did not work.
I do not post the codes I wrote because my question is not what's wrong with my code, but if there is any very fast way to make arduinos communicate.
Yes, I figure then you can just call Serial.begin() on both boards, with the same baudrate specified.
Then Serial.print() and Serial.read() should work on both Arduinos (if you have both RX and TX connected on both Arduinos, plus the common ground)
alessioserraino:
I tried to connect one pin of the sender (configured as output) to one pin of the receiver (configured as input), then to send an 1 the sender sets the port to for 48us, then clears the port for 16us, to send a 0 the port is set for 16us and cleared for 48us.
In the receiver an interrupt is called every time the port changes it status,
That's pretty much what HardwareSerial does without any programming by you - and with very little burden on the MCU. It may work up to 1,000,000 baud.
How fast do you actually need?
Have you taken steps to eliminate all redundant data from the transfer?
The wire is about 25cm (~10 inches) long, so I think every type of wired connection will work. The two arduinos are already connected to the same GND, I mean one wire excluding common GND or +5V.
I thought about using serial, but the receiver's RX is already connected to the PC, so I need two serial, if you know a way to do this (on Arduino Uno, which has only 1 RX) let me know.
Yes, I can allow 3 wires, but they will use three pins, so (because I need many inputs) I have to use another Arduino, and connect also that. It should not be a big problem, I have tons of Atmegas.
Well, actually, I need about .5Mbps, but if it is faster is better.
Have you thought of using shift registers to expand the number of inputs? You can expand your inputs in multiples of 8 pins using three pins. That is much easier than adding another Arduino just to get more input pins.
alessioserraino:
Well, actually, I need about .5Mbps, but if it is faster is better.
Please tell us what you are transmitting and why it needs to be this fast.
How much data is transmitted at any one time?
How many times per second is the data transmitted?
What is the content of the data?
What is the direction of transfer?
I have a ProMini and a Nano communicating using the Software serial library. I've operated that link at 57600, in an environment where hardware serial and another I2C link are all operational at once. There seems to be no problem, and if some timing difficulty arises, you usually can sort it out by forcing the data flows into a cycle, so that they don't interrupt each other. And you can use the sending Arduino to compress the data in some way before sending it.
The SPI interface isn't going to work, since the Arduinos on both ends will think they are the master. Other than that, nobody is going to reliably get a 500 Kbit/sec data rate out of a 16 Mhz. chip, since that chip then has only 32 clocks to both collect, structure, and send each bit. I suggest that perhaps some ingenuity can se applied to reduce the data intensity before sending it. A better alternative might be to examine a chip like the Teensy 3.1, which can operate at up to 92 MHz.
I do not post the codes I wrote because my question is not what's wrong with my code, but if there is any very fast way to make arduinos communicate.
Sorry, but I think you will need to post your code, as has been suggested you could be having problems with interrupts and other timer dependent libraries and functions.
Hi, you have the best transmission line for the physical application, a piece of wire, now we need to see the sketches that Tx and Rx to see how you are TXing and RXing the pulses.
What experience have you had with arduino, programming, transmission lines, electronics and electrical basic theory?
You are asking for our help mate, yet don't want to show us the goods to see what we are helping you with.