Theory:Stepper motors are designed as an open loop system. A pulse generator sends out pulses to the phase sequencing circuit
Diagram:
Verilog code:
module Stepper (input clk, input din, output angle);
wire clk_1;
reg [26:0] clk_div;
always @(posedge clk)
begin
clk_div <= clk_div + 1;
end
assign clk_1 = clk_div[18];
always @(posedge clk)
begin
if (din == 1)
begin
angle <= {1'b0, 1'b1, 1'b0, 1'b1};
end
else
begin
angle <= {1'b1, 1'b0, 1'b1, 1'b0};
end
end
endmodule
PIn assignment:
NET "phase_a" LOC = "L15";
NET "phase_b" LOC = "K12";
NET "phase_c" LOC = "L17";
NET "phase_d" LOC = "M15";
NET "position<0>" LOC = "J14";
NET "position<1>" LOC = "J15";
NET "position<2>" LOC = "K15";
NET "position<3>" LOC = "K14";
NET "position<4>" LOC = "E17";
NET "position<5>" LOC = "P15";
NET "position<6>" LOC = "F4";
NET "position<7>" LOC = "R4".
RTL schematic view:
Output:
Device utilization: