Simplify life with logic

This article explains how a confi gurable logic cell can simplify the implementation of complex functions on a PIC microcontroller.


By Manu Venkategowda, Microchip                Download PDF version of this article


Sometimes, something simple can have great benefits. Most embedded engineers need a variety of signals or logic to address the end application needs. They resort to designing complex board logics to address these needs. But what if there was a simple way to do something more complex? Some microcontrollers have flexible peripherals to perform the functions needed for complex applications. That is where the Configurable Logic Cell (CLC) comes in. The CLC peripheral has been added to the set of peripherals for Microchip PIC microcontrollers (MCUs) and allows users to design a simple function that can interface with the MCU. This CLC peripheral lets the user specify combinations of signals as inputs to a logic function, and to use the logic output to control other peripherals and IO pins, providing users the flexibility to design the function of their choice.

To keep things simple, the CLC is supported in Microchip MPLAB Code Configurator (MCC). This enables the designer to easily drag and drop logic gates to connect the inputs and outputs in a GUI format, and generate C code with the click of a button, greatly simplifying implementation of the CLC modules. Core Independent Peripherals (CIPs) handle their tasks with no additional code or supervision from the CPU to maintain their operation. The CLC is one such CIP that simplifies the implementation of complex control systems and gives developers ample design flexibility at the same time, off-loading the CPU to boost the microcontroller performance. Keep reading to learn how the CLC can be used to implement signal phase detection, complementary waveform generation or multiple parameter monitoring in an application. With a wide variety of inputs, triggers and outputs, the possibilities with the CLC are endless.

The CLC is a user-configurable peripheral, similar to a programmable logic device (PLD), but integrated into a microcontroller. Internal and external inputs can be chosen as inputs to the CLC. The CLC receives inputs from other peripherals or from an input pin. It then performs the intended logic operation and provides an output that can be used to control other peripherals or another IO pin. The CLC can receive signals, such as internal clock signal, an output of another peripheral and peripheral events such as a timer input. The selected input signals can be directed to the desired logic function through the signal gating stage.

The CLC supports various logic functions such as AND, OR, NOT, XOR, NAND, NOR and XNOR. In the CLC, the outputs of the data gating stage are inputs to the logic function selection stage. The output polarity stage is the last stage in the CLC and the desired polarity can be selected. The CLC can be used as a stand-alone peripheral in implementing sequential and combinational logic functions, thus facilitating quick event triggers and responses. It can also be used with other peripherals to help extend their capabilities, by facilitating custom implementation of complex functionalities in hardware.

Figure 1. Phase detector

 

Being a core independent peripheral, the CLC effectively reduces the CPU bandwidth requirement for an application, by offloading many simple and logic event responses from the CPU to the peripheral. It also reduces Flash and RAM requirements since software algorithms are not required. Logic functions implemented in hardware have faster event response compared to logic functions implemented in software. Additionally, the CLC supports a higher level of integration without any external components, reducing the overall PCB size.

The versatile features and simplicity of the CLC extend the design capabilities of a PIC MCU. One good example that demonstrates the capabilities of a CLC is in a phase detector. A phase detector can be used for many applications including distance measurement. It works on the principle that when a continuous RF wave is transmitted towards a target, the distance to the target is proportional to the phase shift between the transmitted and received waves. The CLC can be used to measure the phase difference between two signals of the same frequency. The transmitted and received waves are used as inputs to the CLC and the phase difference between the two signals at the CLC output can be used for calculating the distance between the source and target.

In the phase detector implementation using CLC, the AND-OR logic function in the CLC can be used to implement an XOR function to measure the magnitude of phase difference and the D-Flip Flop (D-FF) logic function helps in obtaining lead and lag information of the signals. Besides square waves, it is possible to measure the phase between other types of analog signals such as sinusoidal waves. Figure 1 depicts the configuration of a phase detector using CLC.

Figure 2. Complementary waveform generator in edge-aligned mode using CLC

 

The source signals, whose phase difference is to be measured, are fed as inputs to two comparators, which are configured as zero-cross detectors (ZCDs). The ZCDs convert the input analog signals to square waves of the same frequency. If source signals are square waves, then ZCDs are not required. The square waves are internally routed as inputs to multiple CLC modules. CLC1 and the input capture (IC) peripheral are used for determining the magnitude of phase difference. CLC1 is configured in AND-OR logic function from which XOR functionality is derived. The XORed output of CLC1 is externally connected as the source signal to the IC. The pulse width of the XORed output gives the magnitude of phase difference between the two waves and is measured by the IC. If the CLC1 output produces no signal, then the source signals are in phase.

In order to determine the phase lead and lag information of two input waveforms, the CLC is configured in a D-FF mode with one square wave used as a D input and the other used as a clock. The output of CLC2 being high or low will determine if D input leads or lags in phase with respect to the clock input. Measuring the phase angle between two signals of the same frequency is useful in many applications, including metering, digital power systems, communications and medical instruments.

Another way to use the CLC is in a complementary waveform generator (CWG). The CWG produces a complementary waveform with a dead-band control from its input source. A dead-band time is inserted between two signals to prevent shoot-through current in various power supply applications. This application illustrates the use of the CLC peripheral’s edge detection and interrupt capabilities in generating a complementary waveform with a single capture/compare/PWM (SCCP) module as its input source.

Figure 3. Multiple parameters monitoring using CLC

 

Often, applications, such as motor control, require several complementary waveform generators to control their functioning. The multiple capture/compare/PWM (MCCP) module can produce complementary waveforms with non-overlapping signals by controlling the dead band at its output. However, if the application requires more instances of MCCP than those available in the device, then the SCCP, in combination with the CLC, can be used. The CLC peripherals with the SCCP can be used to generate a complementary waveform with the required dead band, as the SCCP on its own cannot generate non-overlapping signals. A dead band can be added for both edge-aligned and centre-aligned SCCP outputs. Figure 2 shows the configuration of CLC1, CLC2 and CLC3 to control the dead band of the SCCP output in an edge-aligned mode.

For example, a full-bridge motor driver circuit can be driven by using an MCCP peripheral with its output producing a complementary waveform. However, if several such full-bridge motor driver circuits are to be driven, and the number of MCCP peripherals available on the device is insufficient, then an SCCP, in combination with the CLC, can be used.

Often, applications require the monitoring of different parameters, such as temperature, pressure and humidity, at the same time. If these parameters should start crossing the upper or lower thresholds, the necessary action can be taken to avert catastrophic results. Multiple comparators are available as source inputs to the CLC. In a microcontroller, a comparator can be used to monitor only one parameter. The output of multiple comparators can be combined using the CLC, to monitor multiple parameters. Necessary action can be taken when any or all of the monitored parameters exceed a certain limit. Figure 3 shows the configuration of the CLC to monitor two different parameters.

In practice, this application finds its use in monitoring temperature and pressure in an industrial plant, so that the plant can be shut down if either of the parameters exceeds a pre-set threshold. It can also be used for monitoring voltage levels in an offline uninterruptible power supply.


Related


Cloud for flat-panel controllers and RFID readers

The first cloud for flat-panel controllers offers full connectivity to enable central parameterization and constant monitoring of the operational status of displays. This brings two clear advantages: ...

PCAP Touch displays - what does the future hold?

In this article the author compares three different touch technologies and examines their suitability for industrial applications. Figure 1. Example of a touch panel with Force Touch in a medic...

 


Dirk Giesen describes the Parasoft tool suite for Embedded Software Development

Are you responsible for embedded software development in your organization? Your goal should be to create safe, secure, and reliable software. To make sure your device will work properly, deploy Paras...


Ross Sabolik of Silicon Labs talks about advanced Power over Ethernet

In this video Ross Sabolik of Silicon Labs talks about smart  Power over Ethernet systems with Alix Paultre at their APEC exhibit in San ANtonio, Texas. As PoE migrates to higher power levels and...


Dialog Semi walks through their latest IC solutions for battery chargers

In this video an engineer from Dialog Semiconductor walks us through their latest ICs for battery chargers at APEC 2018. Dialog's Qualcomm Quick Charge adapter solutions offer high efficiency to e...


Steve Allen of pSemi explains their latest LED driver solution

Steve Allen of pSemi explains their latest LED boost product based on Arctic Sand's two-stage architecture. Their PE23300 has a charge-pump, switched-capacitor architecture that offloads most of t...


Teledyne describes their latest 12-bit Wavepro HD oscilloscope

In this video Teledyne LeCroy describes their latest Wavepro HD oscilloscope to Alix Paultre of Power Electronics News at the company's launch event. The WavePro HD high-definition oscilloscope de...


Dialog Semi walks through their latest IC solutions for battery chargers

In this video an engineer from Dialog Semiconductor walks us through their latest ICs for battery chargers at APEC 2018. Dialog's Qualcomm Quick Charge adapter solutions offer high efficiency to e...


ROHM explains their latest wireless battery charger solution kit

In this video an engineer from ROHM goes over their latest wireless power development kit, co-developed with Würth for embedded development. The kit provides a complete wireless power transfer sy...


Tektronix describes their latest mixed-signal oscilloscope

In this video Tektronix explains the features in their latest 5 Series MSO Mixed Signal Oscilloscope. Features include an innovative pinch-swipe-zoom touchscreen user interface, a large high-definitio...


AVX shows a supercapacitor demonstrator at APEC

In this video Eric from AVX explains their supercapacitor demonstrator box at APEC 2018 in San Antonio, Texas. The box shows how a 5V 2.5-farad supercapacitor can quickly charge up using harvested ene...


OnSemi explains their latest passive smart wireless sensor for industrial applications

In this video On Semiconductor explains their latest wireless sensor for hazardous environments at APEC in San Antonio, Texas. Intended for applications like high-voltage power cabinets and other plac...


TI demonstrates an improved gaming power system at Embedded World

In this video Texas Instruments' explains Significant reduction in ripple, which results in improved reliability and increased design margins, among other advantages. Another benefit that improve...


Infineon explains their latest motor drive technology at APEC 2018

In this video Infineon demonstrates new gate drivers using their LS-SOI technology at APEC 2018. In the demo Victorus, an Infineon application engineer, shows in real time how much better thermal the ...


STMicro goes over their latest wireless-enabled microcontroller for the IoT

In this video STMicroelectronics goes over their latest wireless-enabled STM32WB microcontroller for the IoT and intelligent devices in several live connectivity demonstrations at Embedded World 2018....