Help, Stuck on I2C 16 channel PWM Tutorial
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Help, Stuck on I2C 16 channel PWM Tutorial

by js3 on Tue Feb 12, 2013 7:02 pm

I've done everything up to changing the port on my RPi Rev2. It says( http://learn.adafruit.com/adafruit-16-c ... it-library) to make a change to the I2c default port but it seems like Im missing something. Everytime I use the sudo nano I dont get anything on the screen. I've tried from the home directory and from inside the Adafruit_PWM_Servo_Driver directory. Im doing something wrong, I tried running the example program but its not working so I know I have to change that port. I've done everything else up to this point right. Any help?

js3
 
Posts: 19
Joined: Mon Sep 10, 2012 12:45 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

by adafruit_support_bill on Wed Feb 13, 2013 8:11 am

Are you able to locate the file: Adafruit_PWM_Servo_Driver/Adafruit_PWM_Servo_Driver.py?
User avatar
adafruit_support_bill
 
Posts: 30844
Joined: Sat Feb 07, 2009 10:11 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

by js3 on Wed Feb 13, 2013 2:01 pm

I typed in: cd Adafruit-Raspberry-Pi-Python-Code, then used the ls command these are my results below:

~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_PWM_Servo_Driver $ ls
Adafruit_I2C.py Adafruit_PWM_Servo_Driver.py Servo_Example.py
Adafruit_I2C.pyc Adafruit_PWM_Servo_Driver.pyc

js3
 
Posts: 19
Joined: Mon Sep 10, 2012 12:45 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

by adafruit_support_bill on Wed Feb 13, 2013 2:09 pm

A .pyc file is the compiled version of the .py file. It is created automatically when you run it and would be impossible to edit. Try re-downloading the original .py source file from the repository: https://github.com/adafruit/Adafruit-Ra ... ython-Code
User avatar
adafruit_support_bill
 
Posts: 30844
Joined: Sat Feb 07, 2009 10:11 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

by js3 on Wed Feb 13, 2013 2:21 pm

OK I finally got something besides a blank screen. (Wow that frustrating)

#!/usr/bin/python

import time
import math
from Adafruit_I2C import Adafruit_I2C

# ============================================================================
# Adafruit PCA9685 16-Channel PWM Servo Driver
# ============================================================================

class PWM :
i2c = None

# Registers/etc.
__SUBADR1 = 0x02
__SUBADR2 = 0x03
__SUBADR3 = 0x04
__MODE1 = 0x00
__PRESCALE = 0xFE


Is the "i2c = None" where I would change it to: self.i2c = Adafruit_I2C(address, bus=smbus.SMBus(1)) ?
Im new to Linux so Im sorry if this is trivial stuff going over my head

js3
 
Posts: 19
Joined: Mon Sep 10, 2012 12:45 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

by adafruit_support_bill on Wed Feb 13, 2013 2:28 pm

A little further down on line 30. The second line of this section:

Code: Select all | TOGGLE FULL SIZE
  def __init__(self, address=0x40, debug=False):
    self.i2c = Adafruit_I2C(address)
    self.address = address
    self.debug = debug
    if (self.debug):
      print "Reseting PCA9685"
    self.i2c.write8(self.__MODE1, 0x00)
User avatar
adafruit_support_bill
 
Posts: 30844
Joined: Sat Feb 07, 2009 10:11 am

Re: Help, Stuck on I2C 16 channel PWM Tutorial

by js3 on Wed Feb 13, 2013 6:44 pm

It worked! :D Thanks for helping out this noob

js3
 
Posts: 19
Joined: Mon Sep 10, 2012 12:45 am