entity seguidor is
port(
clk, sensorIzq, sensorDer, sensorDisp : in std_logic;
llantaIzq, llantaDer, disp: out std_logic);
end;
architecture comportamiento of seguidor is
begin
movimiento: process (sensorIzq, sensorDer, sensorDisp,clk)
begin
if(sensorIzq='1' and sensorDer='0' and sensorDisp = '0') then
llantaIzq<='1';
llantaDer<='0';
elsif(sensorIzq='0' and sensorDer='1'and sensorDisp = '0') then
llantaIzq<='0';
llantaDer<='1';
elsif(sensorIzq = '1' and sensorDer = '1' and sensorDisp = '0') then
llantaIzq <= '1';
llantaDer <= '1';
elsif(sensorIzq = '1' and sensorDer = '1' and sensorDisp = '1') then
llantaIzq <= '0';
llantaDer <= '0';
end if;
end process movimiento;
end comportamiento;
So, the code is for a line follower, if it reads a '1' from one of the sensors it should pass a '1' (i.e 5v.) to one of its wheels. After reading a '1' from "sensorDisp", the car should stop for a little while, giving "disp" a value of '1' in this while. After that, it should continue on its merry way. I'm having a hard time trying to achieve this delay. Thanks for the help!
I have done similar thing on Atlys. Have clk counters.Know the frequency of the clock in .ucf file ( mapping file ). Have a boolean for waiting state, isWait .When sensorDisp is 1 then isWait = true I have mentioned pseudo code below.
You can create a separate process for this with input clk and sensordisp. And remember if any variable/signal isn't assigned any value in any run of the code, if will infer a latch as it needs the previous value as it isn't assigned.
movimiento: process (clk,sensorIzq, sensorDer, sensorDisp,clk)
begin
if(clk edge ) then
if (isWait) then
if(wait_counter < "frequency")) then
wait_couter++;
else
isWait = False;
Disp = '0';
end if;
else
if(sensorDisp = '1') then
wait_counter = 0;
isWait = True;
Disp <= '1';
end if;
if(sensorIzq='1' and sensorDer='0' and sensorDisp = '0') then
llantaIzq<='1';
llantaDer<='0';
elsif(sensorIzq='0' and sensorDer='1'and sensorDisp = '0') then
llantaIzq<='0';
llantaDer<='1';
elsif(sensorIzq = '1' and sensorDer = '1' and sensorDisp = '0') then
llantaIzq <= '1';
llantaDer <= '1';
elsif(sensorIzq = '1' and sensorDer = '1' and sensorDisp = '1') then
llantaIzq <= '0';
llantaDer <= '0';
end if;
end if;
end if;
end process movimiento;
end comportamiento;