FPGA活用回路&サンプル記述集(2) ―― モータやLEDを駆動するパワー回路
tag: 半導体 電子回路 ディジタル・デザイン
技術解説 2009年3月 9日
●○● Column ●○●
もう一つの制御プログラム
相田泰志
外部回路
- 回路図:なし
- 主要部品:ステッピング・モータ
- VHDL記述:リスト5-A
- 外部入力:CLK1,m_flg,t_flg,t_mode
- 外部出力:step_out
- 内部入力:なし
- 内部出力:なし
- パラメータ:なし
- Xilinx社,Spartan-3評価ボード,ISE WebPACK
永久磁石型ステッピング・モータの駆動に関するプログラムをもう1本紹介します(リスト5-A).記述による違いはありますが,設計の思想は同じです.
architecture Behavioral of test02_te is
signal t_mode : std_logic_vector(3 downto 0);
signal step_out : std_logic_vector(5 downto 0); -- HU HV HW LU LV LW
signal m_flg : std_logic;
begin
motor_m: process (CLK1)
begin
if(CLK1'event and CLK1 = '0')then -- CLK1↓
if(m_flg = '0') then
t_mode <= "0000";
else
if(t_mode < 6 ) then
t_mode <= t_mode + 1;
else
t_mode <= "0001";
end if ;
end if;
case t_mode is
when "0001" => step_out <= "100010"; --0deg
when "0010" => step_out <= "100001"; --30deg
when "0011" => step_out <= "010001"; --60deg
when "0100" => step_out <= "010100"; --90deg
when "0101" => step_out <= "001100"; --120deg
when "0110" => step_out <= "001010"; --150deg
when others => step_out <= "000000"; --off
end case;
end if;
end process motor_m;
end Behavioral;
リスト5-A ステッピング・モータの駆動パルスを生成するためのVHDL記述
signal t_mode : std_logic_vector(3 downto 0);
signal step_out : std_logic_vector(5 downto 0); -- HU HV HW LU LV LW
signal m_flg : std_logic;
begin
motor_m: process (CLK1)
begin
if(CLK1'event and CLK1 = '0')then -- CLK1↓
if(m_flg = '0') then
t_mode <= "0000";
else
if(t_mode < 6 ) then
t_mode <= t_mode + 1;
else
t_mode <= "0001";
end if ;
end if;
case t_mode is
when "0001" => step_out <= "100010"; --0deg
when "0010" => step_out <= "100001"; --30deg
when "0011" => step_out <= "010001"; --60deg
when "0100" => step_out <= "010100"; --90deg
when "0101" => step_out <= "001100"; --120deg
when "0110" => step_out <= "001010"; --150deg
when others => step_out <= "000000"; --off
end case;
end if;
end process motor_m;
end Behavioral;
tag: FPGA