Adafruit DC & Stepper Motor Hat with UP board

Jeff DusekJeff Dusek New Member Posts: 9
Hoping to use the UP board with an Intel Realsense R200 camera for the "brains" of a mobile robot this summer for use with undergraduate summer students.

I have the UP board with Ubuntu 16.04 and Realsense working together nicely. I am using the 4.4.0-2-upboard kernel.

After looking on the UP wiki I decided to try the Adafruit DC & Stepper Motor Hat because it had been verified to work with the UP board using the modified Adafruit python code from Emutex.

Following the How-to on the wiki I installed and setup the Adafruit-Motor-HAT-Python-Library and the Adafruit_Python_GPIO.

When I tried to run the DCTest.py script I get the following errors:

Traceback (most recent call last):
File "DCTest.py", line 2, in <module>
from Adafruit_MotorHAT import Adafruit_MotorHAT, Adafruit_DCMotor
File "build/bdist.linux-x86_64/egg/Adafruit_MotorHAT/__init__.py", line 1, in <module>
File "build/bdist.linux-x86_64/egg/Adafruit_MotorHAT/Adafruit_MotorHAT.py", line 3, in <module>
File "build/bdist.linux-x86_64/egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 11, in <module>
File "build/bdist.linux-x86_64/egg/Adafruit_MotorHAT/Adafruit_PWM_Servo_Driver.py", line 35, in PWM
File "build/bdist.linux-x86_64/egg/Adafruit_MotorHAT/Adafruit_I2C.py", line 53, in __init__
IOError: [Errno 13] Permission denied

One thing I have noticed is that there doesn't seem to be Adafruit_DCMotor in either the Motorhat library downloaded from Emutex or from Adafruit.

I'm relatively new to Python, so I might be missing some other simple errors, but I'm wondering if anyone has been successful in using the Adafruit DC & Stepper Motor Hat with the UP board, and what you did to make it work.

Thanks in advance.

Comments

  • Dan O'DonovanDan O'Donovan Emutex Posts: 229 mod
    Hi JDusek
    On Ubuntu, I think you need to run those Python scripts as root (or using 'sudo'). I've updated the instructions to include that now.
    Thanks,
    -Dan
  • Jeff DusekJeff Dusek New Member Posts: 9
    Dan,

    I thought I had changed the file permissions correctly to a local user, but perhaps I made a mistake. Running the Python script as root does seem to make it work, but is unclear to me why.

    I also found that I needed to connect the motor to M3 instead of M1 to get it to work.

    Thanks,
    Jeff
  • Dan O'DonovanDan O'Donovan Emutex Posts: 229 mod
    The reason you need root there is because the script will access device nodes (e.g. /dev/i2c-1) which are most likely restricted to root user access.
  • Jeff DusekJeff Dusek New Member Posts: 9
    Dan,

    New question for you. I am now trying to test the Adafruit PWM /Servo Hat. I have installed the python software as specified on the wiki.

    When I run "sudo python simpletest.py"

    I get:
    Traceback (most recent call last):
    File "simpletest.py", line 17, in <module>
    pwm = Adafruit_PCA9685.PCA9685()
    File "build/bdist.linux-x86_64/egg/Adafruit_PCA9685/PCA9685.py", line 74, in __init__
    File "build/bdist.linux-x86_64/egg/Adafruit_GPIO/I2C.py", line 66, in get_i2c_device
    File "build/bdist.linux-x86_64/egg/Adafruit_GPIO/I2C.py", line 58, in get_default_bus
    RuntimeError: Could not determine default I2C bus for platform.

    I have searched the forum and web and can't seem to find information on setting up I2c on the UP board. Is there a fix to this in Ubuntu? Or, would using Ubilinux make this easier?

    I am not opposed to Ubilinux as long as I can still install Open Cv

    Thanks,
    Jeff
  • Dan O'DonovanDan O'Donovan Emutex Posts: 229 mod
    Ah, I think I know what's probably happening here.

    These examples were developed on ubilinux, which has Intel's MRAA library pre-installed by default. Some of these Adafruit Python modules use MRAA, if present, to figure out which platform its running on and which default I2C bus to use.

    MRAA is not pre-installed with Ubuntu. However, it can be installed by following the instructions here (search for "Ubuntu" on this page): https://github.com/intel-iot-devkit/mraa
  • Jeff DusekJeff Dusek New Member Posts: 9
    Dan,

    This worked- thank you!
Sign In or Register to comment.