{"id":12157,"date":"2016-02-05T09:15:31","date_gmt":"2016-02-05T17:15:31","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=12157"},"modified":"2021-06-16T14:26:19","modified_gmt":"2021-06-16T21:26:19","slug":"using-the-pmodjstk-to-control-a-stepper-motor-with-the-basys-3","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/using-the-pmodjstk-to-control-a-stepper-motor-with-the-basys-3\/","title":{"rendered":"Using the PmodJSTK to control a Stepper Motor with the Basys 3"},"content":{"rendered":"<p>A few days ago\u00a0I wrote a post about <a href=\"https:\/\/digilent.com\/blog\/index.php\/controlling-a-stepper-motor-with-an-fpga\/\">how to control a stepper motor with an FPGA<\/a>, using the switches to control the direction and enable signal of the motor.<\/p>\n<p>As excited as I was that I could now control a stepper motor with the <a href=\"https:\/\/digilent.com\/shop\/basys-3-artix-7-fpga-trainer-board-recommended-for-introductory-users\/\">Basys 3<\/a>, controlling it with just switches wasn&#8217;t very realistic. Especially for the claw game, which is after all the end goal. Luckily I found a <a href=\"https:\/\/digilent.com\/shop\/pmodjstk-two-axis-joystick\/\">PmodJSTK<\/a> in my desk. The <a href=\"https:\/\/digilent.com\/shop\/pmodjstk-two-axis-joystick\/\">PmodJSTK <\/a>is an adorable little joystick module that also has LEDs and buttons.<\/p>\n<figure id=\"attachment_6793\" aria-describedby=\"caption-attachment-6793\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/shop\/pmodjstk-two-axis-joystick\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-6793 size-medium\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/05\/PmodJSTK-joystick-600x397.jpg\" alt=\"The PmodJSTK.\" width=\"600\" height=\"397\" data-wp-pid=\"6793\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/05\/PmodJSTK-joystick-600x397.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/05\/PmodJSTK-joystick-225x149.jpg 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/05\/PmodJSTK-joystick.jpg 640w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-6793\" class=\"wp-caption-text\">The PmodJSTK. Adorable.<\/figcaption><\/figure>\n<p>So I set out to get the PmodJSTK controlling two stepper motors, one for the X direction and one for the Y direction. I lucked out again when I discovered that someone long ago had written an <a href=\"https:\/\/digilent.com\/reference\/pmod:pmod:jstk:example_code\">FPGA module for the PmodJSTK<\/a>. Unfortunately, it was written for the <a href=\"https:\/\/digilent.com\/shop\/nexys-3-spartan-6-fpga-trainer-board-limited-time-see-nexys4-ddr\/\">Nexys 3<\/a> using <a href=\"http:\/\/www.xilinx.com\/products\/design-tools\/ise-design-suite\/ise-webpack.html\">Xilinx ISE<\/a>.<\/p>\n<figure id=\"attachment_12277\" aria-describedby=\"caption-attachment-12277\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/reference\/pmod:pmod:jstk:example_code\" rel=\"attachment wp-att-12277\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12277 size-medium\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-600x288.jpg\" alt=\"The code example section of the resource center for the PmodJSTK.\" width=\"600\" height=\"288\" data-wp-pid=\"12277\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-600x288.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-768x369.jpg 768w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-1024x492.jpg 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-1078x516.jpg 1078w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-702x336.jpg 702w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference-800x384.jpg 800w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-reference.jpg 1207w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-12277\" class=\"wp-caption-text\">The code example section of the resource center for the PmodJSTK.<\/figcaption><\/figure>\n<p>However, I was easily able to change it over to using the Basys 3 with <a href=\"http:\/\/www.xilinx.com\/products\/design-tools\/vivado.html\">Xilinx Vivado<\/a>. By change the <a href=\"https:\/\/digilent.com\/blog\/index.php\/converting-from-ucf-to-xdc-file\/\">UCF file to an XDC file<\/a>. If you&#8217;d like to learn more about that process, check out this previous blog post. Sometimes depending on how the module was written it doesn&#8217;t always directly transfer over, but this one did!<\/p>\n<figure id=\"attachment_12278\" aria-describedby=\"caption-attachment-12278\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/index.php\/converting-from-ucf-to-xdc-file\/\" rel=\"attachment wp-att-12278\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12278 size-medium\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-xdc-600x461.jpg\" alt=\"The blog post about converting from XDC to UCF file.\" width=\"600\" height=\"461\" data-wp-pid=\"12278\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-xdc-600x461.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-xdc.jpg 747w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-12278\" class=\"wp-caption-text\">The blog post about converting from XDC to UCF file.<\/figcaption><\/figure>\n<p>Now all I needed to do was disable the functionality of the LEDs and buttons on the PmodJSTK since I was only using the JSTK part.\u00a0I also had to create a decoder to decode the information sent from the PmodJSTK into right, left, up and down signals.<\/p>\n<p><iframe loading=\"lazy\" width=\"735\" height=\"551\" src=\"https:\/\/www.youtube.com\/embed\/CHotRih1IJU?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p>You can see the full code and explanation\u00a0of what I did in my Instructable, <a href=\"http:\/\/www.instructables.com\/id\/Using-the-PmodJSTK-to-Control-Stepper-Motors-on-th\/\">Using the PmodJSTK to Control Stepper Motors on the Basys 3<\/a>.<\/p>\n<figure id=\"attachment_12279\" aria-describedby=\"caption-attachment-12279\" style=\"width: 794px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.instructables.com\/id\/Using-the-PmodJSTK-to-Control-Stepper-Motors-on-th\/\" rel=\"attachment wp-att-12279\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-12279\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-inst.jpg\" alt=\"The Instructable on how to make the PmodJSTK control stepper motors. \" width=\"794\" height=\"569\" data-wp-pid=\"12279\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-inst.jpg 794w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-inst-600x430.jpg 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/blog-inst-768x550.jpg 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/a><figcaption id=\"caption-attachment-12279\" class=\"wp-caption-text\">The Instructable on how to make the PmodJSTK control stepper motors.<\/figcaption><\/figure>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-12157 jlk' data-task='like' data-post_id='12157' 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-12157 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-12157 jlk' data-task='unlike' data-post_id='12157' 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-12157 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-12157 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>Use a Basys 3 and PmodJSTK to control a stepper motor.<\/p>\n","protected":false},"author":18,"featured_media":12281,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,35,1563,1561],"tags":[1662,453],"ppma_author":[4466],"class_list":["post-12157","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-expansion-modules","category-fpga","category-guide","category-applications","tag-fpga","tag-vivado"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2016\/02\/Capture.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\/12157","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=12157"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/12157\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/12281"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=12157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=12157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=12157"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=12157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}