Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

control stepper using de0 nano

hii....

how to control a stepper motor that can move 50 degrees?

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I guess you need to calculate, how many pulses you need to send to your motor to move these 50 degree and send them with suitable (low enough) frequency.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    1.8 degrees in one step<><>

    this my program.,. but still looping. how to stop it in order to move 30 degrees only

    library IEEE;

    use ieee.std_logic_1164.all;

    entity stepper is

    port ( CLK : in std_logic;

    tombol_arah : in std_logic;

    STEP_D : out std_logic_vector (3 downto 0)

    );

    end stepper;

    Architecture behavioral of stepper is

    signal cnt : integer range 0 to 3;

    signal cnt_1 : integer range 0 to 3;

    begin

    process (CLK) is

    begin

    if (CLK'event and CLK = '1') then

    case cnt is

    when 0=>

    STEP_D <= "1001";

    when 1=>

    STEP_D <= "0001";

    when 2=>

    STEP_D <= "0011";

    when 3=>

    STEP_D <= "0010";

    end case;

    end if;

    end process;

    process (CLK)

    begin

    if(CLK' event and CLK = '1') then

    if cnt = 3 then

    cnt <= 0;

    else

    cnt <= cnt+1;

    end if;

    end if;

    end process;

    end behavioral;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    1.8 degrees in one step<><>

    this my program.,. but still looping. how to stop it in order to move 30 degrees only

    library IEEE;

    use ieee.std_logic_1164.all;

    entity steper is

    port ( CLK : in std_logic;

    tombol_arah : in std_logic;

    STEP_D : out std_logic_vector (3 downto 0)

    );

    end steper;

    Architecture behavioral of steper is

    signal cnt : integer range 0 to 3;

    signal cnt_1 : integer range 0 to 3;

    begin

    process (CLK) is

    begin

    if (CLK'event and CLK = '1') then

    case cnt is

    when 0=>

    STEP_D <= "1001";

    when 1=>

    STEP_D <= "0001";

    when 2=>

    STEP_D <= "0011";

    when 3=>

    STEP_D <= "0010";

    end case;

    end if;

    end process;

    process (CLK)

    begin

    if(CLK' event and CLK = '1') then

    if cnt = 3 then

    cnt <= 0;

    else

    cnt <= cnt+1;

    end if;

    end if;

    end process;

    end behavioral;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Add another counter, that counts 30 or 50 degrees and when it reaches the certain value it stops rotation. Use enable signal in first process and add a wider counter to the second process.