Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Problem instantiating MotorKit i2c
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Problem instantiating MotorKit i2c

by Chiliarch on Sat Mar 13, 2021 12:55 pm

Hello

I have a MetroExpress M4 with a V2 MotorShield attached. Attempting to bring up the shield in circuitPython.
I'm going through the tutorial at: https://learn.adafruit.com/adafruit-ste ... cuitpython
The board is updated to the latest version of python, and I've downloaded the most current version of the various libraries involved.

The full code is exactly as in the tutorial, literally copy/paste.

I'm getting an error with the following line:
Code: Select all | TOGGLE FULL SIZE
kit = MotorKit(i2c=board.I2C())

I've also tried it as:
Code: Select all | TOGGLE FULL SIZE
kit = MotorKit()

REPL throws the following when I save to the board:
Code: Select all | TOGGLE FULL SIZE
code.py output:
Traceback (most recent call last):
  File "code.py", line 9, in <module>
  File "/lib/adafruit_motorkit.py", line 64, in __init__
  File "/lib/adafruit_pca9685.py", line 141, in frequency
  File "adafruit_register/i2c_struct.py", line 70, in __get__
  File "adafruit_register/i2c_struct.py", line 70, in __get__
  File "adafruit_bus_device/i2c_device.py", line 155, in write_then_readinto
TypeError: extra keyword arguments given


FWIW, I've also checked i2c with the PCA 9685:
Code: Select all | TOGGLE FULL SIZE
import board
i2c = board.I2C()
i2c.try_lock()
i2c.scan()

scan = i2c.scan()
for addr in scan:
    print("Adress = {0:3d}, Hex = {1}".format(addr, hex(addr)))


Any help is appreciated!

Chiliarch
 
Posts: 4
Joined: Wed Feb 03, 2021 2:57 pm

Re: Problem instantiating MotorKit i2c

by Chiliarch on Sat Mar 13, 2021 1:35 pm

Further information: I unmounted the board, quit REPL and restarted everything. Now the code is taking, and I'm not getting the error I posted above. However, REPL goes out to lunch at the "kit = MotorKit(i2c=board.I2C())" line and never displays the second Print.
Here's the code I've loaded to the board, and the REPL response:
Code: Select all | TOGGLE FULL SIZE
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

# """Simple test for using adafruit_motorkit with a stepper motor"""
import time
import board
from adafruit_motorkit import MotorKit

print("I am alive ")

kit = MotorKit(i2c=board.I2C())

print("I am still alive ")

# for i in range(100):
#    kit.stepper1.onestep()
#    time.sleep(0.01)

Code: Select all | TOGGLE FULL SIZE
Response:
code.py output:
I am alive

At this point the board displays a steady green light and REPL does not CTRL+D.
Surely I'm making an error somewhere (?)

Chiliarch
 
Posts: 4
Joined: Wed Feb 03, 2021 2:57 pm

Re: Problem instantiating MotorKit i2c

by Chiliarch on Sun Mar 14, 2021 3:25 am

Pulled the latest (14MAR'21) libraries that posted this evening, and everything works fine. I must have caught things mid-update when I started in on it this morning. No need to reply - this appears to be resolved.

Chiliarch
 
Posts: 4
Joined: Wed Feb 03, 2021 2:57 pm

Please be positive and constructive with your questions and comments.