Mega and 3 unos

Hi all!
I'd like to build something that controls three stepper motors and 2 DC motors, but the steppers have encoders too. I really don't want them to miss steps, that's why I'm using encoders.
I've got an Arduino mega 2560, which is good, but I'd like to rotate the three steppers independently.
That's why I've decided to use uno's to control the motors, reading the encoder, giving signals to the motor driver.
The main program will be on the Mega. That needs to communicate with the unos. I just like to give a commands like:
"First motor takes 5 rotations and 165º at speed of 120 rpm"
"2nd motor takes 3 rotations at speed of 180 rpm"
"3rd motor take 6 rotations at speed of 60 rpm"

The quuestion is how to wire them (arduino mega with 3 unos), which protocol to use, and maybe some sample about communication between two arduinos.
A lot of thanks in advance!

You can easily connect each Uno to one of the Serial1, Serial2 and Serial3 ports on the Mega and use simple Serial.print() commands to communicate.

The 3rd example in Serial Input Basics will provide a reliable way to communicate. You can use it on each of the Unos and 3 versions of it on the Mega if it needs to receive data from the Unos.

Do you need close coordination between the movements of the motors? That may be difficult to achieve with 3 separate Unos. Maybe you could have a separate I/O pin connection from the Mega to the Unos that would signal when a move should start.

...R

Thanks Robin,
The motors coordination will be okaz I think so.
Do I have to use pullup resistors, like in the I2C case?

So on the UNO side, I can receive chars containing the speed and the number of steps, then use them like (stepper.h library):

void setup() {
        Serial.begin(9600);
}

void loop() {

        if (Serial.available() > 0) {

                speedvariable = Serial.read();
                stepvariable = Serial.read();

                        }

 myStepperFirst.setSpeed(speedvariable);
   myStepperFirst.step(stepvariable);

}

I know it's wrong, idk how to send/receive two different characters. please help, how can I send example 150 Speed, and 500 steps?

vajdacsab:
Thanks Robin,
The motors coordination will be okaz I think so.
Do I have to use pullup resistors, like in the I2C case?

Not for serial communication.

So on the UNO side, I can receive chars containing the speed and the number of steps, then use them like (stepper.h library):

It looks like you did not study the code in the link I gave you. It works.

...R