This article describes the design and programming of the PCF8591 A/D-D/A module whose printed circuit board is labelled YL-40 . The module is shown in Figure 1, and its schematic diagram is shown in Figure 2. Note that several other, similar modules exist, but in different shapes and with different capabilities. All, however, are centered on the Philips PCF8591 Analog-to-Digital Converter (ADC) and Digital to Analog Converter (DAC). I noted that the 16-pin DIP form is now available; making it easier to prototype. Soldering SMD ICs to a PCB is not for the faint of heart, in my opinion.
Figure 1: PCF8591 Module YL-40
This particular module is suitable for tutorial use and perhaps for some hobbyists. Its drawback is that its I2C address is hard-wired to all zeros. (Note that I2C is a very effective 2-wire communications standard that is used by many small semiconductor devices such as microcontrollers and sensor peripherals.) If the address lines could be jumpered high or low, then several identical modules could be placed on the same I2C lines. I would therefore recommend the alternative module named the Mini PCF8591 AD DA Shell Module because it has that capability. It is also at least three times the price.
The IC permits only 8 bit data allowing only 256 steps in the analog output value or the digital output value. This is likely borderline for hobbyists who may want to build instrumentation or test equipment.
My tests show another frustration: A lower than expected analog output voltage. For a 4.88 volt supply the output is only 4.17 volts (85%) at maximum value setting. Since the maximum supply voltage is 8 volts, increasing the supply to 6 volts may get a 5 volt result. I did not remove the green LED and related resistor to see if the problem was simply an excess current drain from the IC’s AOUT.
Reference: PCF8591 8-bit A/D and D/A converter Product Specification, 2003-01-27, Philips Semiconductor.
PCF8591 Module YL-40
The module is composed of:
- A PCF8591 IC at U1.
- A thermistor that measures temperature at R6.
- A photo-voltaic cell. This is a light sensitive resistor at R7.
- A single turn trimmer potentiometer at R3.
- Two LEDs: a red one that is on when the device has power; and a green one that increases brightness as the output voltage increases.
- Three red jumpers that apply the voltage sources – photo-voltaic cell, thermistor, and potentiometer, and to analog input channels AIN0, AIN1, and AIN3 respectively.
- Connector pins for I2C (SDA and SCL), Vcc, and ground.
- Connector pins for the Analog output AOUT, and pins for each of the three analog input channels.
- A 4-wire ribbon cable is included with sockets suitable for the connector pins.
Figure 2: YL_40 Schematic
The jumpers control whether analog input channels of the IC are connected to the analog sources:
- Jumper P4 for AIN1: The temperature sensed by the R6 thermister is provided to the ADC.
- Jumper P5 to AIN0: The R7 photocell voltage (resistance drop) is provided to the DAC.
- Jumper P6 to AIN3: The single turn 10K ohm trimpot voltage (resistance drop – brighter light, lower resistance).
Removing a jumper allows an input channel to be fed from one of the external pins, labelled accordingly.
I used the Arduino 1.0.1 IDE. I also used parts of the code from this website: (http://download.polytechnic.edu.na/pub4/download.sourceforge.net/pub/sourceforge/a/ar/arduinosources/PCF8591.pde). With the new Arduino IDE version, the I2C library changed somewhat and so the wire.send() and wire.receive() changed to wire.write() and write.read(). Note that the IC address of 0x9E was be changed to 0x90.
The DAC – Stepper Program
In the pcf8591DACTest3 program, the DAC is sent 8 bit bytes to set an output voltage from zero to 255 and back to zero again. The output voltage is the ratio of the value to the maximum of 256. The green LED then slowly brightens and then goes dark again as the cycle repeats.
The ADC Read Program
The program uses analog channel AIN3 which is jumpered to the trimpot. Adjusting that pot will change the output value between zero and 255. In the “void loop()” function the codes calls a subroutine to get data from the ADC. In “getADC()”, the IC is sent commands to return two ADC bytes. That starts the ADC process itself. Then the bytes are read; only the final byte contains the 8-bit unsigned result of conversion. That value is then printed out.
Mini PCF8591 AD DA Shell Module V2.0
This module is shown in Figure 3 (schematic in Figure 4). I did not purchase nor test this device, but by examining the schematic and the board itself one can see that it is more versatile: It has jumpers to permit selection of one of the eight I2C addresses. The headers are complementary allowing other modules of similar physical forms to be daisy chained (on a buss). The trimpot is still useful for sensing a fraction of some external voltage.
Figure 3: Mini PCF8591 AD DA Shell Module V2.0
Figure 4: Schematic Mini PCF8591 AD DA Converter Module V2.0
The Mini PCF8591 can be programmed using the same software as for the YL-40 version.