-- file "rotater.vhd" ----------------------------------------------------------------------- -- counts a specified number of clock pulses from a trigger -- used to control the stepper motor rotation -- written by Shaun Luong, Clifton Yeung, Jon Paul Kansky -- and Patrick Asiedu-Ampem, University of Alberta -- November 1998 ----------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity rotater is generic(pulse_num: positive:= 10); -- change this for -- different # clock pulses port ( clock, reset: in std_logic; start: in std_logic; rot_enable: out std_logic; stop: out std_logic ); end rotater; architecture counting of rotater is begin process(reset, clock) variable stepper: integer; -- intermediate count variable count: boolean; begin if reset = '1' then -- active low count := false; stepper := 0; rot_enable <= '0'; stop <= '0'; elsif rising_edge(clock) then if start = '1' then count := true; else count := false; end if; if count = true then if stepper < pulse_num then rot_enable <= '1'; -- enable motor rotation stepper := stepper + 1; -- increment count elsif stepper >= pulse_num then rot_enable <= '0'; -- disable motor rotation stop <= '1'; -- done counting end if; end if; end if; end process; end counting;