Tài khoản E-mail miễn phí @ngohaibac.net

Các bạn hãy dành chút thời gian đọc kĩ hướng dẫn sử dụng trước khi dùng.

VHDL Tutorial: Stepper Motor Controller

By admin
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Chào các bạn.

Trong bài này mình xin giới thiệu các bạn một component để điểu khiển động cơ bước đơn cực.

Mình gửi các bạn báo cáo mà mình đã viết có chi tiết  về cách mô phỏng và mã của chương trình và thực hiện trên kit Spartan 3E.

1. Giao diện vào ra

Bộ điều khiển có đầu vào là:

  • Clk: Xung clock sẽ quyết định tốc độ động cơ.
  • Rst: Tín hiệu reset lại trạng thái ban đầu.
  • En : Tín hiệu xác định động cơ ở chế độ quay hay ở chế độ giữ.
  • Dir:  Điều khiển chiều quay của động cơ

Đầu ra là 4 bit đến điều khiển mạch lực.

entity Stepper_Motor_Controller is
    Port ( clk : in  STD_LOGIC;	   -- input to determine spped of rotation
           rst : in  STD_LOGIC;    -- resets and initializes the circuit
           en  : in  STD_LOGIC;    -- determine whether motor rotating or holding
           dir : in  STD_LOGIC;    -- motor direction control 
 
           ph  : out STD_LOGIC_VECTOR(4 downto 1) -- output to phase 1 to 4 motor			  
	 );
end Stepper_Motor_Controller;

2. Thực thi thuật toán

Mình thực hiện thuật toán để đưa ra 4 xung điều khiển động cơ rất là đơn giản. Các bạn thử nghĩ xem mình làm thế nào nhé.

architecture Behavioral of Stepper_Motor_Controller is
	signal   step_pattern : std_logic_vector(7 downto 0):= "11100000"; --initial value puts one LED on near the middle.
 
begin
	process(clk,rst) begin
		if rst = '1' then
			step_pattern <= "11100000";
 
		else
			if clk'event and clk = '1' then 
			-- If clk event occours then shift
				if en = '1' then 
					if dir = '1' then
						step_pattern <= step_pattern(6 downto 0) &amp; step_pattern(7);
					else
						step_pattern <= step_pattern(0) &amp; step_pattern(7 downto 1) ;
					end if;
				end if;
			end if;
		end if;
	end process;
 
	-- Update values to the phases
	ph(1) <= step_pattern(0);
	ph(2) <= step_pattern(6);
	ph(3) <= step_pattern(4);
	ph(4) <= step_pattern(2);			
 
end Behavioral;

REP02.02.FPGA.NOHB.281107.pdf

Các bài viết liên quan:


Leave a reply

:mrgreen: :| :twisted: :arrow: 8O :) :? 8) :evil: :D :idea: :oops: :P :roll: ;) :cry: :o :lol: :x :( :!: :?: