⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fankui1.vhd

📁 在quartus开发环境下
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity fankui1 is
 port(finput:in std_logic_vector(11 downto 0);      --指令信号
    qinput:in std_logic_vector(11 downto 0);      --反馈信号
      clk:in std_logic;                             --时钟信号
      cerror:out std_logic_vector(7 downto 0));     --反馈控制输出量
end;

architecture one of fankui1 is
   signal reg1:std_logic_vector(11 downto 0);        --自定义信号量
   signal reg2:std_logic_vector(11 downto 0);        --自定义信号量
 begin
 jisuan:process(clk)
    begin

--此进程对AD1674输出信号进行处理
 --因为AD1674采用双极性输入,即[-10V, 10V]
 --输入输出对应关系为[-10V -- 0V -- 10V]         [00H - 80H -- FFH]
 --如果反馈量大于指令量0.625V
-- 128(01111111)*20/4096(111111111111)=0.625 V
 --则运行比例运算,
--否则,采用模糊思想,进行归类,使电机实现全速转动
--[00H - 80H -- FFH] ---- [正全速 - 停转 - 负全速]

     if clk'event and clk='1' then           
        if finput>qinput then               --如果反馈量大于指令
           reg1<=finput-qinput;             --进行减法运算,反馈值减指令值
            if reg1>="01111111" then
               cerror<="00000000";          --如果溢出则进行归类
            else cerror<="01111111"-reg1(7 downto 0);  --进行偏移运算
            end if;
        else reg2<=qinput-finput;             --如果反馈量小于指令,为保持正值,--指令值减反馈值
            if reg2>="01111111" then
               cerror<="11111111";           --如果溢出则进行归类
            else cerror<="01111111"+reg2(7 downto 0); --进行偏移运算
            end if;
       end if;
     end if;
  end process;
 end one;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -