Radio button switching with 74C373

Started by Buffalo Tom, March 04, 2020, 08:12:28 AM

Previous topic - Next topic

Buffalo Tom

Im trying to build a "Radio button" switch with 3 switches using 74C373 and 4049 as used in RG's "Programmable FX Switcher". At the moment Im only trying to lit leds on outputs Q1 and Q2 to see that everything works before moving to a relay driver. I have wired up switches to pins 3 and 5 on 4049 chip. And connected pin 2 and 4 from from 4049  to pin3 and 4 on 74C373 .. (only one switch shown on my drawing but I have two). Switching does not work and the leds on Q1 and Q2 outputs are lit all the time. Maybe I have misunderstood how to wire the chips. Can anyone see my mistake?

My version


Original:



Another thread from where I got the 100K resistor to ground on 74C373 pin 11.
https://www.diystompboxes.com/smfforum/index.php?topic=72865.0

anotherjim

#1
My understanding is that the -LE going from high to low will copy the level on the D inputs to the corresponding Q output.
Quote.  When  LATCH ENABLE  goes low,  data at the  D  inputs,  which meets the set-up and hold time requirements,  will be retained at the outputs until LATCH ENABLE returns high again.
...as the data sheet puts it.
In other words, while -LE is low, the D inputs can change and the Q outputs remain at the value of the D inputs at the time -LE went high to low.
I'm not sure how RG's scheme is meant to work. Maybe he meant it for the 74C374 instead? That latches the D into the Q when the Latch Enable goes from low to high and the Q level will stay put until another latch command happens.
QuoteThe MM74C374 is an 8-bit, D-type, positive-edge triggered flip-flop. Data at the D inputs, meeting the set-up and hold time requirements, is transferred to the Q outputs on positive-going transitions of the CLOCK input.

You need the 100k after the diodes. If you see a diode feeding a logic input, you must expect to have a resistor to keep a valid logic level there when the diode isn't conducting. The resistor value isn't fussy -  too low is wasted current and too high is prone to noise pickup. 100k is a fair choice for 12v logic.

You might get it to work with the 373 if you put an inverter between the diode/resistor and the -LE pin?


Buffalo Tom

Quote from: anotherjim on March 04, 2020, 09:04:53 AM
My understanding is that the -LE going from high to low will copy the level on the D inputs to the corresponding Q output.
Quote.  When  LATCH ENABLE  goes low,  data at the  D  inputs,  which meets the set-up and hold time requirements,  will be retained at the outputs until LATCH ENABLE returns high again.
...as the data sheet puts it.
In other words, while -LE is low, the D inputs can change and the Q outputs remain at the value of the D inputs at the time -LE went high to low.
I'm not sure how RG's scheme is meant to work. Maybe he meant it for the 74C374 instead? That latches the D into the Q when the Latch Enable goes from low to high and the Q level will stay put until another latch command happens.
QuoteThe MM74C374 is an 8-bit, D-type, positive-edge triggered flip-flop. Data at the D inputs, meeting the set-up and hold time requirements, is transferred to the Q outputs on positive-going transitions of the CLOCK input.

You need the 100k after the diodes. If you see a diode feeding a logic input, you must expect to have a resistor to keep a valid logic level there when the diode isn't conducting. The resistor value isn't fussy -  too low is wasted current and too high is prone to noise pickup. 100k is a fair choice for 12v logic.

You might get it to work with the 373 if you put an inverter between the diode/resistor and the -LE pin?

Thanks for your reply. Just bought the 74C373 chips.. Thinking that was the one RG used. This schematic has been around för 20years and hopefully built by many forum members... Maybe someone can clarify if Im using the wrong chip. Hard to believe that RG schematic is "wrong"... Its more likely im doing something wrong  ;) Thanks


anotherjim

The problem I see is that when -LE goes low to latch the D input state, the D input has also gone low -  so how can it make the Q output stay High and light a LED? It could be depending on the small timing delays in the circuit so that the latch sees the D as still being High at the micro-instant the latch action happens, but you shouldn't depend on that.

However, you should get high out of the Q output while the button press takes the D input High - but there's no guarantee that the Q output will latch high when you release the button. If it's not meant to latch the last button press, I'm not sure what it's for!
Have a look at the truth table for the 373. While LE is High, it's just an 8bit buffer. When LE goes low, Q is whatever it was before "preexisting output level". And what was that level? You can hope it's high, but the D input goes low at the same time as the latch (slightly sooner actually because the diode + resistor combo has a slower switching speed).

-you can try reducing the 100k pull down to 10k to speed the switching time up.




Buffalo Tom

Quote from: anotherjim on March 04, 2020, 10:52:35 AM
The problem I see is that when -LE goes low to latch the D input state, the D input has also gone low -  so how can it make the Q output stay High and light a LED? It could be depending on the small timing delays in the circuit so that the latch sees the D as still being High at the micro-instant the latch action happens, but you shouldn't depend on that.

However, you should get high out of the Q output while the button press takes the D input High - but there's no guarantee that the Q output will latch high when you release the button. If it's not meant to latch the last button press, I'm not sure what it's for!
Have a look at the truth table for the 373. While LE is High, it's just an 8bit buffer. When LE goes low, Q is whatever it was before "preexisting output level". And what was that level? You can hope it's high, but the D input goes low at the same time as the latch (slightly sooner actually because the diode + resistor combo has a slower switching speed).-you can try reducing the 100k pull down to 10k to speed the switching time up.

Thanks but I gave up on 74C373.. Found this schematic with CD4011B I will try instead.. Just need to buy the chip first  :)




Rob Strand

Quotehanks for your reply. Just bought the 74C373 chips.. Thinking that was the one RG used. This schematic has been around för 20years and hopefully built by many forum members... Maybe someone can clarify if Im using the wrong chip. Hard to believe that RG schematic is "wrong"... Its more likely im doing something wrong  ;) Thanks
It's possible your build has a bug but it could also be a temperamental circuit.   

Like Jim mentioned before the data needs to be valid when LE goes from high to low.   The 74C chip doesn't need to the data to be valid *after* LE goes low high but the 74HC and 74HCT do.   The problem is the LE *is* the data so if possible you want LE high to low transition to speed-up.   Jim's suggestion of reducing the resistor from LE ground should help.     

We can take that a little further by adding another diode and resistor.   What this does is add another diode drop so the LE goes low a little before the data input change.

Suppose you have,

  diode
  bank
  --->|---  10k to gnd --->   LE pin
  --->|

add another (single) diode and another 10k like this,

diode
  bank                    1x added diode                         
  --->|---  10k to gnd ------>|------ 10k to gnd--->  LE pin
  --->|

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

anotherjim

It's moot anyway since the 74C parts are obsolete and the 4000 series equivalents are also hard to find, so it's perhaps not worth pursuing.
The 374 part would have the same timing problem, but then you would only have to add a small delay to the latch input to ensure it always goes low to high AFTER the D input goes low to high.


This appears to be a button latch with a power-on reset. A button press will give a constant high output from the gate UNTIL the power is removed. Is that what you want?

Buffalo Tom

Quote from: anotherjim on March 05, 2020, 04:03:00 AM
This appears to be a button latch with a power-on reset. A button press will give a constant high output from the gate UNTIL the power is removed. Is that what you want?

I want that the output for the button pressed goes high and any other outputs go low. So I get the radio button style with only one button and relay activated at the time. Next stage is ULN2804 as relay driver. So here is where I am at the moment. Im using non latching relays. I have not tested this schematic yet. Still waiting for parts. I might remove the power-on reset transistor.



ULN2804


Data: https://www.mouser.se/datasheet/2/389/uln2801a-957494.pdf


anotherjim

#9
Yeh, sorry, I didn't consider what those diodes do.

Ok, let's look at that as it is.

On power-up, transistor M1 will be on until C1 is fully charged. That places a low into U1b which being a NAND gives a high into U1a. While SW1 is open, the other U1a input is also high via R3, so U1a output is low. Because it's low, the other input to U1b is low and the flip-flop formed is latched in this state as will all the others. All outputs are off which is a good start.
When M1 turns off, the lower flip-flop inputs go high via R2 but because the feedback from the upper gate is low, the state of the outputs don't change - another good thing.

Now press SW1. The input to U1a goes low and its output must go high. That output switches on.
U1b now has both inputs high so it puts a low back into U1a. When the switch is released, it won't change the flip-flop state so the output is now latched on. Another good!

When you operate any switch, the diode also pulls all of the lower inputs low so any latch that is already on will be toggled off.

So it all looks good I think!

There is a CD4044 available, which is x4 of those type flip-flops to reduce the parts count a bit.

Forgot to mention there is still a timing issue with this. When the reset diode acts, it also resets the flip-flop you want to set. Both inputs to the gates go low forcing both outputs high. When you release the button, the flip-flop will latch in some state with one output high and the other low - but which way? It depends on which input goes high first.
This is where those 1M resistors in the upper inputs come in to play. Together with the capacitance of the input pin, they form an RC time delay which makes the upper input the last to go high when you release the button. This gives just enough time for it to latch with the upper outputting a high. It's a dirty rotten trick - should really be a lower value resistor with a proper capacitor to ground to make the delay, but it should work.







Groovenut

You might also do a search for "randall aiken switching circuit"

The switching circuit he used in his amps will do exactly what you are looking for
You've got to love obsolete technology.....

Buffalo Tom

Quote from: Groovenut on March 06, 2020, 11:02:22 AM
You might also do a search for "randall aiken switching circuit"
The switching circuit he used in his amps will do exactly what you are looking for

I found it.. A little bit harder to understand this schematic. 


Buffalo Tom

Quote from: anotherjim on March 05, 2020, 04:10:04 PM
Forgot to mention there is still a timing issue with this. When the reset diode acts, it also resets the flip-flop you want to set. Both inputs to the gates go low forcing both outputs high. When you release the button, the flip-flop will latch in some state with one output high and the other low - but which way? It depends on which input goes high first.
This is where those 1M resistors in the upper inputs come in to play. Together with the capacitance of the input pin, they form an RC time delay which makes the upper input the last to go high when you release the button. This gives just enough time for it to latch with the upper outputting a high. It's a dirty rotten trick - should really be a lower value resistor with a proper capacitor to ground to make the delay, but it should work.

Thanks for your observation! Here is the original source.

INTRODUCTION --
The Radio Push-Button has an interesting function, occasionally needed, where pushing one momentary button of several gives a latched output representing that button, simultaneously cancelling the latched output from the previously pressed button.

The circuit draws only IC leakage current from the supply when quiescent so can be readily backed up with a coin-cell battery and a couple Schottky diodes if the button state needs to be preserved during power down (it should retain its state down to 3V or so).

OPERATION--
The circuit is shown below for three push-buttons but the circuit can be expanded indefinitely as needed, by adding additional stages.
Two NAND gates of the four in each CD4011 package are used in a cross-coupled latch configuration for each stage, to remember the last button pressed.
The total parts required for each added stage is 1/2 NAND gate package, two resistors, one diode, and one push-button.
You can reduce the IC parts count by one-half using the CD4044 quad NAND latch, which requires only 1/4 package per stage, in place of the NAND gates.

The simulation shows the operation for each of the buttons being pressed in various sequences.
As can be seen, the output for the button pressed goes high and any other outputs go low. (S1 through S3 with V1 through V3 are simulated push-button switches).

When a button is pushed. the corresponding Set input goes low, as well as all the RESet inputs through the diode (inputs are active low for a NAND gate latch).
When the button is released all inputs go high, but the Set input is delayed for a few microseconds due to the series 1 megohm resistor along with the input capacitance acting as an RC delay. This delay is sufficient to insure the corresponding latch output stays in the desired high state.

There is also a power-on reset transistor, M1, so that all outputs are zero at power up.
This could also be used as a master reset by momentarily pulling the transistor gate high.


Buffalo Tom

Here is another one... Using CD4028. Looks almost too easy, will it work?



Data: https://www.ti.com/lit/ds/symlink/cd4028b.pdf

anotherjim

The Randall circuit is very similar to the crossed NAND gates. There are 4 of them in the 4044 package. The 4081 AND gates reset other latches when a new button press happens and only that buttons latch is on. I can't see any obvious timing problems with that one. A possible problem with all combination logic is when more than one operation happens accidentally. In practice, if the switches are far enough apart, accidentally operating more than one should be unlikely.

The 4028 one is clever. It self-latches by feeding output back to input. When a second switch operates the BCD decoding clears the original Q output to one that isn't used so the latch drops out. The decoder then asserts and latches the correct Q for that last switch operation.
I wouldn't copy that 240R LED resistor though. With modern LED's and 12v you will get free laser eye treatment.
Note that if you accidentally operate 2 or more switches at the same time, all latches will drop out and the last switch contact to break will be the one that latches.

A big advantage of using a microcontroller for this is that it can be programmed to ignore multiple presses as invalid and only act after a single switch has been operated for some milliseconds to make sure it's intentional.



Rob Strand

QuoteHere is another one... Using CD4028. Looks almost too easy, will it work?
Looks nice and compact.   (If you care, you might be able to press some combination of buttons and get no relays latching you would have check all the combinations.)

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Buffalo Tom

Will try the CD4028 version first. Amazing if it works the way I want with just 1 chip and 3 resistors. Can I leave pins 3,4,5,6,7,9,11,15 unconnected?




anotherjim

Unused outputs can always be left unconnected. All the inputs have a connection to something so they are ok too.
ULN2004 transistor arrays already include a suitable base drive resistor so you could do without R5 to R8.

Buffalo Tom

Quote from: anotherjim on March 07, 2020, 11:22:56 AM
Unused outputs can always be left unconnected. All the inputs have a connection to something so they are ok too.
ULN2004 transistor arrays already include a suitable base drive resistor so you could do without R5 to R8.

That's great. Thanks Jim

Groovenut

Quote from: anotherjim on March 07, 2020, 11:22:56 AM
Unused outputs can always be left unconnected. All the inputs have a connection to something so they are ok too.
ULN2004 transistor arrays already include a suitable base drive resistor so you could do without R5 to R8.
Isnt pin 11 an input?
You've got to love obsolete technology.....