# Logic design for 27 inputs

I have 27 inputs on a pcb. I need to build a circuit on this pcb that checks if only one of these inputs is high. So more than one input high is not allowed.

What is the best way to make this circuit with as less as possible physical components without making use of a fpga. I was trying it but the circuit gets quite big.

• And what should it do if more than one is high? Or if none are high, is that allowed? May 19, 2020 at 17:19
• With what sort of time response? If it doesn't need to be "MHz fast" an MCU with enough I/Os but small memories may be a reasonable choice, especially if the rules might ever get more complicated. And what are you doing with the result? Also in terms of programmable logic this is more of a CPLD task than an FPGA one, which can reduce cost and support requirements substantially. Low scale logic is possible but likely not worthwhile. May 19, 2020 at 17:32
• The output is high when more than one is input is high. And low when only one or zero inputs are high. It does not need to be MHz fast. It will never be changed afterward so hopefully we can just do it with low scale logic because that is also easy to produce and no programming step needs to be integrated. Rules will not get more complicate May 19, 2020 at 17:44
• You need to edit your question with the revised specification. Your question says, "... that checks if only one of these inputs is high." Your comment makes your question wrong. May 19, 2020 at 18:27

Use a summing network of 27 plus 1 resistors and a voltage comparator to measure the level at the summing node and produce a logic output if the voltage indicates two or more inputs are at logic 1.

• but then i also need to set a ref voltage. Is it not possible with just the inputs alone? May 19, 2020 at 17:32

Andy beat me to the wire-OR approach. Here is a variation.

Use 27 small signal diodes (1N914, 1N4148, etc.) and one common pull-down resistor. Depending on the headroom between the lowest high-level input voltage to be detected and the low-high transition voltage of whatever logic family you are using, it might be enough to simply connect the common node to a gate input. What are the lowest input voltage level to be detected, and the power supply voltage(s) available for the input circuit?

UPDATE:

This circuit illustrates the concept. It is not complete because many details are not yet supplied by the TS.

The 27 diodes and R1 form a wire-OR gate; when any input goes high, the voltage across R1 increases above the transition level of whatever is acting as a detector.

The nominal transition level for a TTL gate is approx. 1.8 V, which is far enough below the input voltage minus the diode forward voltage drop to be a reliable detection threshold. Note that if the downstream circuit is a bipolar TTL family (74xx, 74LSxx, etc.) the max value for R1 is relatively low.

CMOS families with a "T" in the descriptor (HCT, AC, etc.) also should work directly. Non-T CMOS families (HC, AC, etc.) and most 4000 series gates will not, because the transition level is approx (Vcc / 2), too close to the input signal voltage after a diode.

For a non-5 V input circuit, you'll probably need an analog comparator. The schematic shows the basic form. Missing are the operating voltages, a possible output pull up resistor, possible hysteresis, etc., because application details are not given by the TS.

• Note: Diode arrays are a thing. (e.g., four rectifier diodes in a single package with a common anode or a common cathode.) May 19, 2020 at 19:03
• Thanks for your reply! The inputs are low 0.0V, high 3.3V May 19, 2020 at 19:06
• I only can't imagine what you exactly mean May 19, 2020 at 19:24
• Do you have an example? May 20, 2020 at 9:23
• See updated answer. May 20, 2020 at 14:44

The least-invasive way I can think of is to use a microcontroller. This would give you self-test capability with modest software effort on a single, low-cost chip. Something like a low-end STM32 would have enough I/Os to handle this.

This raises a question: what is looking at the I/Os, and can that somehow be a scan-capable part?

The low hanging fruit has been plucked already, so let's go extra overkill.

Build a 32 to 5 priority encoder using the answer from this question. That's a bunch of 74HC148 which take 32 input lines and output a binary code corresponding to the number of the lowest input that is "1".

Build another and feed it the same inputs, but in reverse order.

Add a comparator: if both encoders output the same value, then there are either zero or one input bit set. If more than one input is 1, then both encoders will output different values since they're priority encoders and the second one has its inputs reversed, and the comparator will notice this.

Now I was looking for a really oldskool way to do this, which means obviously that it has to use magnetic cores. I guess by running all the 27 wires through a saturable core that would saturate when more than one wire carries current...