# Two problems with my project (handheld console)

Discussion in 'The Projects Forum' started by taz, Jun 20, 2007.

1. ### taz Thread Starter New Member

Jun 20, 2007
4
0
Hi this is my first thread and I'd like to ask for advice on my project, I would be very greatfull for any help or if anyone could point me to a good website.
I'll try to explain the problems as well as I can.

My problems:
I would like to build a small handheld console with one built-in game. The game consists of led's moving in sequence, and I'm using shift registers to do that.
'But the part I'm stuck on is That I need one of four led's to come on at random', now I've tried making a randomizer, but because it has two clocks as inputs, this just makes a sequence that is the same everytime instead of being random, so how can I make a randomizer or something similar with clock inputs and have it actually give a random output?
My other problem is that I need an led in a row of four to move left or right at the command of two buttons, so that everytime I press left the led will move left once and stay there untill I press another button? (left or right)

I will be very greatfull for any examples or tips on either of these.
THANKS

2. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
Two clocks has nothing whatever to do with randomness. Where did you get this quaint idea? Unless you're willing to build a beta decay detector, the best you can do is the pseudo random sequence of a linear feedback shift register (LFSR). The sequence does repeat but it can be very very long.

To do the movement you want a "universal" shift register that can move left or right or hold. The clock goes into the shift register continuously. The buttons determine the state of the inputs that select "left", "right", and "hold".

3. ### beenthere Retired Moderator

Apr 20, 2004
15,815
283
The problem with trying to have random initial conditions in a system using logic is difficult. To function predictably, the system has to be in a known state at first. This is ususlly done through generating a reset signal that deliberately forces the system into a predefined state - all zeroes or all ones.

Even computers can only generate what is called pseudorandom numbers. The process is the topic of some complexity. Trying to achieve this with a few logic chips would be quite difficult. Assuming the initial count in the shift registers is to be the random part, then there has to be some way to let the count run for some random interval.

Things that could control the random count could be influenced by external conditions, like the level of light times some changing count. Or just grabbing a count with a keypress, possibly requiring a third clock.

You might find that a microprocessor is the best way to achieve your random startup counts.

4. ### taz Thread Starter New Member

Jun 20, 2007
4
0
Thanks to both of you for your help, I knew that a random generator with two pulse inputs would be very hard and if not inpossible to make. I'm still in the planning stages of my project, so this is great because I can do a bit of research into a (pseudo random sequence of a linear feedback shift register)
and ("universal" shift registers ), these sound good, and should be exacly what I'm looking for.
I will begin my research on these now and I would be very greatfull for any links to good websites with examples. Also, if anyone could tell me a little more about these I will be very geatfull. Ive done quite a bit on shift registers allready so I should be ok with that, its the (LFSR) I know I'll have problems with so a bit of info on this would be great.
THANKS again, and you're right it was a quaint idea.

5. ### hgmjr Moderator

Jan 28, 2005
9,030
214
You can read up on LFSR technique on the Wikipedia Website.

hgmjr

6. ### Salgat Active Member

Dec 23, 2006
215
1
A switch with no debouncer circuit can also result in a random value *chuckles*.

7. ### beenthere Retired Moderator

Apr 20, 2004
15,815
283
If you put the PB into a 7490, it will count nanosecond glitches. They are just amazing about catching any old pulse.

I suppose a CMOS input just tied to a length if wire would count somewhat at random. But there would be a problem with induced voltages blowing the input circuitry.

8. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
I think I'm too big to fit in a 7490. Just how were you planning to get me into one anyway?

9. ### beenthere Retired Moderator

Apr 20, 2004
15,815
283
Honey, I shrank the poster!

10. ### taz Thread Starter New Member

Jun 20, 2007
4
0
Thanks, the link was great, I can't believe I didn't look on wikipedia in the first place.
Anyway I've built a (lfsr) and it works well, the output signal is long enough not to be noticed by the player.
The only thing that does not work is the universal shift register which I thought would be ok, I made one using crocodile physics and it doesn't quite do what I want it to. It moves both ways but I cant get it to stop, I've used shift registers before but I have never needed to stop the signal while its being carried. I'll try and show you a picture of the circuit so that one of you can show me a way of stopping the led being carried (although that is the purpose of a shift register!)
I can't show you it now because I'll be away on the weekend, but in the meantime I would be greatfull for any advice on the matter.
Thanks

11. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
I don't know what crocodile physics means. Actually I shudder to think of the possibilities. The part I had in mind was a 74xx194. It has two inputs which determine the function and one of the four combinations is "hold" or "do nothing". I don't know how much simpler it could get.

EDIT: Is Crocodile Physics the simulation package?

12. ### hgmjr Moderator

Jan 28, 2005
9,030
214
Crocodile Physics is some sort of simulation package. I had to google it to determine the heck it was.

hgmjr

13. ### Papabravo Expert

Feb 24, 2006
10,340
1,850
It's pretty pricey if I do say so myself

14. ### ashokcp Active Member

Mar 8, 2007
50
2
I needed to read it the second time to realise what Pb meant in beenthere's. The reply to this was good humor fm Papabravo, and, even more in beenthere's. I enjoy this.

15. ### taz Thread Starter New Member

Jun 20, 2007
4
0
Yes crocodile physics is a simulation program for electronics and physics, anyway Ill show you the circuit that I made using it (its a .doc file) so Ill make an attachment.
It will look like this, but instead of the three outputs it will have four. I know this is wrong but I cant see the problem. If you could tell me how to stop the led from being carried and for it to move left or right at the command of two switches I will be very grateful.
And another thing: What simulation program do you use? I thought that crocodile physics was more widely used.
View attachment universal.doc