Interfacing the BASIC Stamp (BS2) to a PCF8591 I2C A/D D/A converter

The PCF8591 is a single-chip, 5V supply, data acquisition device
with four analog inputs, one analog output and a serial I2C-bus interface.
Three address pins A0, A1 and A2 are used for programming the hardware address,
allowing the use of up to eight devices connected to the I2C-bus without
additional hardware. (In this example a single PCF8591 chip is used and it
is hardwired to have the address 000.) Address information, control information,
and data to and from the device are transferred serially via the two-line
bidirectional I2C-bus.

The BASIC Stamp 2 does not support the use of the I2CIN and I2COUT commands.
This example shows you how to "bit blast" a solution using subroutines based on the
SHIFTIN and SHIFTOUT commands.

Here is the PCF8591 datasheet with details on interfacing and I2C communications.
More information on I2C communications is available here.

Here is the interface code.
The main loop continuously increments the analog output channel
and monitors and displays the 4 analog inputs.


Here is the schematic for connecting the PCF8591 chip to the BASIC Stamp.
An analog sensor (a Sharp IR distance sensor) has been connected to the first analog input (IN0) as an example.
The 0-5V analog output signal is available at pin #15 (AOUT).

 

Physical Computing
temple university school of communications and theater
film and media arts
christopher vecchio
www.noisemantra.com