Answer the question
In order to leave comments, you need to log in
How to organize a fast data transfer between two arduino?
There are two Arduino Mega. On one there is an encoder (everything is on the remote control - it can be wired), on the other there is a motor. And you need to transmit data by how many degrees to turn the motor.
I organized a radio broadcast - not all data is received, it is accepted. The LED signals the transmission correctly.
By wire (serial port) - if you quickly turn the encoder knob, then there is a data failure (transmitted in an array).
What else can I try or am I making mistakes in my decisions?
Answer the question
In order to leave comments, you need to log in
SPI is bi-directional. Very fast, synchronization is automatic, there are no "default" losses, available in atmegaXXX.
Byte-by-byte or parcel exchange with or without confirmation.
Judging by the fact that the radio channel is used, the distance between the devices is large. This means that the problem may not be in speed, but in the "tightening" of fronts on long lines. Maybe you should try to put "amplifiers" of the signal.
Do I need to turn the handle quickly?!.
For some reason, it seems to me that the speed should be enough in this case.
Tell me, please, what is a "data failure" and what array is being transmitted - where does it come from, etc.
Try (just in case) to increase the transmission speed (transmitter and receiver must work at the same speed!).
Remove from the program all unnecessary, debugging Serial.print/write.
Leave only the encoder and transmit/receive in the program.
Does not work?
We need to find out where it breaks.
Check separately - encoder, data link, program (maybe it should be checked first).
Encoder. On one Arduino, without transferring to another - only an encoder and an Arduino monitor. Read - and into the monitor. Turn the encoder as accurately as possible by 90 degrees, by 180. It is known that it should give back with such a turn - see what happens on the monitor.
transmission channel. Create programmatically on one arduino the data to be transmitted. Check in the monitor that they are generated correctly. Here they are transferred to the second board.
If individually everything works - see the program.
I will offer another option:
Make a simple protocol (if it is for wireless).
1) transmit the packet until confirmation is received. Packets with end-to-end numbering. Confirm not a command, but the receipt of a packet with the number N
2) send not what to do, but in what position the engine should be
Or
2.1) How much will it turn from the last confirmed packet
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question