步进电机定位控制系统VHDL程序与仿真

[11-20 16:14:54]   来源:http://www.88dzw.com  FPGA   阅读:8608

文章摘要:步进电机定位控制系统VHDL程序与仿真library IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_arith.all;use IEEE.std_logic_unsigned.all;entity step_motor isport (reset:in STD_LOGIC; --系统复位信号 dir: in STD_LOGIC; --方向控制信号 clk: in STD_LOGIC; --系统时钟信号 ini: in STD_LOGIC; --初始化使能信号 manner: in STD_LOG

步进电机定位控制系统VHDL程序与仿真,标签:fpga是什么,fpga教程,http://www.88dzw.com

步进电机定位控制系统VHDL程序与仿真
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

entity step_motor is
port (reset:in STD_LOGIC; --系统复位信号
      dir: in STD_LOGIC; --方向控制信号
      clk: in STD_LOGIC; --系统时钟信号
      ini: in STD_LOGIC; --初始化使能信号
      manner: in STD_LOGIC_VECTOR (1 downto 0); --激磁方式的选择开关
      angle: in INTEGER range 255 downto 0; --步进角的倍数设定输入
      baBA: out STD_LOGIC_VECTOR (3 downto 0)); --步进电机状态输出
end step_motor;

architecture stepmotor_arch of step_motor is
signal count: INTEGER range 0 to 7; --计数器
signal cntInc: INTEGER range -2 to 2; --设定累加器所需的累(加/减)计数值
signal cc : integer range 0 to 3;
signal cntIni: INTEGER range -1 to 0; --设定累加器所需的计数初值
signal angleDnCount: INTEGER range 255 downto 0;  --计算已经转过的步进角
signal angleDnCntDec: INTEGER range 2 downto 1;
begin

  process(dir, manner, angle)--, ini)
  begin
      --if ini='1' then
      cc<=conv_integer(manner);
      if dir='0' then 
          case cc is
              when 1 => -- 1-相激励
                  --count<=0;
                  cntIni<=0;
                  cntInc<=2;
                  angleDnCntDec<=2;--"10";
              when 2 => -- 2-相激励
                  --count<=7;
                  cntIni<=-1;
                  cntInc<=2;
                  angleDnCntDec<=2;--"10";  
              when 3 => -- 1-2相激励
                  --count<=0;
                  cntIni<=0;
                  cntInc<=1;
                  angleDnCntDec<=1;--"01";   
              when 0 => --manner="00" autodetect            

[1] [2] [3] [4]  下一页


Tag:FPGAfpga是什么,fpga教程FPGA
分类导航
最新更新
热门排行