Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] VHDL counter sensor question

Status
Not open for further replies.

enterkill

Newbie level 3
Joined
Feb 8, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Hi, i have a vhdl code here, I'm still missing of a certain part. How do i equate this into the code: When Q hits P, LED lights up and Q stops counting.

code:

library ieee;
use ieee.std._logic_1164.all;
use ieee.numeric_std.all;

entity conveyor is
port ( sensor, reset : in std_logic;
p : in std_logic_vector (4 downto 0);
q : out_std_logic_vector (4 downto 0);
Led_on : out std_logic);
end conveyor


architecture flow of conveyor is

signal count_sig: unsigned (4 downto 0);

begin
process (sensor, reset, Led_on)
begin
if (reset = '0') then
count_sig <= "00000";
Led_on <= "1";

elsif falling_edge (sensor) then
count_sig <= count_sig + 1;


end if;
end process;

q <= std_logic_vector (count_sig);

end flow;
 

Try this. Fixed a few other issues, typos and removed Led_on from sensitivity list. I syntax checked it but didn't simulate it. Note, Led_on signal is active low.

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity conveyor is
port ( sensor, reset : in std_logic;
p : in std_logic_vector(4 downto 0);
q : out std_logic_vector(4 downto 0);
Led_on : out std_logic);
end conveyor;


architecture flow of conveyor is

signal count_sig: unsigned(4 downto 0);

begin
process (sensor, reset)
begin
if (reset = '0') then
count_sig <= "00000";
Led_on <= '1';
elsif falling_edge(sensor) then
if count_sig /= unsigned(p) then
count_sig <= count_sig + 1;
else
Led_on <= '0';
end if;
end if;
end process;

q <= std_logic_vector(count_sig);

end flow;


Ray
 
A sensor is used to detect the number of bottles on the conveyor. The user can set any number of bottles he wants to detect on inputs: P4P3P2P1P0. Design a system such that when the reference number is reached, a Led turns on and the count stops at the reference number. Show the number of bottles detected on 5 Leds and the value of the reference on another 5 Leds. After the active-High reset is activated, the counting starts again, the counter returns to 0 and the led is off.


Here's the question. The code you gave, can't count up.
 

its okay. I found my mistake. reset is supposed to be at 1.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top