?? 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 + -