Make a protocol to crontrol motors

Hello,

I need to control two motors with a special protocol.
I have two arduino cards to read a PWM output from one RC controller and control each motor.
My problem is that I don't find something to help me to know how I have to write my protocol.
I just want to know how I can write a protocol in a serial communication.
I don't know nothing about this... and I have don't find tutorial about "writting your own protocol".
After writting the informations on RX and TX, I will tranform them with a shield TTL to RS485.

If you need more informations I can give you them in french...

Thank you for your time !

Have a look at Serial input basics - updated

It will show you how to send serial data in a format that can be parsed (decoded) when received.

Do you know what a protocol is? It is an agreed-upon format for exchanging data.

If you expect Russian text describing some action to take, and I send you a poem in Chinese, we are not communicating.

If you expect me to stand on a 12 foot ladder and wave red and blue flags, and I do that, we can communicate.

So, whatever YOU think you can send, in whatever form you can parse on the other end, is a good protocol.

Start with what, EXACTLY, you need to send from one device to the other. "PWM output" is useless information. How much data do you need to send? How often? Sending two integral values twice a month, when neither Arduino has anything else to do means that you could send "two thousand, three hundred twenty four and minus one hundred ninety five."

Sending 4 bytes every 10 milliseconds requires a much more compact representation of the data.

Thank you PaulS and UKHeliBob

Yes I know what's a protocole but When I have posted this question I not have the informations of what I have to send !
Now I have them and it doesn't help me more...
My question is : How I can send the informations ! and not, What informations I have to send !
I use just MySerial.write() and I send the bytes one by one...
I don't know if it's correct...
I have to send informations like a start data (0xAC) and informations like motor power (-1000/0/1000)...
All I have to send as to be in hexadeciamel ?
And after I have to make the CRC8 Maxim Checksum with the data for this part I think I am ok.

Thank you

All I have to send as to be in hexadeciamel ?

Hexadecimal is a text representation of a number. So do you have to send text or do you have to send the numbers.

I have to send informations like a start data (0xAC) and informations like motor power (-1000/0/1000)...

Please fill in those dots at the end. With the information that you gave, you now probably have access to the datasheet/documentation for motor(driver). Post it here.

AntoineBoatProject:
My question is : How I can send the informations !

Have you studied the examples in the link in Reply #1?

The technique in the 3rd example will be the most reliable.

You can send data in a compatible format with code like this

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

…R

AntoineBoatProject:
My question is : How I can send the informations ! and not, What informations I have to send !
I use just MySerial.write() and I send the bytes one by one...

Thank you

What are the capabilities of the receiver? I'll assume some common serial interface that is not an issue.
You have a motor driver that controls PWM to the the motor.
All you should need to send is the desired duty cycle and the direction you want the motor to turn. That would be a number from 0 to 100 for duty cycle and a bit for direction. So all you need to send are two bytes of data. Whether it is binary, hex, ascii or EBCDIC only effects how you write the parser. Then decide which byte to send first and which second. If you think you need a start byte or address or something else then that is dependent upon the environment the device is operating in.