This is an old revision of the document!
Table of Contents
YL-40 A/D D/A Converter Module
The YL-40 is a cheap analogue I/O device based on the PCF8591 I2C interface chip.
These devices combine the silicon chip with a potentiometer, light dependant resistor, thermistor and two LEDs.
I have three of these devices, in two the earth connection to the thermistor is missing on the PCB, with this fault the NTC (channel 1) will always return a value of 255.
Pinout
SCL SDA GND VCC O/P PWR LED LED LDR NTC P4 POT P5 P6 AOUT AIN0 AIN1 AIN2 AIN3 P4=NTC ENABLE P5=LDR ENABLE P6=POT ENABLE
The LDR and NTC part numbers are unknown but the following characteristics were found.
Board | LDR @ 10lx | NTC @ 25'C | Earth fault | Jumpers |
---|---|---|---|---|
1 | 10K | 4K7 / 3977 | No | RED |
2 | 5K | 6K8 / 3977 | Yes | BLACK |
3 | 10K | 10K / 3977 | Yes | NONE |
As we can see, the components vary, plus there is a massive variation in response for the LDRs so they must be considered unique.
The LDRs are likely to be the GL/PGM 5516 (5K) and 5528 (10K).
PCF8591
Control | Register | Function | Device |
---|---|---|---|
0 | channel 0 | Read ADC 0 | LDR |
1 | channel 1 | Read ADC 1 | NTC THERMISTOR |
2 | channel 2 | Read ADC 2 | NC |
3 | channel 3 | Read ADC 3 | POTENTIOMETER |
+64 | analog OE | DAC output | O/P LED |
The O/P LED will begin to turn on with the output set to 140 or more with VCC at 3v3.
RPi
Set up I2C as per the Slice of Pi/O.
Set O/P to VCC and turn on LED.
i2cset -y 1 0x48 64 255
Read POT.
i2cset -y 1 0x48 3 ; i2cget -y 1 0x48 ; i2cget -y 1 0x48
The first i2cget will read and discard any previous sample. This will be from the any previously read input channel and perhaps not the one required.