Using the PmodJSTK to control a Stepper Motor with the Basys 3

A few days ago I wrote a post about how to control a stepper motor with an FPGA, using the switches to control the direction and enable signal of the motor.

As excited as I was that I could now control a stepper motor with the Basys 3, controlling it with just switches wasn’t very realistic. Especially for the claw game, which is after all the end goal. Luckily I found a PmodJSTK in my desk. The PmodJSTK is an adorable little joystick module that also has LEDs and buttons.

The PmodJSTK.
The PmodJSTK. Adorable.

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 FPGA module for the PmodJSTK. Unfortunately, it was written for the Nexys 3 using Xilinx ISE.

The code example section of the resource center for the PmodJSTK.
The code example section of the resource center for the PmodJSTK.

However, I was easily able to change it over to using the Basys 3 with Xilinx Vivado. By change the UCF file to an XDC file. If you’d like to learn more about that process, check out this previous blog post. Sometimes depending on how the module was written it doesn’t always directly transfer over, but this one did!

The blog post about converting from XDC to UCF file.
The blog post about converting from XDC to UCF file.

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. I also had to create a decoder to decode the information sent from the PmodJSTK into right, left, up and down signals.

You can see the full code and explanation of what I did in my Instructable, Using the PmodJSTK to Control Stepper Motors on the Basys 3.

The Instructable on how to make the PmodJSTK control stepper motors.
The Instructable on how to make the PmodJSTK control stepper motors.

Author

Be the 1st to vote.

5 Comments on “Using the PmodJSTK to control a Stepper Motor with the Basys 3”

  1. I didn’t know about the reference section of digilent website. There is a lot of useful stuff over there!
    Any plans to add the files converted for Vivado over there?

    1. Hi Marco,
      Reference.Digilentinc.com is where all of the most up to date projects, examples and documentation are. I always check there first.

      There is no active plan to convert that I know of right now. The existing projects usually get converted as people use them in Vivado.

      If you have any projects up that are designed for ISE you can follow this blog post to convert them. Most projects will transfer over by following these steps.

      https://blog.digilentinc.com/index.php/converting-from-ucf-to-xdc-file/

      Kaitlyn

  2. Hi Digilent friends,

    I hope this message reaches you and doesn’t get lost in the void. I am a frequent client of yours, and would like very much to replicate this project with the Digilent parts I have. I already have a Basys3, so I try to get the joystick and the other required parts. I noticed that the PmodSTEP board is no longer in production, so I bought the next option you have in store: the PmodDHB1

  3. Hi Digilent friends,

    Is it possible to drive the Nema Stepper Motor that you recommend with the PmodDHB1 board? Since the PmodSTEP is no longer being manufactured, should I assume that I can use the PmodDHB1 instead for each one of these Basys3-based stepper motor control projects? Please let me know.

    Best,
    Diego

    1. Hi Diego,

      Thank you for your question! I spoke with one of our support engineers, and you would need to route individual wires from two different headers on the Pmod DHB1 to make a bipolar stepper motor work, as well as modifying your source code to ensure you handle the H-Bridge direction switching properly. Our engineers can be found directly on the forum, if you want additional support: Forums – Digilent Forum

Leave a Reply to Kyli Dokes Cancel reply

Your email address will not be published. Required fields are marked *