A
A
alex995052017-09-04 20:33:54
Arduino
alex99505, 2017-09-04 20:33:54

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

4 answer(s)
N
n12eq3, 2017-09-04
@n12eq3

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.

A
Andrey Skorzhinsky, 2017-09-05
@AndyKorg

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.

R
rmsun, 2017-09-06
@rmsun

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.

H
Hoksmur, 2017-09-14
@Hoksmur

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 question

Ask a Question

731 491 924 answers to any question