Latch Issue

Status
Not open for further replies.

eenewbie

New Member
Logic Gates and Latch Issue

I've been working on this circuit, but I can't get it to work as expected in any simulator. Im basically trying to store the current state of an LED and alternating between two color LEDs so whenever the next turn results in an odd number of switches closed the red LEDs should light up and whenever there is an even number of switches closed a yellow LED should light up. Previous LEDs that have been powered on should remain at their last state through the NOR latches. Unfortunately, both LEDs light up whenever any switch is closed. What am I missing?

Thanks
 

Attachments

  • circuit.jpg
    295 KB · Views: 205
  • circuit.png
    101.8 KB · Views: 191
Last edited:
Logic Gates and Latch Issue

The complete design has 9 switches. As each is closed the LED lights should alternate between red / yellow according to whether there are an odd / even number of switches closed. Each LED pair should remain at its previous state through its NOR latch. Now the problem is that when a switch is closed... both red and yellow LEDs light up. This should not be happening, but I can't seem to figure it out.

Expected Results
Close S1: RED LED LIGHTS UP
Close S2: YELLOW LED LIGHTS UP, Previous LED remains RED
Close S6: RED LED Lights Up, Previous LEDs remain Red and Yellow.

Actual Results
Close S1: Both Red/Yellow LED Light up
Close S2: A new pair of Red/Yellow LED Light up, Previous Pair remains on

I would appreciate any insights as to why the circuit is not working.

I've included another design using the 4044BP NAND latches... this one won't turn any LEDs on at all.
 

Attachments

  • Circuit2.JPG
    86.8 KB · Views: 208
can you explain bit more about what you really want to do? on the expected result you mentioned closeS2, is it when S1 is still in close? or only one switch is closed at a time? or you are trying to make a memory for the keys pressed and it will be the input to tell ODD or EVEN?

you have used the latches that "set" on input "L" and "LL" is not permissible. if you want other way then use an inversion before the inputs.

Edit:
1) i made a mistake, the latches are set by logic high, but the output goes low that time, by swapping the outputs you will get the right result. or you have to invert the out puts.
2) the reset input is not having any value like floating, it might have caused a problem in your result.
3) when the key is pressed the output changes/ toggles that is an input to your latch, so you may get different result depends on semiconductor response time. you better use a D-flip flop before connecting.
 
Last edited:
when a switch is closed... it remains closed. So when I close S2... S1 is still closed. I'm trying to keep tabs of a player in a tic-tac-toe game. So when S1 closes... LED red lights up indicating Player 1... when S2 closes... LED yellow lights up indicating player 2... The latch is supposed to keep the S1 pair of LEDs from switching to yellow when I close S2.

When you say invert the outputs... do you mean Q and Q' on the latches or the cross-links between the two NOR gates of the latch? If I did the cross-links... wouldn't that be the same as using OR instead of NOR gates for the latches?

I thought the reset input basically shows a LOW (0v) until the switch is pressed to reset the latches.

I think I know what is happening... don't know how to solve it though. When I close S1... there is a brief instant where the voltage coming out of U19 is 5V before it quickly goes back to 0V. This causes the latch to lock in. I've included a few diagrams with voltage/current probes of three states (Circuit On, S1 Closed, S1-S2 Closed).

Any ideas how to filter that initial 5V coming out of U19?

Thanks,
 

Attachments

  • Circuit_ON.JPG
    100.5 KB · Views: 170
  • Circuit_S1.JPG
    100.6 KB · Views: 169
  • Circuit_S1S2.JPG
    101.1 KB · Views: 165
So I've made some progress... I added a D Flip-Flop and I can now reliably turn the LEDs on. However, I'm not quite getting the result I want. This is what happens now...

S1 Closed: RED LED Turns On / Green LED remains off
S1 S2 Closed: Second RED LED Turns On / Second Green LED remains off - Previous RED LED remains ON / Previous Green LED Turns On (Not what I want... it should have stayed OFF)

This may help visualize it better:
Step 1
S1 Closed :Red On / Green Off
S2 Open: Red Off / Green Off
S3 Open: Red Off / Green Off

Step 2
S1 (Remains Closed): Red On / Green On
S2 Closed: Red Off / Green On
S3 Open: Red Off / Green Off

Step 3
S1 (Remains Closed): Red On / Green On
S2 (Remains Closed): Red On / Green On
S3 Closed: Red On / Green Off

Any help is appreciated... it shouldn't be this hard... ;-)

Thanks,
 

Attachments

  • Circuit-FF.JPG
    157.6 KB · Views: 174
Last edited:
I was able to fix the issue. I added a couple of AND gates and an inverter to make sure only one LED is ON at any given time for each pair of LEDs. I'll post the final circuit tomorrow once I've cleaned it up.

Thanks for all the help.
 
great, but i feel still there is a simple way to do what you want. may be if you connect the latches directly to the switches (micro switch - not latching type), then it will indicate the status of the switch until you reset it. the out put can now be wired to XORs.

also you can use 4017 IC as a digital selector and the output you can code it to get different conmbination for your requirement. see the folwing link

https://www.electro-tech-online.com/threads/channel-selector-project.105567/
 
Have a new issue... stray voltage?

I haven't posted the final diagrams as I ran into another problem. The circuit works perfectly using the virtual components, but once I began replacing them with actual ICs I've run into an issue with the 4070B XOR gate. I'm attaching three pictures... Picture 1 shows the relevant section of the circuit with my switch in the off position... no voltage is applied to the gates inputs (A/B). Then Picture 2 shows the switch in the on position and I'm applying 5V (VDD) to the B input. Finally, Picture 3 shows the switch back in the off position and I'm now getting a slowly decaying voltage dropping about .01v a second from 5v... on the B input. Where is this coming from? I can fix it by changing the switch to a SPDT between 0v and 5v. I'm just trying to find out where is the stray voltage coming from.

Thanks,
 

Attachments

  • pict_1.png
    17.6 KB · Views: 163
  • pict_2.png
    17.5 KB · Views: 164
  • pict_3.png
    17.4 KB · Views: 158
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…