# Of what use can a logic gate be to a circuit that contains a micro-controller

I am wondering if a logic gate would be of use to a circuit that contains a micro-controller.Are there cases when an analog logic gate is preferred over a micro-controller and what are some of the gadgets that use analog logic gates in the age of micro-processors and controllers.

• What is an "analog gate", a digital gate in a separate chip (74HC00 etc)? Or an analog switch or selector chip (CD4066 etc)? – Wouter van Ooijen Nov 7 '14 at 14:28
• I mean your ordinary OR or AND or NOR gate. – jsjsjsjsjsjs Nov 7 '14 at 14:30
• 'analog logic gate' means a gate with a statistical analog function e.g. In an analog logic XOR gate (“soft XOR gate”), the inputs to the gate are actually determined by the current proportionally to the probability that the input is logical “1” or logical “0” google.com/patents/US8742794 and a few research papers – Pete Kirkham Nov 7 '14 at 14:33
• Thanks to everyone who answered or commented.Your answers were really helpful. – jsjsjsjsjsjs Nov 7 '14 at 14:51

I think you mean a 'discrete' logic gate.

Yes, there are reasons you may wish to use an external gate. I'll take an actual example: I have a microcontroller that controls a clock signal to some external boxes. It must turn the clock (several MHz) on at a time determined by the microcontroller and must not feed out any 'runt' pulses. By synchronizing the enable with the clock generator (a flip-flop) and gating it (an 'and' gate), the specifications can be met. There's no way to do it with just the micro.

In another case, an external signal from a comparator should be enabled by a timer in the microcontroller. The microcontroller peripheral has the ability to precisely (in time) toggle its port pin, but no ability to 'and' signals with that pin state.

In some cases, microcontrollers have been fitted with some configurable logic to take care of this sort of requirement (the 'CLC' or 'configurable logic cell') on Microchip parts, for example), but there will always be applications where the micro maker did not anticipate the application. In fact, sometimes we tie an entire FPGA with hundreds of thousands of gates to the micro to get enough external logic to meet the requirements.

• Cypress Semiconductor has really cool PSoC with those sort of CLC on them, I wonder if they can deal with these issues .. Atmel just came out with their ARM Cortex M0, the D20 series, which as fully configurable communications subsystem blocks but that's not quite relevant haha. – KyranF Nov 7 '14 at 14:59
• @KyranF The 364kg gorillas in the toolbox now are the Zynq chips from Xilinx. A good-size FPGA with a dual-core 32-bit ARM A9 on-chip. – Spehro Pefhany Nov 7 '14 at 15:08
• Wow, not for \$70 it's not! Looks really good though. The cypress chips are also available in non BGA packages, for those with less professional equipment to deal with. I guess a huge project would benefit from the series power of FPGA + dual core A9. Like a huge control station with many interfaces perhaps. – KyranF Nov 7 '14 at 15:14
• @KyranF We're using them to do some heavy-duty signal processing. Just a little (but expensive) airborne box with an Ethernet port and some sensors. ;-) – Spehro Pefhany Nov 7 '14 at 15:36
• Atmel's Xmega E devices have a bunch of glue logic (XCL) built into the chips that interfaces with the core in several ways. – Ignacio Vazquez-Abrams Nov 7 '14 at 17:40

Digital logic gates ("analog logic gate" makes no sense) are still sometimes used with microcontrollers. Usually the reason is that something needs to be done at the speed of a logic gate that firmware is too slow for. Another possibility is expanding the I/O capabilities of the micro. If you have several devices on a bus, for example, you will probably have external logic that latches data to and from the bus. There may also be external logic to handle arbitration, since this often has to happen at the speed of bus cycles or fractions of a bus cycle.

Another reason: ultra low current consumption when not switching. You could use this to respond to simple input when the micro is off, or decide whether to wake it up to perform processing.

Microchip has determined that enough designers need to add some peripheral "glue" logic to their designs that they have come out with two microcontroller families -- PIC16(L)F150 and PIC10(L)F32X -- which include up to four Configurable Logic Cells (CLC), much like a miniature CPLD.

There are eight different logic functions available:

• AND-OR
• OR-XOR
• AND
• S-R Latch
• D Flip-Flop with Set and Reset
• D Flip-Flop with Reset
• J-K Flip-Flop with Reset
• Transparent Latch with Set and Reset


For example here is a J-K flip-flop:

In the case of the PIC10 (which has one CLC), that's pretty amazing for a six-pin device that costs under 40ȼ in quantity. At that price, the cost and space saving over having to include several separate logic chips adds up.

On one hand, "discrete" logic can perform faster and more reliably operations that could otherwise be done by a microcontroller. And, which sometimes is even more important, logic gates can operate concurrently, while a uC is inherently sequential.

Also, if you have a crowded board you can save I/O pins on the microcontroller if you can perform such operations externally.

To add to the list of applications, they're also useful when dealing with input signals faster than you could process directly in the microcontroller. For instance, on a board I'm working on at the moment, a phase detector - simply an XOR gate - with a resistor and capacitor allows the MCU to read out the relative phase of two signals using its ADC, instead of having to sample the whole high speed signal.

Everybody has ignored op-amps here; analogue logic has many functions even in modern uP / micro controller circuits. Proprietary signals via long wires between micros would be just one application. Personally I work on security and other electronics all the time where I have to sort out bad designs by highly qualified Engineers because of their lack of understanding of op-amps and discreet logic.

• Analog signal processing is still not logic, which deals with discrete values. – Colin D Bennett Nov 8 '14 at 6:23
• Op-amp integrators and differential circuits are calculators, and comparators and schmidt triggers provide interfaces between analogue and digital circuits. They perform logic functions in all sorts of ways. – intelec7 Nov 8 '14 at 7:01
• And just to be difficult logic circuits are analogue circuits. They, like op-amps are just very high gain analogue circuits. If you do not take that into account when designing with them then it all turns bad. – intelec7 Nov 8 '14 at 7:05
• I think you mean discrete; discreet logic is something else entirely. ;) – Nick Johnson Nov 28 '14 at 15:46

They are also used for safety logic, to keep the whole complexity of software out of the critical path. In this laser cutter board for example, to turn off the laser.