element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Blog Raspberry PIO Stepper Library: Trying it out with a Pi Pico and two Stepper Motors!
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
GPIO Pinout
Raspberry Pi Wishlist
Comparison Chart
Quiz
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 23 Apr 2025 7:13 PM Date Created
  • Views 1587 views
  • Likes 9 likes
  • Comments 14 comments
Related
Recommended
  • raspberry
  • pico
  • PIO
  • stepper-motor
  • c++

Raspberry PIO Stepper Library: Trying it out with a Pi Pico and two Stepper Motors!

shabaz
shabaz
23 Apr 2025

Stepper motors are super-useful for precision movements.

I made a little stepper motor board a while back, but never got around to testing it at the time.

Jan Jan Cumps has created a stepper motor control library (click here to learn about it:  Raspberry PIO stepper library documentation - 1: intro, set up project and simple example )  that uses special hardware inside the Pi Pico chip, called PIO. The PIO hardware allows for precise control of inputs and outputs. 

The PIO is used to pulse an output that goes to a Toshiba chip which translates that to higher-current outputs in a sequence to drive the coils of the motor.

The video shows a quick first test of the board, using Jan's stepper motor library.

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Here's another short video; showing interaction from a terminal/console connection. This will be useful when trying out new stepper motors and mechanisms, to experiment and discover what speeds and steps are needed:

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

The stepper motors/leadscrew/linear rails combo were purchased from AliExpress quite a while ago. The particular AliExpress seller no longer has more to sell, but I have seen that other AliExpress sellers have very similar-looking options.

I need to experiment a bit more, but it's great to see the board operational with the stepper motor code.

The circuit diagram is below (this is a more recent revision 1.1, compared to the revision 1.0 board which I used. The rev 1.1 board is directly compatible with Jan's stepper motor library, whereas the older rev 1.0 board needs a few resistor changes). The PDF circuit diagram is downloadable here.

image

If you wish to build the board, see the pico-dual-stepper GitHub repo for the Gerber files.

Top layer:

image

3D render:

image

The underside doesn't have any components:

image

The PDF Parts List is available here.

 

  • Sign in to reply
  • BigG
    BigG 24 days ago in reply to Jan Cumps

    docs.python.org/.../asyncio.html

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps 24 days ago in reply to BigG

    the interrupt that I'm generating (and will have to try and capture) isn't one based on a pin's edge. It should fire when all steps are generated - a logic-condition-based interrupt cause.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • BigG
    BigG 24 days ago in reply to Jan Cumps

    I thought as much. Cool.

    I believe the pigpio python library for raspberry pi allows you to use hardware interrupts. There's also an updated/enhanced RPI.GPIO library out there that does the same (cannot remember exactly which one).

    import pigpio
    import time
    
    def my_callback(gpio, level, tick):
        print(f"Interrupt on GPIO {gpio}, level {level} at tick {tick}")
    
    pi = pigpio.pi()
    if not pi.connected:
        exit()
    
    gpio_pin = 4  # Example GPIO pin
    pi.set_mode(gpio_pin, pigpio.INPUT)
    pi.set_pull_up_down(gpio_pin, pigpio.PUD_DOWN) # Or PUD_UP
    
    # Trigger callback on rising edge
    pi.callback(gpio_pin, pigpio.RISING_EDGE, my_callback)
    
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        pi.stop()

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz 24 days ago in reply to shabaz

    Done, it is here:

    https://github.com/shabaz123/pico-dual-stepper/tree/main/interactive_console_example/stepper_test2

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz 25 days ago

    Added an interactive console thing to quickly test out things on-the-fly (it's now embedded in the main blog too):

    https://youtu.be/SxN2Bi1Z2GM

    I'll put the code at the same GitHub location hopefully tonight or tomorrow.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube