Hi there,
I am using the motor bridge cape using BBB to run stepper motor. When I execute the test file, steppermotortest.py, I end up in the error “Attribute error: ‘Adafruit_I2C’ object has no attribute ‘writeList’”. Kindly help me in this issue.
Problem fixed. Thanks
1. install the adafruit_gpio
sudo apt-get update
sudo apt-get install build-essential python-pip python-dev python-smbus git
sudo pip install Adafruit-GPIO
2. install adafruit_bbio
sudo apt-get install build-essential python-dev python-pip -y
sudo pip install Adafruit_BBIO
3. change the MotorBridge.py as below
import Adafruit_GPIO.I2C as I2C
import Adafruit_BBIO.GPIO as GPIO
import time
Reset = “P9_23”
MotorBridge = I2C.Device(0x4b, 2)
GPIO.setup(Reset, GPIO.OUT)
4. Here is the output. I will update wiki soon.
debian@beaglebone:~/MotorBridgeCapeforBBG_BBB/tests$ python StepperMotortest.py
Hello From MotorBridge
Hello From MotorBridge
Hello From MotorBridge
thanks
Seeed techsupport team
Bill
Hello Fellows and Ladies,
Is the new software, which is found on GitHub.com, for the Motor Bridge Cape (MotorBridge.py) used w/ only Python3 now?
Seth
This error happens because there is no attribute with the name you called, for that Object. This means that you got the error when the “module” does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the python source code after you had already imported the file (module). Or, some times packages get deprecated and they rename some functions. If that is true, then you may want to exit and reimport the module once again to be able to access the new method.
You can do it in another way to reimport the module with changes without having to exit the interpreter is to do the following:
import importlib
importlib.reload(myModule)
Hello,
I started to use smbus2 which can be installed with pip3 after an apt install python3-pip installation.
…
So,
# with help from @zmatt on Freenode
from smbus2 import SMBus
import time
import pathlib
# reset pin is P9.23, i.e. gpio1.17
reset_pin = pathlib.Path('/sys/class/gpio/gpio49/direction')
reset_pin.write_text('low')
MotorBridge = SMBus('/dev/i2c-2')
ReadMode = 0
WriteMode = 1
DeAddr = 0X4B
ConfigValid = 0x3a6fb67c
DelayTime = 0.005
…
def WriteByte(Reg,Value):
data = [0 for i in range(2)]
data[0] = Reg
data[1] = Value
MotorBridge.write_i2c_block_data(0x4b, 1, data)
def WriteHalfWord(Reg,Value):
data = [0 for i in range(3)]
data[0] = Reg
data[1] = Value & 0xff
data[2] = (Value>>8) & 0xff
MotorBridge.write_i2c_block_data(0x4b, 1, data)
def WriteOneWord(Reg,Value):
data = [0 for i in range(5)]
data[0] = Reg
data[1] = Value & 0xff
data[2] = (Value>>8) & 0xff
data[3] = (Value>>16) & 0xff
data[4] = (Value>>24) & 0xff
MotorBridge.write_i2c_block_data(0x4b, 1, data)
def SetDefault():
WriteOneWord(CONFIG_VALID,0x00000000)
…
On line 302 of the smbus2.py file, change the line to read:
filepath = "/dev/i2c-2".format(bus)
that should do it.
If you are making your source work in a virtual environment, sudo apt install python3-venv will take care of making some nice .txt files for use later in other Linux SBCs, e.g. requirements.txt is one.
Seth
P.S. If this makes sense, good. It took a while to get it to work without the read-only, deprecated versioning of Adafruit_GPIO.I2C as I2C.
Hello,
No issue, @Baozhu. It took me harassing a fellow quite a bit to figure it out. He figured it out before me b/c he knew how to read the smbus2.py file better than me. So, I kind of piggy-backed the source from him.
Seth