A robot with 2 boards

I would like to create a modularized robot i.e There are different boards (each with its own micro controller) such that each board handles a specific functionality .

say for example,
I hav movement control board that directly connects to the motors and has a program for navigation .
There is a obstacle detection module that has IR sensors for detecting obstacles .
so on .

Now I want data from 1 board to be sent to the other when an appropriate request comes (request might be as simple as if pin number 'x' becomes high then send value of variable 'a' to the board below it)

How do I do this ???
I don't mind adding a bit of code in each of the micro conrollers for the purpose of communication .

I don't mind adding a bit of code in each of the micro conrollers for the purpose of communication .

Good thing, because that is exactly what you need to do.

Serial.print(), Serial.write(), and Serial.println() can all be used to send bytes (characters or numbers) to the serial port (the TX/RX pins).

Serial.available() and Serial.read() are used to collect that data.

Connect TX on one board to RX one the other.

Then, it is simply a matter of defining a protocol - a set of instructions that can be understood by both boards.

request might be as simple as if pin number 'x' becomes high then send value of variable 'a'

That's hardly simple. That appears as though you are trying to program one board from the other.

You've either got to knock up a multi-drop network, have all modules talk directly to the main processor, or have another uC to consolidate the inputs.

For example if you have 5 modules they can talk to a small board using seperate serial lines. This board can then pass the info to the main processor. This way there's no "networking" to be done with all the issues involved with that.

Of course all modules could also talk directly to the main processor as long as you use interrupt-driven comms and it can handle the load and has enough spare pins.

Thinks...alright here's another option that only needs 2 pins on each module including the master.

Daisy chain all modules together, Tx of the main processor to Rx of the first module, tx->rx, tx->rx etc until the last module who has tx back to the main processor.

Send a byte to the first module. It passes the byte to the second and adds X bytes according to what is has to say. #2 passes #1's bytes on and adds it's bytes etc etc.

Eventually a stream of bytes returns to the main processor, parse that and you know what's going on in the robot.


Rob