Stepper Motor Controller in High-Level Synthesis

by mohammad6 in Circuits > Electronics

641 Views, 0 Favorites, 0 Comments

Stepper Motor Controller in High-Level Synthesis

logo.png

The goal of this mini-project is to drive a 4-phase bipolar stepper motor using high-level synthesis for FPGA. To achieve this goal, here I am going to control the 17HS4401S stepper motor, which is connected to the Basys3 board via a Pmod-Step (Stepper Motor Driver). Two IPs described in HLS are used to rotate the stepper motor. If you are interested in designing with HLS, please refer to here.

Introduction

figure-01.png

A Stepper motor is usually used to make electronically controlled precise movements. It has several applications, especially in DVD players, printers, CNC machines, and robotic arms, to name a few. Like other types of motors, the stepper motor consists of two main parts: stator and rotor. The stator consists of individual sets of coils. In contrast to other types of motors, the rotor in a stepper motor rotates in discrete steps. After each step, the rotor holds itself in position. These discrete steps are controlled by a proper sequence of pulses on the stator coils. In other words, a stepper motor converts electrical pulses into discrete mechanical movements.

The number of coils will differ based on the type of stepper motor, but for now, it is enough to understand that in a stepper motor, the rotor consists of metal poles, and each pole will be attracted by a set of coils in the stator.
When a coil gets energised, it acts as a magnet, and the rotor pole gets aligned to it. When the rotor rotates to adjust itself to align with the stator, it is called “one step”. There are mainly three types of stepper motors based on their rotor construction: Variable reluctance stepper motor: They have an iron core rotor Permanent magnet stepper motor: They have a permanent magnet rotor Hybrid synchronous stepper motor: They are a combination of Variable reluctance and permanent magnet stepper motors

Driving Methods

figure-02.png

We can also classify the stepper motors as Unipolar and Bipolar based on the type of stator coil wiring.

The above figure shows the coil configuration of a 4-wire bipolar stepper motor.

There are four different drive methods for stepper motors:

  • One-phase-on stepping or Wave Stepping (Full Step)
  • 2-phase-on (Full Step)
  • 1&2-phase-on (Half Step)Microstep

The simplest case is the one-phase-on.

Concept

figure-03.png
figure-04.png

To understand the driving signals that an HLS function should generate, let us simplify the motor structure shown in the above figure. Here, each motor step is 90°, representing 1.8° of the rotor rotations in our actual motor.

To rotate the rotor, we should energise the coils one after another, as shown in the following figure.
When we energise the A phase, it attracts the rotor. We turn off A and turn on B, the rotor rotates 90° (1.8°) and so on. Each time only one phase is energised.

HLS Codes

If we assume A–>black, B–>blue, C–>green and D–>red, then the HLS function bipolar_stepper_motor.cpp can generate the proper signals to rotate the motor continuously. Here, the motor_clk_rate input argument is a 100Hz clock frequency.

The testbench in bipolar_stepper_motor-tb.cpp file can be used to test the stepper motor driver design.

Waveform

figure-07.png

After running the RTL/C co-simulation in Vitis-HLS, the above waveform illustrates the design timing digram.

Vivado Project

figure-06.png

The design in Vivado consists of two IPs generated by Vitis-HLS. The first IP generates a 100Hz single-cycle clock pulses and the second IP generates the stepper motor signals.

Constraints

The stepper motor is connected to the Pmod JC connector on the Basys3 board via Pmod-Step. Therefore, the following constraints define the design port connected to the JC interface.

##Sch name = JC7
set_property PACKAGE_PIN L17 [get_ports {motor_signal[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {motor_signal[0]}]
#Sch name = JC8
set_property PACKAGE_PIN M19 [get_ports {motor_signal[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {motor_signal[1]}]
#Sch name = JC9
set_property PACKAGE_PIN P17 [get_ports {motor_signal[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {motor_signal[2]}]
#Sch name = JC10
set_property PACKAGE_PIN R18 [get_ports {motor_signal[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {motor_signal[3]}]<br>

Demo

bipolar stepper motor

Finally, this is a simple demo. If you are interested in designing with HLS, please refer to here.