Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with simple logic

Status
Not open for further replies.
OK. technically it is possible, but why would you add the extra layers of circuitry needed to scan constantly the switches?

ak

Not continuous scan, it just go through maximum one cycle at each press and when reach to the pressed button, the system goes to hold / inhibit status.
 
Here's an LTspice simulation of the NAND gate circuit with write-up here.
Only the output with the last pressed switch is active.
Each output, with an added transistor driver, or a driver IC such as the ULN2803, can control a relay.
The circuit can be extended to 16 outputs by duplicating the right portion of the circuit consisting of a diode, two resistors, and two NAND gates.


1552618661051-png.117183

How does this circuit prevent more than one output from energizing when buttons are pressed at the same time?

eT
 
When you press a button, the diode-AND wiring pulls the Reset input to all of the other ff's low, clearing whichever one was latched at the time. It also pulls both the Set and Reset low for the ff for that button. When you release the button, the Reset input goes high immediately, but the Set input is held low by the time constant of the 1 M resistor and the input's capacitance. This delays the release of the Set input, leaving the ff in the Set state. Sounds a bit iffy, but the Wally has checked it out and he says it's reliable.

ak
 
When you press a button, the diode-AND wiring pulls the Reset input to all of the other ff's low, clearing whichever one was latched at the time. It also pulls both the Set and Reset low for the ff for that button. When you release the button, the Reset input goes high immediately, but the Set input is held low by the time constant of the 1 M resistor and the input's capacitance. This delays the release of the Set input, leaving the ff in the Set state. Sounds a bit iffy, but the Wally has checked it out and he says it's reliable.

ak

So the output is set on button release?
 
Because the output is taken from the gate with the Set input, it changes the instant the button is pressed. The trick is that it reliably stays set when the button is released.

ak
 
Not continuous scan, it just go through maximum one cycle at each press and when reach to the pressed button, the system goes to hold / inhibit status.
I worked through the logic. I now understand your scanning scheme, and I edited my previous response. However, at 2 ms per scan it is possible for switch bounce to confuse things.

ak
 
How does this circuit prevent more than one output from energizing when buttons are pressed at the same time?
It doesn't.
It's designed to have only one button pushed at a time.
But if more than one is pushed, the last one released will be the only one selected to stay latched.
 
This delays the release of the Set input, leaving the ff in the Set state. Sounds a bit iffy, but the Wally has checked it out and he says it's reliable.
I believe it is reliable, but if there is a timing problem, a small capacitor added to each input after the resistor to give more delay after the reset goes high, should solve it.
 
It doesn't.
It's designed to have only one button pushed at a time.
But if more than one is pushed, the last one released will be the only one selected to stay latched.

Then I don’t think that satisfies the design objectives. The switch is used to switch midi signals (5 ma current loop).
So only one output should energize regardless of the number of buttons pressed...that is why I proposed earlier using a priority encoder approach.

Being a part time musician myself, I would want switching to occur immediately when the button was pressed...but it’s up to the TS..

eT
 
that is why I proposed earlier using a priority encoder approach.
Going back through the thread, I don't see any schematics using priority encoders. Did I miss something?

Separate from that, it is almost impossible for a radio button circuit to anticipate and capture correctly every possible mis-key input scenario. Often when two keys are pressed at the same time, the intended output is for the one held down the longest, even if it wasn't the first one pressed. Wally's latches the last button released, mine takes a snapshot of all buttons at the end of the debounce period for the first one pressed, others do other things. For my circuit, if you extend the debounce time period to however long someone sliding from the wrong key to the right one takes to be stable on only the intended key, the output never has simultaneous ON circuits but is delayed maybe 100-200 ms. Wally's response is much faster, but you will see both keys until one is released.

ak
 
Going back through the thread, I don't see any schematics using priority encoders. Did I miss something?
ak

Maybe...

I removed the schematic and didn’t repost.

Anyway, there’s always a chance that more than one button gets pressed....how.?...,it happens...someone loses their balance moving about equipment and places their whole hand across some buttons...for example.
Or just simply fat fingers the buttons.

But...I believe the TS stated that requirement in their first post...

“Only one input/relay active at once.”


eT
 
I would want switching to occur immediately when the button was pressed.
My circuit does switch the output immediately.
It just latches that output when the button is released.

Can having more than one midi output momentarily connected cause a problem?
 
My circuit does switch the output immediately.
It just latches that output when the button is released.

Can having more than one midi output momentarily connected cause a problem?

It’s a current loop (in and out jacks) carrying digital signal channel info so it will end up being garbage. Probably momentarily cutoff sound of the attached instruments.
 
You could play with the latch-current vs hold current differential of relays to make latching relays...

 
Can having more than one midi output momentarily connected cause a problem?
And, can having the output go to a signal for some milliseconds before jumping to another signal cause a problem?

ak
 
And, can having the output go to a signal for some milliseconds before jumping to another signal cause a problem?

ak

Each Midi device has an "In" and "Out" jack and devices are "daisy changed" by connecting the output of one device to the input of the other device. The relays will be switching one output jack to 1 of 16 input jacks.
Here is the midi interface spec:

1554779732165.png


1554779791191.png
 
Last edited:
Here's a version using priority encoders.
I only showed 5 relay outputs in the graph because I was lazy :happy:. The outputs are shown energizing in a sequencial manner but can be selected randomly. The simulation is running with 20ms of bounce duration for each switch. The daisy chained CD4532B's only allow one input to be read at a time and present a 4-bit address (via U3) at the input to U5 . The differentiator circuit at the clock input of U4B provides the de-bouncing and triggers FF U4B to strobe U5 at each button press, causing U5 to latch the selected output. U4A sets all U5 outputs to zero at power up and latches to remove the INH signal when the first button is pressed. The circuit requires 7 chips though.:angelic: I think it could be expanded fairly easily if desired.

eT

1554780862463.png


1554780919918.png
 
Last edited:
Wouldn't that be the integrator circuit at the Reset input?

ak

At the output of U4B...yes...at the input is a differentiator..(I corrected the text in post #57)

When U4B Q goes high, U4B resets after a short delay...

BTW...U4 is a CD4013B.

eT
 
Last edited:
I get all of that, but that wasn't my point. The right side of C7 (the differentiation capacitor) jumps up and down with every flutter of a button press. Since a differentiator is an edge extractor (enhancer?), it is the opposite of a debouncer. It is the edge-triggered flipflop, and the R-C time delay of the Reset signal prohibiting a trigger on the closely-spaced bounce transitions, that does the debouncing.

ak
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top