{"id":12116,"date":"2016-02-03T09:15:58","date_gmt":"2016-02-03T17:15:58","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=12116"},"modified":"2021-06-16T14:26:52","modified_gmt":"2021-06-16T21:26:52","slug":"controlling-a-stepper-motor-with-an-fpga","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/controlling-a-stepper-motor-with-an-fpga\/","title":{"rendered":"Controlling a Stepper Motor with an FPGA"},"content":{"rendered":"<p>For those of you that have been following my last few posts on state machines, you know that I&#8217;ve been working on <a href=\"https:\/\/digilent.com\/shop\/pmod-peripheral-modules\/\">Pmod<\/a> interfaces for<a href=\"https:\/\/digilent.com\/shop\/fpga-programmable-logic\/\"> FPGA <\/a>as part of making the claw game. The first one I delved into was using the <a href=\"https:\/\/digilent.com\/shop\/pmodstep-stepper-motor-driver\/\">PmodSTEP<\/a>\u00a0and <a href=\"https:\/\/digilent.com\/shop\/basys-3-artix-7-fpga-trainer-board-recommended-for-introductory-users\/\">Basys 3<\/a>\u00a0to control a stepper motor.<\/p>\n<p>Here is a video of it working:<\/p>\n<p><iframe loading=\"lazy\" width=\"735\" height=\"413\" src=\"https:\/\/www.youtube.com\/embed\/62Tq9P4xpoY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>As you can see in the video, if you flip switch 1 the motor turns on or off, and if you flip switch 0 it changes the direction of the motor.<\/p>\n<p>Along \u00a0with writing the FPGA driver for the stepper motor I also created <a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\">an Instructable<\/a> so you can replicate the functionality in the video.<\/p>\n<p>In <a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\">the Instructable<\/a>, I cover what you need.<\/p>\n<figure id=\"attachment_12119\" aria-describedby=\"caption-attachment-12119\" style=\"width: 515px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12119 size-full\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog1-what-you-need.jpg\" alt=\"The first step covers what you need. This includes the Basys3, PmodSTEP, stepper motor, and micro USB cable.\" width=\"515\" height=\"583\" data-wp-pid=\"12119\" \/><\/a><figcaption id=\"caption-attachment-12119\" class=\"wp-caption-text\">The first step covers what you need. This includes the <a href=\"https:\/\/digilent.com\/shop\/basys-3-artix-7-fpga-trainer-board-recommended-for-introductory-users\/\">Basys3<\/a>, <a href=\"https:\/\/digilent.com\/shop\/pmodstep-stepper-motor-driver\/\">PmodSTEP<\/a>, stepper motor, and <a href=\"https:\/\/digilent.com\/shop\/usb-a-to-micro-b-cable\/\">micro USB cable<\/a>.<\/figcaption><\/figure>\n<p>Background info on stepper motors is also available.<\/p>\n<figure id=\"attachment_12120\" aria-describedby=\"caption-attachment-12120\" style=\"width: 487px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12120 size-full\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog2-background.jpg\" alt=\"Here I link to a video on stepper motors and describe stepper motors at the most basic level.\" width=\"487\" height=\"663\" data-wp-pid=\"12120\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog2-background.jpg 487w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog2-background-441x600.jpg 441w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/a><figcaption id=\"caption-attachment-12120\" class=\"wp-caption-text\">Here I link to a video on stepper motors and describe stepper motors at the most basic level.<\/figcaption><\/figure>\n<p>But what&#8217;s the theory behind the code?<\/p>\n<figure id=\"attachment_12121\" aria-describedby=\"caption-attachment-12121\" style=\"width: 496px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12121 size-full\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog2-idea.jpg\" alt=\"In this step I describe my state diagram and the idea behind how I coded this. \" width=\"496\" height=\"538\" data-wp-pid=\"12121\" \/><\/a><figcaption id=\"caption-attachment-12121\" class=\"wp-caption-text\">In this step I describe my state diagram and the idea behind how I coded this.<\/figcaption><\/figure>\n<p>I talk about how to download, open, and program the project to the Basys3.<\/p>\n<figure id=\"attachment_12117\" aria-describedby=\"caption-attachment-12117\" style=\"width: 512px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12117 size-full\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog-3-code.jpg\" alt=\"In a few steps I describe how to program the board.\" width=\"512\" height=\"520\" data-wp-pid=\"12117\" \/><\/a><figcaption id=\"caption-attachment-12117\" class=\"wp-caption-text\">In a few steps I describe how to program the board using <a href=\"http:\/\/www.xilinx.com\/products\/design-tools\/vivado.html\">Xilinx Vivado<\/a>.<\/figcaption><\/figure>\n<p>And lastly how to tie everything\u00a0together.<\/p>\n<figure id=\"attachment_12118\" aria-describedby=\"caption-attachment-12118\" style=\"width: 544px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12118 size-full\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog-4-plug.jpg\" alt=\"The last step is to plug all of the pieces together. \" width=\"544\" height=\"507\" data-wp-pid=\"12118\" \/><\/a><figcaption id=\"caption-attachment-12118\" class=\"wp-caption-text\">The last step is to plug all of the pieces together.<\/figcaption><\/figure>\n<p>To view the full Instructable,\u00a0<a href=\"http:\/\/www.instructables.com\/id\/How-to-Control-a-Stepper-Motor-With-an-FPGA\/\">click here<\/a>.<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-12116 jlk' data-task='like' data-post_id='12116' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-12116 lc'>+3<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-12116 jlk' data-task='unlike' data-post_id='12116' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-12116 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-12116 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>This tutorial walks you through controlling a stepper motor with an FPGA.<\/p>\n","protected":false},"author":18,"featured_media":12118,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4327,35],"tags":[1662,144,453],"ppma_author":[4466],"class_list":["post-12116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-fpga","tag-fpga","tag-tutorial-2","tag-vivado"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/01\/blog-4-plug.jpg","authors":[{"term_id":4466,"user_id":18,"is_guest":0,"slug":"kaitlyn","display_name":"Kaitlyn Franz","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/3f16f6159d3666c6fd05a4b73a18c286?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Franz","last_name_2":"","first_name":"Kaitlyn","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/12116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=12116"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/12116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/12118"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=12116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=12116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=12116"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=12116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}