Controlling a Stepper Motor with an FPGA

6

For those of you that have been following my last few posts on state machines, you know that I’ve been working on Pmod interfaces for FPGA as part of making the claw game. The first one I delved into was using the PmodSTEP and Basys 3 to control a stepper motor.

Here is a video of it working:

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.

Along  with writing the FPGA driver for the stepper motor I also created an Instructable so you can replicate the functionality in the video.

In the Instructable, I cover what you need.

The first step covers what you need. This includes the Basys3, PmodSTEP, stepper motor, and micro USB cable.

The first step covers what you need. This includes the Basys3, PmodSTEP, stepper motor, and micro USB cable.

Background info on stepper motors is also available.

Here I link to a video on stepper motors and describe stepper motors at the most basic level.

Here I link to a video on stepper motors and describe stepper motors at the most basic level.

But what’s the theory behind the code?

In this step I describe my state diagram and the idea behind how I coded this.

In this step I describe my state diagram and the idea behind how I coded this.

I talk about how to download, open, and program the project to the Basys3.

In a few steps I describe how to program the board.

In a few steps I describe how to program the board using Xilinx Vivado.

And lastly how to tie everything together.

The last step is to plug all of the pieces together.

The last step is to plug all of the pieces together.

To view the full Instructable, click here.

Share on FacebookTweet about this on TwitterShare on Google+Pin on PinterestShare on RedditShare on TumblrShare on LinkedInShare on StumbleUponEmail this to someone
Share.

About Author

When I started school I wasn’t interested in any of things I’m passionate about now. In fact originally I started out wanting to study art. But then I decided I didn’t want to have people telling me what to create, so I changed to music. Then I decided I didn’t want to ruin a hobby by making it my career. At the same time my Physics class was teaching a unit on the physics of music, and I thought that was way interesting, so I changed to physics. Then by the time physics was over I decided that the coolest part of physics was electricity and magnetism, and I may as well get a degree that transfers directly into a career. So while all this was happening, I was attending Shoreline Community College, and during that time I found my passion, or rather presented itself repeatedly, until I realized, maybe I should take a hint from the universe. While at community college, I was asked to help at the high school by tutoring chemistry students. Then I was asked to help at the elementary school by being a math Olympiad coach. I continued both because I found I really enjoyed it. I also had an opportunity, and was hired to be a tutor in the Math Learning Center at the Community College, a job I really loved. At the same time I was working as a Nanny, which I had been doing for several years, the main reason because I could and would answer the hard questions the kids asked honestly (i.e. why is the sky blue). I then was recommended by the patrons of the MLC to the transfer tutoring center (private tutoring,) and developed a wait list of students. Through all these opportunities at some point I realized that I loved watching people go from totally lost, to masters of a subject. I was also forced to admit that having all these opportunities continually renewed, I must have been somewhat good at it. So I decided I wanted to teach, which fits with my mission oriented personality. I saw a serious lack of passionate ECE professors in the institutions I attended. At WSU I continued this trend by being ask to TA for computer science and electrical engineering, being a TA for a total of 4 semesters. This continued by getting an amazing opportunity in my first semester at Washington State University to work at Digilent, an educational company. So even if I didn’t want to teach, turns out I can’t avoid it. Luckily it is my main passion.

6 Comments

  1. Miranda Hansen on

    Cool project! I was just wondering, what is the difference between a stepper and brushless motor? Are there more than just those two types of motors?

  2. Mirek Szymczyk on

    There are also AC motors. The AC motors can be divided into two main types:
    – synchronous motors
    – asynchronous (induction) motors.
    AC motors are not as easy to speed control as DC motors. Motor speed can be controlled by varying the voltage and frequency of the applied waveform (V/f control) or by wrapping a speed loop around a torque loop incorporating Field Oriented Control (FOC).

  3. I like the state machine diagram, it explains what the FPGA should do. A signal diagram showing how the coils need to be driven would make it even more understandable. And some more words about how the the actual FPGA code works would also be nice (in the code I find, apart from all the temporary files, just three Verilog modules, but do not see how they are wired together…)

    • Hi Hendrik,
      If you open the project in Vivado you will see that the top module is pmod_step_interface.v. Within that file the other two files are instantiated and the connections are shown.

      If you open those three .v files in a text editor I describe exactly the connections and where they go in comments. Comments are the text after the “//”. I did this in the code because it’s hard to explain without having the code right there.

      Give that a read and let me know what you think.

      Kaitlyn

Leave A Reply