我正试图通过FPGA板移动机器人手臂。通信工作正常,但我想制作一个自动序列,我可以在飞行中修改。基本上我需要的是能够按顺序编码以下内容:
PA0 <= PA1; (for 2s)
PA2 <= PA5; (for 3,5s)
PA4 <= PA3; (for 3s)
PA2 <= PA1; (for 2s)
以数据向量的形式或在一个案例块中,只是为了保持简单,并能够添加/更改信号和传播这些信号的时间。
我用简单的计时器和if语句尝试了这个但是它远远不够完美,我无法在不将其转换为二进制并添加到现有时间计数器的情况下改变信号的传播时间。它看起来很乱。我根据时间的推移不能改变状态。
编辑:
正如我所说的那样,我要包含一些带声明的代码(LED仅用于测试)。
CODE:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
entity abra is
port
(
PA0 : out std_logic ;
PA2 : out std_logic;
PA4 : out std_logic;
PA6 : out std_logic;
PA1 : in std_logic;
PA3 : in std_logic;
PA5 : in std_logic;
PA7 : in std_logic;
LED: out std_logic_vector(7 downto 0);
RST: in std_logic; --ROT_CENTER--
CLK : in std_logic --50MHz clock--
);
end abra;
architecture Behavioral of abra is
signal TIME_COUNTER : std_logic_vector (31 downto 0) := (others => '0');
signal CNTR : std_logic_vector (7 downto 0) := (others => '0');
begin
control: process(CLK)
begin
if rising_edge(CLK) then
if(TIME_COUNTER = b"00000000101111101011110000100000") then
CNTR <= CNTR + 1; --should inc every 1s--
TIME_COUNTER <= (others => '0');
else
TIME_COUNTER <= TIME_COUNTER + 1;
end if;
if( RST = '1' ) then
CNTR <= (others => '0');
LED <= "11111111";
end if;
PA0 <= '0';
PA2 <= '0';
PA4 <= '0';
PA6 <= '0';
-----------------
if( CNTR >= "00000000" AND CNTR < "00000100") then
PA6 <= PA5; --servo 1 / side up--
LED <= b"00000001";
end if;
if( CNTR >= "00000100" AND CNTR < "00001011") then
PA4 <= PA3; --servo 3 / side down--
LED <= b"00000010";
end if;
if( CNTR >= "00001011" AND CNTR < "00110000") then
PA2 <= PA1; -- servo 6 / side down--
LED <= b"00000100";
end if;
if ( CNTR >= "00100000") then
LED <= b"00000000";
end if;
------------------
end if;
end process control;
end Behavioral;
UCF声明:
NET "PA0" LOC = "A13" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA2" LOC = "B13" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA4" LOC = "A14" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA6" LOC = "B15" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA1" LOC = "A15" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA3" LOC = "A16" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA5" LOC = "A17" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "PA7" LOC = "B17" | IOSTANDARD = LVCMOS33 | SLEW = FAST | DRIVE = 8 ;
NET "RST" LOC = "R13" | IOSTANDARD = LVCMOS33 | PULLDOWN ;
NET "CLK" LOC = "E12"| IOSTANDARD = LVCMOS33 ;
NET "LED<0>" LOC = "W21" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<1>" LOC = "Y22" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<2>" LOC = "V20" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<3>" LOC = "V19" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<4>" LOC = "U19" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<5>" LOC = "U20" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<6>" LOC = "T19" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;
NET "LED<7>" LOC = "R20" | IOSTANDARD = LVCMOS33 | SLEW = SLOW | Drive = 8 ;