Well, the good news is that the PCA9685PW chip is working as it should and I can now set the fan speed for all three MOSTFET outputs. Yay! I have created a small python script for controlling it, loosly based on the Adafruit lib. The real problem was really getting the I2C to work under Angstrom. The I2C post on GigaMegaBlog was very helpful, but unfortunately there were a few hickups, namely a typo, a missing library and finally a missing instruction. For anyone wanting to control PCA9685PW with Python from a Beaglebone, here goes:
opkg install kernel-headers python-distutils wget http://www.hipstercircuits.com/uploads/i2c-tools-3.1.0.tar.bz2 tar -xjf i2c-tools-3.1.0.tar.bz2 cd i2c-tools-3.1.0/py-smbus/
From an SSH-shell (since nano works poorly with minicom), do the following:
add this line, this is different than GigaMegaBlog:
The point here is that the i2c-dev.h file that is present on the Beaglebone (as of this writing) is missing some of the functions necessary for this to work. Therefore, we use the i2c-dev.h file that comes with the i2c-tools package, located in the “../include” folder.
python setup.py install
This will fail since the linker does not support the –sysroot command. Just remove that argument form the compile-line, it will then look something like this:
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -fno-tree-vectorize -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.7/smbusmodule.o -L/usr/lib -lpython2.7 -o build/lib.linux-armv7l-2.7/smbus.so
and then re-run the python install command:
python setup.py install
And you are good to go.
If you are lucky and have a Replicape or a PCA9685PW connected on I2C2 (which shows up as /dev/i2c-3, btw), do this to test it:
wget http://www.hipstercircuits.com/uploads/pwm.py wget http://www.hipstercircuits.com/uploads/Adafruit_I2C.py python >>> from pwm import PWM >>> pwm = PWM() >>> pwm.setFrequency(100) >>> pwm.setDutyCycle(2, 0.1)
The setDutyCycle takes channel nr, and %on as arguments. Thus, 2 is channel “C” and 0.1 = 10%. Setting 0 or 1 gives “off” and “on” output, repectively.
Update: I forgot to mention how this is all connected together. Below is a screen shot of the schematic. The two interesting parts are “Fan drivers” and “PWM Extension” and they are connected together with FAN_1…FAN_3-wires. VFF is 12V.