RP6 ROBOT SYSTEM - 4. Programming the RP6
Example 17: I²C Bus Interface – Master Mode
Directory: <RP6Examples>\RP6BaseExamples\Example_I2C_MASTER_02\
File: RP6Base_I2C_MASTER_02.c
This program demonstrates how to use the Master Mode of the I²C Bus. Of course
you will have to connect a suitable slave device to the I²C Bus before running
this program.
We added PCF8591 routines to this example program. The PCF8591 chip contains an
8-Bit Analog/Digital Converter (ADC) with 4 channels and a Digital/Analog Converter
(DAC) for generating analog voltages. Thus, PCF8574 and PCF8591 devices perfectly
complement one other.
The PCF8591 allows you to monitor four different voltages – our example has been
designed to evaluate four additional LDRs (arranged as voltage dividers). However the
actual circuit is quite negligibly – we could use four Sharp GP2D120 IR distance
sensors, some temperature sensors or any similar devices as well.
One main disadvantage in using these chips is that it is a bit time consuming to re-
ceive the measurements via the I²C Bus compared to an integrated ADC or I/O Port.
This restricts both ICs to simple, non timing-critical applications. Whoever needs fast
response and control should consider using another Microcontroller. Obviously a
second, freely programmable controller will complicate the system, but will also make
it more flexible!
We included detailed data sheets for the devices PCF8574 and PCF8591 on the CD!
Example 18: I²C Bus Interface – Master Mode
Directory: <RP6Examples>\RP6BaseExamples\Example_I2C_MASTER_03\
File: RP6Base_I2C_MASTER_03.c
This program demonstrates how to use the Master Mode of the I²C Bus. Of course
you will have to connect a suitable slave device to the I²C Bus before running
this program.
This simple program demonstrates how to control a Devantech SRF08 or SRF10 Ultra-
sonic distance sensor via the I²C Bus. Of course, the program may be adapted for us-
ing similar types of sensors from other manufacturers.
Example 19: I²C Bus Interface – Master Mode
Directory: <RP6Examples>\RP6BaseExamples\Example_I2C_MASTER_04\
File: RP6Base_I2C_MASTER_03.c
This program demonstrates how to use the Master Mode of the I²C Bus. Of course
you will have to connect a suitable slave device to the I²C Bus before running
this program.
In this example program, the Master is controlling four I²C Slaves: two SRF08/SRF10,
one PCF8574 and one PCF8591. The program is reuses code from the three previous
examples.
Other programming examples for peripheral I²C-devices will be supplied along with
the corresponding expansion modules!
- 121 -