Need Serious Help on Homework - Designing a 'Guess the Number Game'

Discussion in 'Homework Help' started by knnbccb, Mar 14, 2009.

  1. knnbccb

    Thread Starter New Member

    Mar 13, 2009
    2
    0
    Hi Guys,

    So sorry to disturb u all but i in really desperate need of help . I have been cracking my brains for a few days but i am back to square one.

    Question from School :

    Design and implement a digital circuit to simulate a random number guessing gamefor young children.

    The game system works as follows.
    The game gives four chances to a player to guess a number set by the system in the range of 0-15.

    To give the player a clue, a RED LED should light up if the player’s
    guess exceeds the set number by more than 3. Likewise, if the player’s guess is smaller than the set number by more than 3, a GREEN LED lights up. If the guess is within +3 from the set number, neither the GREEN nor the RED LED lights up.

    If the player guesses correctly within the four attempts, a WIN LED lights up. If the correct guess has not been made within four attempts a LOSE LED lights up. The system has to be RESET to start a new game when the outcome of the current game has been determined. The number to be guessed is input by setting it on a 4-bit DIP switch and

    entering it into the system by a push button (PB) switch coupled with a single pulsercircuit (ENTER_NUM). The player’s guess is input to the system by using a 4-bit DIP switch and another PB switch coupled with a single pulser circuit(ENTER_GUESS).

    My Circuit Design :

    [​IMG]
    List of Components Above Used for the My Design
    DM74LS194A
    4-Bit Bidirectional Universal Shift Register

    DM74LS04
    Hex Inverting Gates

    DM74LS85
    4-Bit Magnitude Comparators
    DM74LS08
    Quad 2-Input AND Gates
    DM74LS193
    Synchronous 4-Bit Binary Counter with Dual Clock
    DM74LS283
    4-Bit Binary Adder with Fast Carry

    Other available components provided by school
    Hex inverters 7404
    Quad 2-input NAND gates 7400
    Quad 2-input NOR gates 7402
    Quad 2-input AND gates 7408
    Dual 4-input NAND gates 7420
    Dual 4-input AND gates 7421
    Quad 2-input OR gates 7432
    Quad 2-input XOR gates 7486
    Dual 2-input NOR gates 7402
    4 bit magnitude comparator, 7485
    3 to 8 Line decoder / demultiplexer 74138
    Dual 2 to 4 line decoder / demultiplexer 74139
    Quad 2 to 1 line multiplexer 74157
    Synchronous 4-bit up/down counter with dual clock
    Synchronous 4-bit up/down counter with mode control
    Synchronous mod-16 counter with synchronous clear and preset
    74193
    74191
    74161/74163
    Dual D-type flip flop 7474
    4 bit universal bi-directional shift register 74194
    Binary adder 74283

    Problems that I am Facing
    :

    1. In the picture above, i circled my red area...so how do i deactivate the
    2 adders when A = B ? and vice versa?

    2. How do i connect my Magnitude Comparator to the adders when A > B or A < B so that it activates only 1?

    3. Can the LED light just by using the High State to the anod and ground to the cathode?

    4. Can someone tell me whether my circuit will work?

    :(

    pls help...at wits end :(
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Do you have a copy of logisim? It's a free download.

    I'll have to think on your project, I haven't used multiple discrete chips in a while. PICs and PLAs tend to dull the brain, though they do nifty stuff.
     
  3. knnbccb

    Thread Starter New Member

    Mar 13, 2009
    2
    0
    i'm downloading it now.

    i have been trying to use this circuit maker software but too bad the representation is not that clear 100% or maybe i'm not that good in using it.

    thanks for the help...i can't wait to hear from u again.
     
  4. mattc82

    Member

    Mar 13, 2009
    22
    0
    I just did a lab like this I used (3) 8-1 MUXs and an inverter. Its a lot of wiring but pretty simple,the reason for the inverter was to flip the A input to A’ with B, C and D as the select lines. The design allows the user to move between switches for example if (1000)2 is entered then the circuit returns (001)2 indicating that one of the bits is wrong. This design allows the LEDs to stay on until all bits are correct. The switch position when all LEDs are off corresponds to the secret number in binary. The switch position for the secret number (1010)2 is S1=1/on, S2=0/off, S3=1/on and S4=0/off.

     
  5. mattc82

    Member

    Mar 13, 2009
    22
    0
    I just did a lab like this I used (3) 8 to 1 MUXs and an inverter, the inverter allows you to invert input A with B, C and D as the select lines.For example if (1000)2 is entered then the circuit returns (001)2 indicating that one of the bits is wrong. This design allowed the LEDs to stay on until all bits were correct. The switch position when all LEDs were off corresponded to the secret number in binary. The switch position for the secret number (1010)2 was S1=1/on, S2=0/off, S3=1/on and S4=0/off. The S is for switch​
     
  6. frozenrose_5234

    New Member

    Dec 6, 2011
    1
    0
    did your circuit worked? can i have a copy of it? :( i find it cool and i want to use it for our flip flop project. please
     
  7. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    Instead of cold spiking someone else's work, from which you will learn very little, how about taking the description provided of what the problem is that the circuit is solving and then solve the same or similar from from scratch on your own. You will learn a LOT more from it.
     
  8. absf

    Senior Member

    Dec 29, 2010
    1,492
    371
    I cant see your schematics so can you please upload it again on another image site?

    1. There is no RESET or ENABLE on the LS283, so I would disable it by connecting the 4 outputs of the adder to one input each of 4 "AND" gates while the other input to the "A=B" output through a "NOT" gate. This would force the outputs of the adder to zero.

    2. Hmmm..., I haven't figured this one out yet.

    3. Better to drive the LED using a NPN transistor via 10K resistor and 470Ω on the collector of the transistor.

    4, Sorry I cant see your circuit anyway...

    Dont worry, at least 2 members here are interested in your problem.:D

    Allen
     
    Last edited: Jun 28, 2012
  9. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    Huh, my post to the OP never showed up.

    One clarifying answer I asked was whether or not I understood it correctly that if the person guesses a value that is within 3 (I'm assuming +3 was meant to be +/-3), then the player gets no indication at all? Not even an indication that they even successfully pressed the button?

    Anyway, I can't see the schematic -- the link says the file can't be found or has been deleted.

    The way I would be tempted to address it is to always perform A-B and (A is the answer and B is the guess, or the other way around) and make all of your decisions based on that one result.

    If you have a 5-bit (or larger) 2's complement adder, then this is pretty trivial. But a 4-bit adder with a carry in and carry out should be good enough with a little thought and if you are willing to spend some time understanding the math involved; it's not too complicated, but it takes a bit of playing with it.

    To motivate you toward trying this approach, consider how you might determine the information about the current guess give a single value, namely the 5-bit two's complement value for the difference between the answer and the guess.
     
  10. absf

    Senior Member

    Dec 29, 2010
    1,492
    371
    Yes, that's a good approach.:)

    The result from "A-B" would be checked against +3, 0 and -3. If >+3 light the Red LED, If < -3 the green LED. If 0 then the "WIN" LED. 7486 and 7400 together with 74283 can be used to construct the 5 bit adders.

    The "enter guess" button would step the binary counters to see if the number of guesses is greater than the preset number and light the "LOSE" LED.

    Allen
     
  11. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    Actually, you should be able to construct the necessary 5-bit A-B circuit directly with the two DIP switches, [EDIT - add: eight pullup/down resistors,] and the one 74283 4-bit adder. Nothing more.

    Then some very simple logic looking at the five adder outputs (both the sum and the carry out pins) to drive the LEDs, and then the counter to track the number of guesses.
     
    Last edited: Jun 27, 2012
  12. absf

    Senior Member

    Dec 29, 2010
    1,492
    371
    This seems harder than I first thought.

    First I would get the 2's complement of the "number to be guessed" or "B" using one of the LS283 and apply the outputs to the second LS283. This is added with the "player's guess" or "A" and the result goes directly to two or three 7485 for comparison.

    Do I really need a 4-bit adder to get the 2's complement of a binary number?

    I'll try to get the truth tables and Maths done first before I proceed with the simulation with proteus. I'll hold my design for comparison with the OP's design later.:p

    Thanks very much Mr WBahn.

    Allen
     
  13. WBahn

    Moderator

    Mar 31, 2012
    17,716
    4,788
    Think about how you take the two's complement of an unsigned integer.

    Think about what the Carry In does.

    Think about what the Carry Out does.

    Consider that a DIP switch can be configured to either produce a HI when the switch is ON or to produce a LO.
     
Loading...