0

Adafruit DC & Stepper Motor Bonnet for Raspberry Pi
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by bpe on Tue May 11, 2021 3:12 pm

Hi,
I received the hat and followed the tutorial here:
https://learn.adafruit.com/adafruit-dc- ... g-software

Successfully installed all the libraries however when I tried to run the test code:
==========================================================
# 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

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

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

I get an error message saying:
Traceback (most recent call last):
File "stepper.py", line 6, in <module>
import board
ImportError: No module named board

How do I get the board libraries installed? What did I miss? I am trying to use a Nema 17 Stepper motor connected on M1, M2 on the board. (I enabled both I2C and SP2 on my raspberry pi zero w)

Thanks

bpe
 
Posts: 5
Joined: Fri Nov 28, 2014 10:49 pm

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by mikeysklar on Wed May 12, 2021 1:31 pm

@bpe,

It looks like your Pi is not finding the libraries.

Is your Pi up to date with a current Pi OS and you installed the libraries with:

Code: Select all | TOGGLE FULL SIZE
sudo pip3 install adafruit-circuitpython-motorkit


It should look like this when it runs successfully:

Code: Select all | TOGGLE FULL SIZE
 $ sudo pip3 install adafruit-circuitpython-motorkit
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting adafruit-circuitpython-motorkit
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-motorkit/adafruit_circuitpython_motorkit-1.6.2-py3-none-any.whl
Collecting adafruit-circuitpython-busdevice (from adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-busdevice/adafruit_circuitpython_busdevice-5.0.6-py3-none-any.whl
Collecting adafruit-circuitpython-pca9685 (from adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-pca9685/adafruit_circuitpython_pca9685-3.3.6-py3-none-any.whl
Collecting adafruit-circuitpython-register (from adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-register/adafruit_circuitpython_register-1.9.5-py3-none-any.whl
Collecting Adafruit-Blinka (from adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-blinka/Adafruit_Blinka-6.9.1-py3-none-any.whl (169kB)
    100% |████████████████████████████████| 174kB 444kB/s
Collecting adafruit-circuitpython-motor (from adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-circuitpython-motor/adafruit_circuitpython_motor-3.3.0-py3-none-any.whl
Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-motorkit) (0.7.0)
Collecting rpi-ws281x>=4.0.0 (from Adafruit-Blinka->adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/rpi-ws281x/rpi_ws281x-4.2.6-cp37-cp37m-linux_armv7l.whl (116kB)
    100% |████████████████████████████████| 122kB 472kB/s
Collecting sysv-ipc>=1.1.0 (from Adafruit-Blinka->adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/sysv-ipc/sysv_ipc-1.1.0-cp37-cp37m-linux_armv7l.whl (68kB)
    100% |████████████████████████████████| 71kB 3.4MB/s
Collecting pyftdi>=0.40.0 (from Adafruit-Blinka->adafruit-circuitpython-motorkit)
  Downloading https://files.pythonhosted.org/packages/7f/f0/d1eccc82e727e6fa332529ea5a59e9158a4f906b9cd0c990ca580cdafed1/pyftdi-0.53.1-py3-none-any.whl (141kB)
    100% |████████████████████████████████| 143kB 1.9MB/s
Collecting Adafruit-PureIO>=1.1.7 (from Adafruit-Blinka->adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-pureio/Adafruit_PureIO-1.1.8-py3-none-any.whl
Collecting Adafruit-PlatformDetect>=3.1.0 (from Adafruit-Blinka->adafruit-circuitpython-motorkit)
  Downloading https://www.piwheels.org/simple/adafruit-platformdetect/Adafruit_PlatformDetect-3.13.0-py3-none-any.whl
Collecting pyusb>=1.0.0 (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-motorkit)
  Downloading https://files.pythonhosted.org/packages/b5/28/b857ac783257f142932b23379d761a3d9becf6deecf5d14075ec19bdb890/pyusb-1.1.1-py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 3.2MB/s
Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-motorkit) (3.4)
Installing collected packages: rpi-ws281x, sysv-ipc, pyusb, pyftdi, Adafruit-PureIO, Adafruit-PlatformDetect, Adafruit-Blinka, adafruit-circuitpython-busdevice, adafruit-circuitpython-register, adafruit-circuitpython-pca9685, adafruit-circuitpython-motor, adafruit-circuitpython-motorkit
Successfully installed Adafruit-Blinka-6.9.1 Adafruit-PlatformDetect-3.13.0 Adafruit-PureIO-1.1.8 adafruit-circuitpython-busdevice-5.0.6 adafruit-circuitpython-motor-3.3.0 adafruit-circuitpython-motorkit-1.6.2 adafruit-circuitpython-pca9685-3.3.6 adafruit-circuitpython-register-1.9.5 pyftdi-0.53.1 pyusb-1.1.1 rpi-ws281x-4.2.6 sysv-ipc-1.1.0


Then run your stepper script with this command:

Code: Select all | TOGGLE FULL SIZE
python3 stepper.py

mikeysklar
 
Posts: 4624
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by bpe on Fri May 14, 2021 9:30 am

Hi,
Thank you! That worked!

One last question:
When I use my Adafruit ordered stepper motor, the scripts work great. When I try with my original stepper motor (Model 17HS4401), somehow it works but not quite (choppy and skipping motion). The stepping is not accurate.

In reading the guide, it states that this may be due to power / current issues. Is there a hat that is able to support a Nema 17 that needs 12v 1.2A specs. I actually have another one that needs 12v 1.7A (Model 42BYGHM809) as well. I'm trying to reuse my old 3D printer stepper motors for a new project.

Thanks
Bob

bpe
 
Posts: 5
Joined: Fri Nov 28, 2014 10:49 pm

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by mikeysklar on Fri May 14, 2021 12:19 pm

Yeah, I'm not sure what the deal with using other steppers. Good luck with that. Glad you got the example going.

mikeysklar
 
Posts: 4624
Joined: Mon Aug 01, 2016 8:10 pm

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by bpe on Fri May 14, 2021 12:24 pm

Is there any way you can get the motor to rotate faster? i tried the double stepping but even that still feels slow for what I am trying to do. Any suggestions?

bpe
 
Posts: 5
Joined: Fri Nov 28, 2014 10:49 pm

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by adafruit_support_bill on Fri May 14, 2021 12:28 pm

The 17HS4401 is not compatible with the Bonnet. Based on the specs, it appears to have been designed for use with a current-limiting 'chopper' type driver. Simple H-Bridge type drivers such as the ones on the Bonnet will overload when used with motors like that. https://www.handsontec.com/dataspecs/17HS4401S.pdf

We have the DRV8833 which is a current-limiting driver. It could safely drive that motor, but would not be able to get peak performance from it. www.pololu.com carries a wider selection of current limiting stepper drivers and would have boards better suited to getting the most from that motor.

adafruit_support_bill
 
Posts: 81328
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by adafruit_support_bill on Fri May 14, 2021 12:29 pm

Is there any way you can get the motor to rotate faster?

Eliminate the sleep between steps.

adafruit_support_bill
 
Posts: 81328
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor Bonnet for Raspberry Pi

by bpe on Fri May 14, 2021 12:32 pm

Great! Thank you for the clarifications and pointers! I'll checkout Polulu and see what they have. I'll also try eliminate the sleep and see how that goes. Appreciate the quick response!

bpe
 
Posts: 5
Joined: Fri Nov 28, 2014 10:49 pm

Please be positive and constructive with your questions and comments.