saUNT
Newbie level 3
hello
please help mw to add a counter that will stop at 10 and here is the exaxt words from the proffesor
" The dispense state turn the dispense signal on to activate a stepper motor that issimulated on the red LEDR lights.Again, state machines are used for this part. Make sure to add a counter to count a number of steps (i.e. 10) before it stops. Otherwise, your vending machine will have a flaw dispensing soda to the whole population of UNT for 35 cents. A real stepper motor is connected to the board through the global IO pin (GPIO "
and here is the code:
please help mw to add a counter that will stop at 10 and here is the exaxt words from the proffesor
" The dispense state turn the dispense signal on to activate a stepper motor that issimulated on the red LEDR lights.Again, state machines are used for this part. Make sure to add a counter to count a number of steps (i.e. 10) before it stops. Otherwise, your vending machine will have a flaw dispensing soda to the whole population of UNT for 35 cents. A real stepper motor is connected to the board through the global IO pin (GPIO "
and here is the code:
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity stepper is Port ( dispense,reset,clk : in std_logic; Q : out std_logic_vector(3 downto 0)); end stepper; architecture Behavioral of stepper is type states is (three,six,twelve,nine); signal current_state,next_state: states; signal count: integer:=0; begin P1:process(reset,clk) begin if reset='0' then current_state<=three; elsif rising_edge(clk) then current_state<=next_state; end if; end process; p2:process(current_state, dispense) begin if dispense='1' then --check for dispense active case current_state is when three => Q<="0011"; next_state<=six; when six => Q<="0110"; next_state<=twelve; when twelve => Q<="1100"; next_state<=nine; when nine => Q<="1001"; next_state<=three; when others => Q<="0011"; next_state<=three; end case; end if; end process; --GPIO(3 downto 0)<=Q; --send output to the stepper motor hardware end Behavioral;
Last edited by a moderator: