Dobrica Pavlinušić's random unstructured stuff
PCA9685: Revision 8
PCA9685.pdf

PCA9685.jpg

16-channel, 12-bit PWM Fm+ I 2 C-bus LED controller

dpavlin@cubieboard:~$ zgrep 9685 /proc/config.gz 
CONFIG_PWM_PCA9685=m

# on armbian this requires kernel recompile

root@cubieboard:~# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: UU UU -- UU -- -- -- -- UU -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- --                         

root@cubieboard:~# echo pca9685 0x70 > /sys/bus/i2c/devices/i2c-2/new_device 
[Tue Jun 25 19:59:58 2019] i2c i2c-2: new_device: Instantiated device pca9685 at 0x70

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0# echo 0 > export

# Default period_ns = 1/200 Hz
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 5000000 > period 
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# cat period 
5000000
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# cat duty_cycle 
0

# move servo

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 2000000 > duty_cycle 
root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 1000000 > duty_cycle 

sg90 servo motor

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 20000000 > period # 50Hz

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 1000000 > duty_cycle # min?

root@cubieboard:/sys/devices/platform/soc/1c2b000.i2c/i2c-2/2-0070/pwm/pwmchip0/pwm0# echo 3000000 > duty_cycle # max?