Digital Logic Design Project game

Discussion in 'Homework Help' started by ankur3000, Dec 29, 2010.

  1. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    Hey guys, this is my first post on this website, so please excuse any mistakes.

    Ok, now here is the problem:
    I have to make a final project for my DLD course at college, and most students in this course end up making a clock (kind of a tradition for some reason), but I want to do something a little more challenging and different. Having looked around for quite some time about project ideas, I think i have found something, (see attached video link):

    http://www.youtube.com/watch?v=0SG-Ftnpjns


    I find this project really interesting but I am a little confused about how some of it will work:

    *First, how can I generate random bytes for the top line of LEDs, so that the game is fair and somewhat challenging? My first thought is using counters but obviously they will be too predictable.

    *Secondly, how can I make the same byte scroll down until the end? For this part, I was thinking flip flops but I am not sure.


    Any kind of help would be appreciated. I know you guys would prefer if I had shown you some kind of effort before, but all I need is some guidance or just some kind of an idea for the afore mentioned problems.

    Also any other project ideas of similar difficulty will be great.
  2. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    This project is certainly feasible with generic digital logic.

    I envision a 555 as the clock source that feeds a 3-bit binary counter. The three outputs of the 3-bit binary counter feed 3 shift registers. The output of the 3 shift registers go to 8 3-bit to 1-of-8 decoders. The output of the decoders feed the 8 by 8 LED matrix.

    The paddle row is handled by a 3-bit up/down counter so that the paddle can move both left and right. The output of the paddle counter feeds its own 3-bit to 1-of-8 decoders. You can use a dual 4-bit digital comparator to test for hits.

    To achieve some sense of randomness you can jam the counter feeding the top-row with a scambled version of the value of the paddle at the time it is sampled by the 555 timer.

    These are just some stream-of-consciousness thoughts on one implementation of your project.

    These ideas do not address the score keeping feature.

    hgmjr
  3. Kermit2

    Kermit2 Well-Known Member

    Joined:
    Feb 5, 2010
    Messages:
    2,444
    Some micro's now have a random function output available. If you search around the web(google) I'm sure you'll find it. (like I did several months ago)

    The TETRIS game would be easy to do but difficult to explain if you don't already have an idea of how to accomplish the various tasks involved.

    Counters, shift registers, logic comparison sections in several places (times) involving the users button pushes.

    All simple things that are combined into one larger project. It should be a fun project.

    Google up what you can about TETRIS and game programming. Those subjects might get you some good info.
  4. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    Thanks for the help guys...I will look into it and get back to you abt it....

    @hgmjr could you please explain how the scrolling will work...and the purpose of shift registers...I had completely forgotten abt decoders...make things much more simpler now...thanks

    @Kermit2 I will look into Tetris as soon as possible...i am just having a hard time finding a good link for it..most links use a microcontroller....but we are not allowed to use it yet....
  5. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    Scrolling is handled by a common clock source that feeds the 3 shift registers. That way the 3-bit value that is loaded into the top of the 3 shift registers will ripple down the matrix feeding each of the 8 3-bit decoders as it travels. The LSB of the counter at the top of the matrix will feed one of the shift registers, the middle bit will feed one of the shift register and the MSB out of the counter will feed the 3rd shift register.

    I imagine that a second 555 will be needed to serve as the clock for the 3 shift registers. That way you can tweak the fall speed in proportion to the length of the game.

    hgmjr
  6. Kermit2

    Kermit2 Well-Known Member

    Joined:
    Feb 5, 2010
    Messages:
    2,444
    Two 555's at slightly different Freq's provide a clock signal for the project AND combined with some SR FF's provide a 3 bit quasi random number generator.

    :)

    [​IMG]
  7. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    @hgmjr: Thanks a lot for the help, the whole project seems much simpler than I thought initially. I wanted to ask about the LED pattern, if you notice in the video, every OTHER byte fed into the LED matrix is a 0 (all LEDs off)...I think this is for giving the player enough time to move the paddle, for this I was thinking about using an AND gate with input1 as the output from the counter and the input2 as the output Qa (LSB from the counter). This way, at every other clock cycle, the output will be ANDed with 0, producing a 0 and hence the empty line.

    I could do the same for all 3 bits of the top line. Would this work?

    Thanks in advance!

    @Kermit2: Thanks for your suggestion, I will definitely try it out in the final project.


    Thanks guys!
  8. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    In a 3-bit to 1-of-8 decoder "0" is a legitimate input. It would result in the left most or right most LED being illuminated.

    An alternate approach that would work would be to add a 4th shift register to the 3 already being used. Each of the outputs of the 4th shift register would be fed to the enable pin on the corresponding 3-bit decoder. To get the alternate blank row you would then load the 4th shift register with alternating 1's and 0's. All four shift registers would share the same clock source. A significant benefit from the 4th shift register is that you could even use it to add 1 or more blank lines between active LED rows in order to change the game level accommodate beginners. All you would need to do is change the pattern of 1's and 0's fed into the 4th shift register.

    hgmjr
  9. Georacer

    Georacer Moderator Staff Member

    Joined:
    Nov 25, 2009
    Messages:
    4,907
    Location:
    Athens, Greece (GMT +2)
    About keeping score:

    Suppose you have 8 columns, just like the video. You can wire each bit of the lower red line with the green line through a XOR gate. This way you can test if RedLED0 and GreenLED0 are both lit and one on top of the other. Duplicate this for all of the rest 7 pairs of LEDs. This way you have 8 XOR outputs. If all outputs are 0, all is fine, and you can generate a HIGH pulse to feed a counter. If not, a HIGH pulse should feed the lives counter.
    If the lower red row is blank (two 4-input ORs) you should inhibit the 2 above signals because it's the "break" line.

    Is that clear?
  10. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    Thanks for all the help guys.

    @Georacer: I think using a comparator as hgmjr suggested would be a little more convenient, I could use 2 4-bit comparators or an 8-bit comparator and hook up the output of the comparator to the counters for score and lives.

    But here is my question, what happens during the time when I am trying to move the paddle in the right location. The comparator might keep changing outputs because of the moving position of the LED and this will cause the counters to increase value even though I have not done anything yet.

    I was thinking maybe adding a flip-flop between the comparator and the scoring counters, and I am not so sure but if I add the flip-flop the clock frequency must be half of the 4 shift registers.
  11. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    If you use a 74HC688 8-bit comparator then you could connect the bottom row 8-bits to one of the 8-bit inputs and the paddle row to the other 8-bit inputs and you could use the output of the comparator to trigger the alarm to indicate a hit and to also bump the score counter. It should not produce any false hits for those rows with no leds lit since the paddle row is never equal to zero at any time.

    hgmjr
  12. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    Only the "equal to" output of the comparator will be zero, but the output for "greater than" or "less than" would not be zero and this would cause the counter for misses to increase.
  13. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    You will only be connecting to the "equal to" output. The others will not be used.

    hgmjr
  14. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    But if I dont use the others, how will I count the number of times the player has missed?
  15. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    Excellent question!

    Basically what I imagine is that the same clock that advances the LED down each row would be fed to the counter that keeps track of the ones as they fall off the bottom row. This clock will be qualified by the output of the magnitude comparator and used to advance the missed counter.

    hgmjr
  16. jerry0

    jerry0 New Member

    Joined:
    Aug 15, 2008
    Messages:
    2
    Location:
    N.C.
    You can get random #s from a cpu or discretely from a classic circuit using shift registers and XOR gates. It should be in any respectable Design textbook.
    PS Do they still have libraries with real books made of paper?
  17. bertus

    bertus Administrator Staff Member

    Joined:
    Apr 5, 2008
    Messages:
    12,458
    Location:
    Amsterdam,Holland (GMT + 1)
  18. ankur3000

    ankur3000 Thread Starter New Member

    Joined:
    Dec 28, 2010
    Messages:
    9
    @jerry0 & Bertus: Thanks for your suggestions, but I sort of understood those a while back.

    @hgmjr: I am sorry for asking you so many questions, but I think this should be the last, could you please explain your last post, I still didn't understand how it will count the misses...
  19. Kermit2

    Kermit2 Well-Known Member

    Joined:
    Feb 5, 2010
    Messages:
    2,444
    I think he means that the logic will only have an output for the one condition, so, the clock pulses, or whatever signal shifts the rows downward would count the misses. If the paddle is in the wrong position, the "missed it" logic would be missing an output. Using a NAND gate would be one way to count misses and toggle a counter. The logic gate output goes low if the clock arrives, but the paddle is not where it should be, and this is used to clock the counter.
  20. hgmjr

    hgmjr Moderator Staff Member

    Joined:
    Jan 28, 2005
    Messages:
    9,030
    Location:
    Tennessee, USA (GMT-6)
    Kermit2 has expressed my basic thought very well.

    hgmjr
Similar Threads
Forum Title Date
Homework Help Digital Electronics - Logics May 11, 2014
Homework Help switching routines with digital logic? Apr 29, 2014
Homework Help Computer Logics and Digital Design Mar 31, 2014
Homework Help Digital Logic: Realizing circuit from logic function Nov 14, 2013
Homework Help Digital Electronics paper -- Logic Gates Oct 6, 2013

Share This Page