<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><description>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&amp;#39;m trying t...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Sat, 19 Apr 2025 20:22:16 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The PIO program that I wrote works, but it&amp;nbsp;violates a requirement from the stepper motor driver I use, a TI DRV8711&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="186" src="/resized-image/__size/992x372/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-f22ae837-6bef-4eb4-ac01-941403c8c38b/pastedimage1745093724237v1.png" width="496" /&gt;&lt;/p&gt;
&lt;p&gt;There should be a 200 ns time between setting the DIR pin, and taking a step. My code violated that blatantly. It had&amp;nbsp;4 PIO clock ticks between the two events.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have a perfect solution yet, that works for all PIO clock speeds. Wat I&amp;#39;ve done now is configure the highest speed that works for my&amp;nbsp;project.&lt;br /&gt;Then stretch the clocks used to set the DIR pin:&lt;/p&gt;
&lt;pre&gt;.define public DIR_DELAY 4&lt;br /&gt;# ...&lt;br /&gt;out pins, 1 side 0 [DIR_DELAY] ; shift direction out of OSR and output to dir. 200 ns before next step&lt;/pre&gt;
&lt;p&gt;The [DIR_DELAY] stretches the clock ticks used by the out command from one tick to 5. (the command, and 4 delay ticks)&lt;br /&gt;It&amp;#39;s not perfect. For slower PIO clock speeds (something you set, there will be a (nanosecond order of magnitude) delay. But I bet that you won&amp;#39;t notice it.&lt;br /&gt;This is the scope capture of the time between the events, with the adapted code:&lt;/p&gt;
&lt;p&gt;&lt;img height="300" src="/resized-image/__size/1000x600/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-f22ae837-6bef-4eb4-ac01-941403c8c38b/DS1Z_5F00_QuickPrint8.png" width="500" alt=" " /&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Mon, 07 Apr 2025 19:36:29 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Time taken by the ARM core to load an instruction into the PIO FIFO.&amp;nbsp;I used a GPIO to measure the time, so you &amp;#39;d have to discount&amp;nbsp;two gpio_put() calls from the&amp;nbsp;360 ns&amp;nbsp;it takes to pass the instruction from ARM to PIO.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="300" src="/resized-image/__size/1000x600/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-f22ae837-6bef-4eb4-ac01-941403c8c38b/pastedimage1744054576274v1.png" width="500" /&gt;&lt;/p&gt;
&lt;p&gt;An instruction can have many steps (millions, if you need - anything that fits in 31 bits. For any process that&amp;nbsp;needs a motor to step for milliseconds or seconds (or longer), this is definitely a resource gain. (although you can&amp;#39;t put the Pico to sleep during that time, because then the PIO would stop too)&lt;/p&gt;
&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Mon, 07 Apr 2025 19:10:36 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In this video, a LED shows how much time it takes to send 6 instructions to PIO.&amp;nbsp;In total 1600 steps, including direction changes in between.&lt;br /&gt;The motor is fast too&amp;nbsp;[emoticon:c4563cd7d5574777a71c318021cbbcc8]&amp;nbsp;- but that is because I uptimised its speed and torque. Even if each of these 6 instructions would generate 100.000s of steps, the setup time in the ARM controller would be the same.&lt;/p&gt;
&lt;p&gt;[View:https://youtu.be/9sVK7T45DL8:640:360]&lt;/p&gt;
&lt;p&gt;In a classic design, the microcontroller would have to spend clock ticks controlling the motor. Ticks it can&amp;#39;t spend on other activities.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Mon, 07 Apr 2025 16:40:19 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Using an old school counter to validate the stepper motor firmware:&lt;/p&gt;
&lt;p&gt;[View:https://youtu.be/OoEPBERgOKc:640:360]&lt;/p&gt;
&lt;p&gt;My oscilloscope can do that too, as long as I can fit the signal on a single screen. A counter doesn&amp;#39;t&amp;nbsp;have that limitation.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Mon, 07 Apr 2025 16:12:38 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Project&amp;nbsp;now available on GitHub:&amp;nbsp;&lt;a id="" href="https://github.com/jancumps/pio_drv8711_stepper" rel="noopener noreferrer nofollow" target="_blank" data-e14adj="t"&gt;https://github.com/jancumps/pio_drv8711_stepper&lt;/a&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Sun, 06 Apr 2025 17:42:49 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;A test to see if the PIO actually generates the amount of steps that I request. In this case: 350.&lt;/p&gt;
&lt;p&gt;&lt;img height="299" src="/resized-image/__size/996x598/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-f22ae837-6bef-4eb4-ac01-941403c8c38b/DS1Z_5F00_QuickPrint4.png" width="498" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve used my oscilloscope&amp;#39;s pulse counter to do the work for me. It&amp;#39;s a match.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: Stepper Motor Control with Raspberry Pico PIO and DRV8711 driver- Part 5: a more autonomous PIO</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/stepper-motor-control-with-raspberry-pico-pi-and-drv8711-driver--part-5-a-more-autonomous-pio</link><pubDate>Sun, 06 Apr 2025 16:25:08 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:f22ae837-6bef-4eb4-ac01-941403c8c38b</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Here&amp;#39;s an example stepper motor program:&lt;/p&gt;
&lt;p&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:edcbe254-91c9-419d-a45c-ad9448ed8c22:type=c_cpp&amp;text=struct%20command%20%7B%0D%0A%20%20%20%20uint32_t%20steps%3B%0D%0A%20%20%20%20bool%20reverse%3B%0D%0A%7D%3B%0D%0A%0D%0A%20%20%20%20%2F%2F%20...%0D%0A%20%20%20%20std%3A%3Aarray%3Ccommand%2C%206%3E%20cmd%7B%7B%7B200%2C%20true%7D%2C%20%7B200%2C%20false%7D%2C%7B200%2C%20false%7D%2C%7B400%2C%20false%7D%2C%7B250%2C%20true%7D%2C%7B350%2C%20true%7D%7D%7D%3B%20%20%20%20%0D%0A%20%20%20%20for%28auto%20c%20%3A%20cmd%29%20%7B%0D%0A%20%20%20%20%20%20%20%20printf%28%22Steps%20%3D%20%25d%5Cn%22%2C%20c.steps%29%3B%0D%0A%20%20%20%20%20%20%20%20pio_stepper_set_steps%28piostep%2C%20sm%2C%20c.steps%2C%20c.reverse%29%3B%0D%0A%20%20%20%20%7D]&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28817&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>