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.

Need help with VHDL-project

Status
Not open for further replies.

peter92

Newbie level 3
Newbie level 3
Joined
Dec 3, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,307
Hi

Not sure if I'm posting this the right place, but here goes:

I'm working on a vending machine project. The VHDL code for the entity is in this pastie:

http://pastie.org/5475527

I need some help with getting the system to do what I want. As it is now, when one of the coin-buttons are pressed, the sum-so-far will keep on incrementing every clock cycle for as long as the button is pressed.

I would like for the system to increment the sum only once every time a button is pressed.

So far, I have tried different solutions myself, but none seem to work.
 

Two things:

1) Debounce the switch, if you're not already doing that

2) Use a state-machine. When it sees the button pressed, it goes to state S1 where your count is incremented, it then goes to state S2. It remains in S2 until it sees the button UN-pressed. Then go to your idle state.
 
Thanks for the advice barry.

The buttons have already been debounced and synchronized.

I will try out the state machine and get back to you. Would you mind perhaps giving an example of how to do it?
 

something like:

Code:
case state is
	when idle =>
		if button='1' then
			state<=S1;
		end if;
	when S1 =>
		count=count+1;
		state <= s2;
	when s2 =>
		if button='0' then
			state<=idle;
		end if;	
end case;
 
I have worked a little on my project in accordance with your advice. The buttons are responding well now, but there is still a little problem.
Once the sum-so-far becomes greater than the price, the price is automatically deducted from the sum, which is not the intention. This should only happen when the user presses the "buy"-button.
The help has been great so far, can you help me with the last part?
The revised VHDL code of the entity is in this pastie:

http://pastie.org/5476200

- - - Updated - - -

I have just solved it myself. If anyone is interested, this is the pastie:
http://pastie.org/5476250
Thanks for the help, you saved my day and my grade!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top