AN 488: Stepper Motor Controller Using Altera MAX Series

ID 683592
Date 9/22/2014

1.2.1. Design Example: Targeting a MDN-B2 Demo Board (MAX II Devices)

You can implement this design with an EPM240 or any other MAX® II device.

The stepper motor works by supplying inputs through a user interface, which form the controller inputs to the MAX® II device. You can input mode, direction, and step control through user buttons and switches that are assigned to various general purpose I/Os (GPIOs) of the MAX® II device.

The following details the implementation of this design on the MDN-B2 demo board using this design source code. For illustrative purposes, this design is made using LEDs. Each LED represents a winding of the motor. The winding energizing sequence can thus be “seen” on the demo board. However, note that the LEDs glow on a logic 0 and are turned off when the port detects a logic 1. You can replace these LEDs by a motor driver circuit to run a motor. All the lines are parallel and independent of each other. Each line excites one separate coil winding of the motor and causes the rotor to rotate in a specific direction and manner as set by the user control.

Table 2.  EPM240 Pin Assignments for MDN-B2 Demo BoardUnused pins are assigned as input tri-stated in the Device and Pin option settings in the Quartus® II software prior to compilation.
Signal Pin
dir pin 38
mode pin 37
move pin 82
rst pin 77
phaseout[0] pin 71
phaseout[1] pin 72
phaseout[2] pin 73
phaseout[3] pin 74

To demonstrate this design on the MDN-B2 demo board, follow these steps:

  1. Select the EPM240GT100C3 device, compile the source code, and assign the pins (as shown in the pin assignments table).
  2. Switch on power to the board using slide switch SW1. Download the design to the MAX® II device using the JTAG header JP5 on the MDN-B2 demo board and a conventional programming cable (ByteBlaster™ II, USB-Blaster™).
  3. Press switch SW4 on the demo board to begin the download process. Remove the JTAG connector and switch off power after programming the MAX® II device.
  4. Switch on power to the demo board by sliding slide switch SW1 to ON.
    This version of stepper motor control displays the phase excitation on the LEDs on the demo board. The four phaseout outputs are connected to red LEDs (D5, D6, D8, and D10) on the demo board.
  5. Select the mode and direction using the following switches of the DIP switch SW3 (Control Switch):
    • Switch #1—assigned to set the mode to either continuous mode or step mode.
    • Switch #2—assigned to set the direction.
  6. Use push button SW9 for the “move” function.
    Note the LEDs progress in the excitation sequence that was set in step 5 as you push this button.
    • When the mode is set to step mode and SW9 is pressed, the LEDs progress one step for each push.
    • When the mode is set to continuous mode and SW9 is pressed, the LEDs appear to be moving one step after another without any user intervention.
    The direction switch changes the direction of this sequence. Push button SW6 on the board is used to reset the demo board.