Radio button switching with 74C373

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

Previous topic - Next topic

Slowpoke101

Quote from: Groovenut on March 07, 2020, 06:25:48 PM
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?

Pin 11 is definitely  an input. In this particular example it should go to 0V (ground ).
  • SUPPORTER
..

anotherjim

Ah, I was looking at the 4 channel example. Yes pin11 to ground.

R.G.

To lessen the mystery of the 74C373 a bit, yes, it works. However, the 74373 has a timing quirk that makes it particularly suited to this application.
The underlying idea in a non-chip-specific way is to have several D latches, each with an input. All the "capture data" lines are tied in parallel to the OR of the inputs so that any one input changing works the capture data lines. So any input being set latches all of the inputs, only one of which is active.
However, with fast logic, nanoseconds matter. Most logic D latches have a set up time which is a requirement that the data be valid some number of nanoseconds before the activation of the capture signal. This ensures time enough for the input signals to be ready before the capture signal tells the latches to set to the new condition. They also have a hold time, the number of nanoseconds after the capture line goes inactive that the data must remain steady so the data will be properly latched in and steady.
This application tries to use the data inputs for both data and capture. It tinkers with ORing the datas to make the capture signal, which more or less automatically satisfies the set up time. But the data line causing the capture signal drops before the capture line can drop. So in the raw condition, the data to the latches drops before the capture line goes inactive.
The 74C373 is somewhat unique in that it has a negative data hold time. The insides of the chip naturally allow data to go invalid some number of nanoseconds before the capture line goes inactive. This makes it a natural in this application, excepting for that being obsolete and unavailable thing.  :icon_biggrin:

It is possible to fake things to use other chips. You can buffer the inputs and use diode-resistor-capacitor networks to hold data up longer and make the capture line timing better for stock logic chips. It's a bit of a pain, but I have done it when I needed a 74C373 and didn't have one. Similar tricks work to make SR NAND and NOR latches work, in various combinations, and of course you can build anything needing latches out of JK flops. I personally find bare-latches flipflops distasteful - it's a personal limitation, I suppose. I just don't like them.

But this is the 21st century. A $0.50 controller will do eight inputs as a parallel latch of eight pins, or one of N, or momentary on each of N, or latching N and selectable momentary on any of the N ( this is the Mark Hammer configuration  :) )   I do realize that every time I say "microcontroller" peoples' eyes glaze and they start looking for an exit, but really - the reason that 74C373 and its ilk are hard to find is that uCs are so very good and so very cheap.

If anyone wants to look  at it, I think I can still find my code for running a one-of-N latch setup for PICs. It uses one of the cleverest tricks I've ever seen for processing many inputs at the same time: vertical-adder logic. I found this in a post by Scott Dattalo on the PICList forum, at least fifteen years ago. Once you see the trick, you slap your forehead. It's that good.
But the code, written in BASIC, reads N bits from a port every 10ms or so, clocking this into a software shift register of a few bytes' length. With the few-reads history of reading inputs every so often, you can do logic on the most current and preceding-few reads. Doing byte-wide logic operations on several reads lets you produce results for each bit position separately, but all of them at the same time. Eight inputs can be set up so that you get latch and debounce on eight inputs, each input ignoring all the rest. I used this for my first footswitch array setup. You can do logic across the results as well - I used this to do a one-of-N radio button. And you can mask the byte-wide results so that some inputs do one function, others do another function. As you might imagine, I went vertical-adder mad for a while.  :icon_lol:

If you are at all technically inclined, go give a look at microcontrollers. Programmers are cheap, relatively, and so are the chips. I used to use PIC BASIC Pro, but lately I've converted over to Great Cow Basic, which is free for the download.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

R.G.

I got sucked in by looking at this and pondering through my archives. There are two reasons to use the 74C373. One is that its data hold time to de-asserting LE is negative; the data can go invalid a few microseconds before LE goes invalid. I vaguely remembered some work on making the 374 version work by deliberatelyl extending the LE signal with diode/r/c nets. Haven't found that one yet. But the biggie was that the 74C family works directly on 9Vdc, unlike most new logic. There are newer 40xx3 octal transparent latches like the 74C373 that work up to 12-15V, but the ones I found don't have the negative hold time from D to de-asserting LE. The Toshiba variant has a zero hold time, but that's not quite good enough.

You can make this work without MML by using an 8-input gate on the signals to make the LE signal and putting an RC hold on that to extend it a little.

But all the 8-input D latches seem to cost as much or more than a uC to do the job, even the ones which need 5V or less for a power supply. I found you can use two **174 style latches and save some money - $0.72 for two of them versus $1.40 for an 8-bit D. The processor I'd use today is the PIC16F15344, which Mouser sells for $1.21 in ones. It works on 2.4V to 5.5V,  and uses nanowatts, so it would run on either a zener or a string of diodes for a regulator. Getting to 9V levels would most easily be done by the ULN2x0x series mentioned already. One of the ULN2803/4 would do eight relay driver outputs, and include the catch diodes, as mentioned.

Using the PIC does all the fancy steps and debouncing as well. This gets up to about $3.00 in parts, but is much less fiddly than any currently available CMOS. Out of curiousity, what does a real 74C373 cost these days?
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Buffalo Tom

#24
Thanks R.G. I bought 20x 74C373 and paid $33,80 USD. After reading your post I really wanna give 74C373 a chance again. But Im not sure I understand the original schematic. Is this correct?   


Sooner Boomer

How do these circuits handle switch bounce?
Dan of  ̶9̶  only 5 Toes
I'm not getting older, I'm getting "vintage"

anotherjim

Latching circuits can be immune from contact bounce. Once the logic level is latched, it takes a deliberate opposite action to un-latch it. A repeated action due to bouncing is only giving the same command to the latch circuit, not an opposite one. This is especially true with the S-R flip-flop since Set and Reset are separate inputs.

Slowpoke101

Quote from: Buffalo Tom on March 08, 2020, 07:34:03 PM
Thanks R.G. I bought 20x 74C373 and paid $33,80 USD. After reading your post I really wanna give 74C373 a chance again. But Im not sure I understand the original schematic. Is this correct?   



A couple of revisions - I think they are correct but I have been wrong before. Good luck and let us know how you go.



  • SUPPORTER
..

Buffalo Tom

YES! Thank you very much. I had the diode network on the inputs wrong. On the original R.G. drawing all lines is crossing each other and it's hard to know which lines to be connected or not. Another thing was to add a 200K resistor from LE to ground. Without that resistor the selected led don't stay on.

So the basic radio switch function works now! There is just one bad thing.. On power up all leds are on. I want the switcher to start up with just Q1 active. So need a solution for that. More diodes?



anotherjim

Really liking Merlins suggestion. It solves a power-0n situation where none of the channels will be selected. That diode from Q0 bootstraps the channel A latch on for you.

I've been puzzling how that 74C373 can latch valid data in a "shut the stable door after the horse has bolted" scenario.
The equivalent circuit shows it isolates each D input by a "T" Transmission gate ( like a 4016 type of switch) which is then buffered and latched by positive feedback via another T gate. That means the D level can hang around internally at a high enough voltage to be a logic high although it started to go low when the -LE input did. The feedback latch will boost it up to full high logic level.

Buffalo Tom

#31
Quote from: merlinb on March 10, 2020, 07:17:13 AM
https://www.diystompboxes.com/smfforum/index.php?topic=102786.msg1151280#msg1151280


Thanks. Have you built this one and it works for you? Im having some trouble.. Leds looses power after 20 seconds and dies.. After that buttons don't latch. Everything is very unstable. If I unplug the power and start over everything works again but only for some time then it's the same type of problems again. Its on a breadboard so maybe I have bad connections somewhere but I don't think that's the problem.  :-[

Buffalo Tom

Am I missing any parts that's needed to make this stable?


anotherjim

Where have you go the LED's connected?

merlinb

#34
Quote from: Buffalo Tom on March 10, 2020, 10:29:42 AM
Im having some trouble.. Leds looses power after 20 seconds and dies..
Maybe you're using resistors that are too small in value? The chip can only supply a little current. Use 4.7k resistors or more.

Buffalo Tom

Led 1 on [OUT 1] pin 10
Led 2 on [OUT 2] pin 13
Led 3 on [OUT 3] pin 12

Im running it on 12V and 3.9K resistors for the leds.

merlinb

#36
Hmm, I'm not sure of the chip's max current ability, but it may be more prudent to use 10k resistors or more.

Buffalo Tom

Quote from: merlinb on March 10, 2020, 12:03:27 PM
Hmm, I'm not sure of the chip's max current ability, but it may be more prudent to use 10k resistors or more.

Yes hopefully current related.. Hope so. I don't need to put the leds direct on the CD4028 chip. That was just for testing the switching logic to see whats going on. I will try tomorrow with a ULN2804 transistor array and drive the leds (and relays) from there..


Buffalo Tom

Quote from: merlinb on March 10, 2020, 12:03:27 PM
Hmm, I'm not sure of the chip's max current ability, but it may be more prudent to use 10k resistors or more.





Buffalo Tom

#39
CD4028 version merlinb posted works great together with ULN2804. I have no problems with the circuit once the ULN2804 is connected. So for a 3 button switch I believe that's the best one of all different versions we talked about here.

I also continued with the 74C373 version and that one is running fine too if you want more than 3 buttons. I implanted the reset function from the randall aiken switching circuit so its starting up with Q1 active.

Thanks everyone that helped me