User manual

RP6 ROBOT SYSTEM - 4. Programming the RP6
Example 20: I²C Bus Interface – Slave Mode
Directory: <RP6Examples>\RP6BaseExamples\Example_I2C_SLAVE\
File: RP6Base_I2C_SLAVE.c
Initially this program will not perform anything visible from the outside. You
will have to add an expansion module to the robot, which takes over control and
acts as I²C master.
It makes sense to equip the robot with several additional Microcontrollers. In most
cases it is a good idea to let one of the additional Microcontrollers control the com-
plete Robot. Not only bigger and faster controllers can do this, but also another
MEGA32. The Controller on the Mainboard performs several tasks already like ACS,
Motion Control etc. and this consumes quite a bit of processing time (lots of Interrupt
events). On an external Controller, you will have more spare time.
This is the idea behind this program: a master controls the high level overall function-
ality of the robot and sends commands to the slave through the I²C Bus, which
handles the low level control. All known functions like the automatic motion control
now show their real advantages the master only has to transmit short commands
like “drive forwards at <speed parameter>” and the rest is done automatically. Of
course running tasks may be aborted for example after sensors detect obstacles.
The program's source code contains a list with all valid commands and the corres-
ponding parameters. Additionally the program source code contains further details for
controls.
If necessary, the slave controller automatically initiates an interrupt signal on the first
interrupt signal line (INT1). This can be used by the Master to detect sensor or motion
state changes fast and easily.
The Sensor values can be read from a number of registers. If an Interrupt event has
been triggered, the master can start reading some status registers and check what
caused the interrupt event. Afterwards the corresponding register can be read.
Alternatively you might simply read ALL sensor registers at once, which takes some
time, of course.
Detailed informations to this topic and of course specific register details are to be
found in the program's source code.
Further example programs for robot control will soon be published along with expan-
sion modules. A few of these programs and the RP6 CONTROL M32 examples are
available on the CD-ROM already.
- 122 -