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
  • About Us
  • 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 Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 3: GPIO
  • 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: Jan Cumps
  • Date Created: 3 Apr 2025 6:37 PM Date Created
  • Views 909 views
  • Likes 7 likes
  • Comments 8 comments
Related
Recommended
  • pico
  • pico_eurocard
  • PIO

Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 3: GPIO

Jan Cumps
Jan Cumps
3 Apr 2025

The Pico has a set of PIO co-processors. They are real-time controllers that can execute logic with deterministic timing. Ideal to run strict-timed sequences and state machines. And to implement extra peripherals.
In this series, I'm trying to use the PIO to control a TI DRV8711 stepper motor controller.

image

Follow up of  Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 2: SPI .

Next to power, the driver IC has some digital inputs that we need to entertain. This post is my doco on how I connected them. Very short, nothing real happening here.
These are the Pico resources I reserve:

signal DRV8711 Pico
direction DIR

IO4

step STEP

IO5

sleep SLEEP

IO14

reset nRESET

IO15

power

3V3

ground

GND

All are outputs, Here's the code to set them. And a little helper.

#define NSTALL (-1)
#define NFAULT (-1)
#define NSLEEP (14)
#define RESET (15)
#define DIR (4)
#define STEP (5)

// ...

void init_drv8711_hw() {
    // nStall and nFault as input
    // not used
    // gpio_init(NSTALL);
    // gpio_set_dir(NSTALL, GPIO_IN);
    // gpio_set_pulls(NSTALL, true, false); // drv8711 outputs are open drain
    // gpio_init(NFAULT);
    // gpio_set_dir(NFAULT, GPIO_IN);
    // gpio_set_pulls(NFAULT, true, false); // drv8711 outputs are open drain
    
    // nSleep and Reset as output
    gpio_init(NSLEEP);
    gpio_put(NSLEEP, 0);
    gpio_set_dir(NSLEEP, GPIO_OUT);
    gpio_init(RESET);
    gpio_put(RESET, 0);
    gpio_set_dir(RESET, GPIO_OUT);
    
    // bin1 and bin2 as output
    // not used
    
    // DIR and STEP as output
    gpio_init(DIR);
    gpio_put(DIR, 0);
    gpio_set_dir(DIR, GPIO_OUT);
    gpio_init(STEP);
    gpio_put(STEP, 0);
    gpio_set_dir(STEP, GPIO_OUT);
}

void sleep(bool yes) {
    gpio_put(NSLEEP, yes? 0 : 1);
}

In main(), the pins are set. Before the logic, the driver is is woken up. At that time, a blocking current flows, that holds the motor in place.

When all done, we release that motor lock and send the driver to sleep again:

int main() {
    // ...
    init_drv8711_hw();
    // ...

   sleep(false);
   
   // business ...
   
   sleep(true);

    return 0;
}

Next post: PIO and putting it all together.
Thank you for reading.

  • Sign in to reply
  • Jan Cumps
    Jan Cumps 6 months ago in reply to DAB

    100%*, if the motor is not loaded more than it can handle. If there is more load on the motor than it can handle: random.

    I'd compare it to the reliability of engaging a relay.

    * except for solar flares, power outages, wear, unfortunate mishaps

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB 6 months ago in reply to Jan Cumps

    How repeatable are your step positions?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps 6 months ago in reply to shabaz

    The PIO script that I'm using is not that autonomous - still relies on the main controller for most of the logic.

    Once I know PIO better, I may try to make it easier to just hand over commands to it. And maybe make it do ramp-up and ramp-down profiles.

    Like the example for the TI Hercules timers that I tried many moons ago:

    image

    TI has some good documentation for the BeagleBone PRU timers too, including how to soft start, ramp up, slow down and stop: https://www.ti.com/lit/ug/tidu707/tidu707.pdf

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps 6 months ago

    Final post:  Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 4: PIO 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz 6 months ago

    Looking forward to seeing it take shape!

    Incidentally, using PIO has another nice benefit: PIO code can be run from MicroPython on the Pico too (the machine language code can be pasted from the .pio file into the Python file using some Python decorator), so effectively there's dual language support for almost free, if a project makes use of PIO. 

    • 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