Modify VHDL code of the stepper motor on page 603 of your te
Solution
a) VHDL code for Stepper Mottor
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following lines to use the declarations that are
-- provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;
entity stepper is
Port ( clk,dir : in std_logic;
Q : out std_logic_vector(3 downto 0));
end stepper;
architecture Behavioral of stepper is
TYPE state_type is (three,six,nine,twelve);
SIGNAL state:state_type;
begin
stepper: process(clk,dir) is
begin
if rising_edge (clk) then
if dir =\'1\' then
CASE state IS
when nine =>
state <= twelve;
Q <=\"1001\";
when twelve =>
state <= six;
Q <=\"1100\";
when six =>
state <= three;
Q <=\"0110\";
when three =>
state <= nine;
Q <=\"0011\";
end CASE;
else
CASE state IS
when three =>
state <= six;
Q <=\"0011\";
when six =>
state <= twelve;
Q <=\"0110\";
when twelve =>
state <= nine;
Q <=\"1100\";
when nine=>
state <= three;
Q <=\"1001\";
end CASE;
end if ;
end if;
end process stepper;
end Behavioral;
b) the steps at which Stepper motor rotates is 3,6,9,12 because it is running at full step sequence
in the full step sequence two coils are energized at the same time and moter shaft rotates.the order in which they rorate is given below.
step 1: 1001
step2: 1100
step3: 0110
step4: 0011
the above order is for direction forward(dir=1).

