📄 add_qf.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity add_qf is
port( qk:in std_logic_vector(7 downto 0);-----前馈量
fk:in std_logic_vector(7 downto 0);-----反馈量
clk: in std_logic; -------时钟信号
ctrl_out: out std_logic_vector(7 downto 0)); ----总的控制输出量
end entity;
architecture one of add_qf is
signal ee:std_logic_vector(8 downto 0);
signal qk1,fk1:std_logic_vector(8 downto 0);
begin
qk1<='0'& qk;
fk1<='0'& fk;
process(clk,ee)
begin
if clk'event and clk='1' then
if fk1<="001111111" then -------电机反转时
if fk1>qk1 then ------------如果反馈值大于前馈值
ee<=fk1-qk1; ------------根据前馈算法,用反馈量减去前馈量,使电机加速
else ee<="000000000"; --------如果前馈量大于反馈量,则电机全速反转
end if;
else ee<=fk1+qk1; ------电机正转时,根据前馈算法,用反馈量加前馈量,--使电机加速
end if;
if ee>"011111111" then ---如果正转控制量溢出(超过FF)
ee<="011111111"; -----则电机全速正转
end if;
end if;
ctrl_out<=ee(7 downto 0);---将控制量送出
end process;
end one;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -