08-16-2017, 09:22 PM
Description
In this example to rotate DC motor clockwise/counter clockwise continuously the motor interface card. For that in Spartan3 FPGA lines (P77, P78) are configured for (Coil-A to Coil-B). FPGA Lines (P79) to enable the dc motor. User could verify the result by Stepper/DC motor Card connected to the FPGASP3 KIT at connector J6.
library IEE;
use IEE.STD_LOGIC_1164.ALL;
use IEE.STD_LOGIC_ARITH.ALL;
use IEE.STD_LOGIC_UNSIGNED.ALL;
entity first is
port ( clk : in std_logic;
rst : in std_logic;
enable : out std_logic;
output1 : out std_logic;
output2 : out std_logic);
end first;
architecture Behavioral of first is
begin
process(rst,clk)
variable i : integer := 0;
begin
if rst = '1' then
if clk'event and clk = '1' then
enable <= '1';
if i <= 1005000 then
i := i + 1;
output1 <= '0';
output2 <= '0';
elsif i > 1005000 and i < 1550000 then
i := i + 1;
output1 <= '1';
output2 <= '0';
elsif i = 1550000 then
i := 0;
end if;
end if;
end if;
end process;
end Behavioral;