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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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
Join Raspberry Pi to participate - click to join for free!
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 4942 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
  • shabaz
    shabaz over 1 year ago in reply to dougw

    Purely chance! I had dabbled with timer-driven code, but didn't do much. It was easy to take Jan's library (doesn't even need manual downloading/installing; the make file (CMakeLists.txt) contains a special fetch command that will automatically grab it and build with it) and just drop in the code to control the I/O expander which is the only board-specific part, since it sets up the Toshiba driver chips.

    It was just luck that it was easy to re-map the pins to be consecutive by re-wiring a few resistors.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 1 year ago

    Very cool.

    Making things move is the first step to making interesting applications.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to BigG

    > Say, would this PIO code work on the Raspberry Pi 5? 

    The PIO code should port just fine. The C++ wrapper would possibly need redesign - in particular the interrupt part - because that's Pico specific.
    (not sure if I'd do that on a Pi though - because it may have enough resources (threads) to run stepper motors in parallel on Linux without hickups.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • BigG
    BigG over 1 year ago

    Great demo and great teamwork, even if not planned.

    Say, would this PIO code work on the Raspberry Pi 5? 

    Would make for another interesting demo, if it's possible.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to dougw

    Good that the pcb exists :) - I wasn't able to test 2 motors. And these linear steppers are great to check if things are in sync.

     shabaz , it probably doesn't matter, but you can make the two state machines start at exactly the same time, if you enable them via this API:  pio_set_sm_mask_enabled (PIO pio, uint32_t mask, bool enabled): Enable or disable multiple PIO state machines

    First disable them with the same call. Send the commands, then enable.

    You can then have them start at exactly the same Pico clock tick.

    I don't think it really matters, because there are several mechanical tollerances at play that are larger than the few ticks between enabling SM1 and 2 separately in C code ...

    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube