I2c with PCA9685

Hey,
I try to get some servos moving via i2c and a PCA9685 on a jetson orin nano dev kit.
I connected the SDA and SDL to pin 3 and 5.
I think i came to the same point as here:

Using adafruit_servokit seems to find the hardware because I dont get any errors running a simple script like this:

from adafruit_servokit import ServoKit
myKit=ServoKit(channels=16)
myKit.servo[0].angle=90

But the servo do not move.

Disconnecting the PCA9685 board results in a error "No I2C device at address: 0x40
I also tried pin 27 and 28 without success.

Any suggestions how to debug this?

If the i2c communication without problem I would suggest consult with vendor to get help.

Thanks

Thank you, I will try that.
However, I am still a bit confused also about the Jetson Orin Nano. In various tutorials with the Jetson Nano, the PCA9685 board seems to work out of the box.
Are there any differences between the Jetson orin Nano and the Jetson Nano regarding the i2c bus?

In the Jetson orin Nano pinout here https://jetsonhacks.com/nvidia-jetson-orin-nano-gpio-header-pinout/
I2C Bus 7 is mentioned on pin 3 and 5 and I2C Bus 1 on pin 27 and 28.

In the Jetson Nano pinout here https://jetsonhacks.com/nvidia-jetson-nano-j41-header-pinout/ I2C Bus 1 is mentioned on pin 3 and 5 and I2C Bus 0 on pin 27 and 28.

I was thinking that when I switch to pin 27 and 28 on my orin nano the PCA9685 may work, but I was not able to get i2c working here.

Is there a way to change the bus configuration on pin 3 and 5 to 1 and and on pin 27 and 28 to bu 0 like on the Jetson Nano?

Thx

  1. Use a logic analyzer to verify proper I2C communication. This is the first step.

  2. Get the datasheet for the chip:
    https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf

  3. Forget any libraries. Try to access the chip on register level and to generate full off, full on and PWM outputs. Verify the results with your logic analyzer and a led, which should be off, on, or half on (less bright).

fchk

I have similarly have been having a nightmare trying to get the PCA9685 to work with the Jetson Orin Nano. For reference, I have used the PCA9685 with the Jetson Nano before without issue.

Here was my process:

I started with trying to use the I2C Bus 7. Upon running:

sudo i2cdetect -y -r 7

I would get something like:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- --                       

The PCA9685 is supposed to appear on 0x40 and 0x70. So there is something weird going on. I tried multiple different PCA9685 modules (2 of them that I knew worked correctly) and I could never get a 0x40 address to show up for them, only 0x70.

So I tried to use them on the 0x70 channel. Unfortunately it seems extremely difficult to address the I2C Bus 7 using Python. Using board:

import board
dir(board)

ouput:

['CE0', 'CE1', 'D10', 'D11', 'D12', 'D13', 'D16', 'D17', 'D18', 'D19', 'D20', 'D21', 'D22', 'D23', 'D24', 'D25', 'D26', 'D27', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'I2C', 'MISO', 'MOSI', 'SCK', 'SCL', 'SCLK', 'SCL_1', 'SDA', 'SDA_1', 'SPI', '__blinka__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__repo__', '__spec__', '__version__', 'ap_board', 'board_id', 'detector', 'os', 'pin', 'sys']

No SCL_7 or SDA_7 to use. Couldn’t figure out how to address bus 7 any other way either.

So, I tried switching to I2C Bus 1. I verified that I was able to see the device on 0x70 (still not appearing on 0x40, although that channel is already taken on this bus) with i2cdetect:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: 70 -- -- -- -- -- -- --

Then I tried using the device:

i2c = busio.I2C(board.SCL_1, board.SDA_1)
pca = adafruit_pca9685.PCA9685(i2c, address=0x70)
pca.frequency = 1000

leftPump = pca.channels[0]

leftPump.duty_cycle = 0

and got the following error:

Traceback (most recent call last):
  File "TankCalibration.py", line 17, in <module>
    leftPump.duty_cycle = 0
  File "/home/maize/.local/lib/python3.8/site-packages/adafruit_pca9685.py", line 95, in duty_cycle
    self._pca.pwm_regs[self._index] = (0, 0x1000)
  File "/home/maize/.local/lib/python3.8/site-packages/adafruit_register/i2c_struct_array.py", line 70, in __setitem__
    i2c.write(buf)
  File "/home/maize/.local/lib/python3.8/site-packages/adafruit_bus_device/i2c_device.py", line 100, in write
    self.i2c.writeto(self.device_address, buf, start=start, end=end)
  File "/home/maize/.local/lib/python3.8/site-packages/busio.py", line 219, in writeto
    return self._i2c.writeto(address, memoryview(buffer)[start:end], stop=True)
  File "/home/maize/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 60, in writeto
    self._i2c_bus.write_bytes(address, buffer[start:end])
  File "/home/maize/.local/lib/python3.8/site-packages/Adafruit_PureIO/smbus.py", line 303, in write_bytes
    self._device.write(buf)
OSError: [Errno 121] Remote I/O error
Exiting... 
Cleaning up pins

Afterwards, I couldn’t even see the devices on i2cdetect. Has anyone had any success/insight/ideas that they would be willing to share?

Thanks!

Based on how far you have gotten with addressing the hardware directly, I think there ought to be some way to get this working using the Jetson Device Tree Overlay (NVIDIA Jetson Device Tree Overlay | Device Tree Overlay | RidgeRun Developer). unfortunatly I don’t have sufficient understanding to try anything in this area. But please continue to update this thread if you are able to make progress. This is an important hardware requirement and there needs to be a fully documented and fully supported way forward.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.