I verified i2c is activated, and running i2c detect -y 1 shows 0x40 marked with a 40
Have a basic test program, that looks like:
import pi_servo_hat
import time
test = pi_servo_hat.PiServoHat()
test.restart()
when i run it I get the below error:
Traceback (most recent call last):
File "/home/pzpi/repos/hello_servo_world.py", line 4, in <module>
test=pi_servo_hat.PiServoHat()
File "/usr/local/lib/python2.7/dist-packages/pi_servo_hat.py", line 169, in __init__
self.set_pwm_frequency(_DEFAULT_SERVO_FREQUENCY)
File "/usr/local/lib/python2.7/dist-packages/pi_servo_hat.py", line 249, in set_pwm_frequency
if self.PCA9685.set_pre_scale(frequency) == True:
File "/usr/local/lib/python2.7/dist-packages/qwiic_pca9685.py", line 1301, in set_pre_scale
self._i2c.writeByte(self.address, PRE_SCALE, pwmPreScale)
File "/usr/local/lib/python2.7/dist-packages/qwiic_i2c/linux_i2c.py", line 226, in writeByte
return self.i2cbus.write_byte_data(address, commandCode, value)
File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 454, in write_byte_data
msg.data.contents.byte = value
TypeError: int expected instead of float
clearly somewhere the wrong value is being passed, but not sure how to troubleshoot this as it seems the error is in the library provided? any help would be great, thank you!
i had to manually go into smbus2.py and change all the
msg.data.contents.byte = value
``` lines to ```
msg.data.contents.byte = int(value)
then there were some areas in pi_servo_hat.py i had to modify to convert ints to floats such as in the move_servo_position function as values were being treated as ints, so were getting a 0 value when they should have gotten a low decimal value (e.g. period, m, etc.).
I kinda know python but not well enough to know all the nuances, could this be because i am using python 2.7 instead of python3+? Using 2.7 because its what ros melodic uses.
I purchased SparkFun Auto pHAT and tried to use software configuration on their website, but I received an error when i run “test=pi_servo_hat.PiServoHat()”
test=pi_servo_hat.PiServoHat()
Traceback (most recent call last):
File “”, line 1, in
File “/home/admin/lab/lib/python3.11/site-packages/pi_servo_hat.py”, line 190, in init
self.set_pwm_frequency(_DEFAULT_SERVO_FREQUENCY)
File “/home/admin/lab/lib/python3.11/site-packages/pi_servo_hat.py”, line 296, in set_pwm_frequency
if self.PCA9685.set_pre_scale(frequency) == True:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/admin/lab/lib/python3.11/site-packages/qwiic_pca9685.py”, line 1255, in set_pre_scale
mode1 = self._i2c.readByte(self.address, MODE1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/admin/lab/lib/python3.11/site-packages/qwiic_i2c/linux_i2c.py”, line 190, in readByte
raise ioErr
File “/home/admin/lab/lib/python3.11/site-packages/qwiic_i2c/linux_i2c.py”, line 183, in readByte
data = self._i2cbus.read_byte_data(address, commandCode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/admin/lab/lib/python3.11/site-packages/smbus2/smbus2.py”, line 435, in read_byte_data
ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error