Design Solutions Research & Design Hub

Inductive Sensing with PSoC MCUs

Written by Nishant Mittal

Tougher Touch Tech

Inductive sensing is shaping up to be the next big thing for touch technology. It’s suited for applications involving metal-over-touch situations in automotive, industrial and other similar systems. Here, Nishant explores the science and technology of inductive sensing. He then describes a complete system design, along with firmware, for an inductive sensing solution based on Cypress Semiconductor’s PSoC microcontroller.

Touch sensing has become an important technology across a wide range of embedded systems. Touch sensing was first implemented using resistive sensing technology. However, resistive sensing had several disadvantages, including low sensitivity, false triggering and shorter operating life that discouraged its use and led to its eventual downfall in the market.

— ADVERTISMENT—

Advertise Here

Today whenever people talk about touch sensing, they are usually referring to capacitive sensing. Capacitive sensing has proven to be robust not only in a normal environmental use cases but, because of its water-resistant capabilities, also underwater. As with any technology, capacitive sensing comes with a new set of disadvantages. These disadvantages tend to more application-specific. And those have opened the door for the advent of inductive sensing technology.

Inductive sensing is based on the principle of electromagnetic coupling, between a coil and the target. When a metal target comes closer to the coil, its magnetic field is obstructed and it passes through the metal target before coupling to its origin (Figure 1). This phenomenon causes some energy to get transferred to the metal target named as eddy current that causes a circular magnetic field. That eddy current induces a reverse magnetic field, and that in turn leads to a reduction in inductance.

FIGURE 1 – Inductive sensing technique (Source: Cypress Semiconductor application note AN219207 – Inductive Sensing Design Guide).

— ADVERTISMENT—

Advertise Here

To cause the resonant frequency to occur, a capacitor is added in parallel to the coil to create the LC tank circuit. As the inductance starts reducing, the frequency shifts upward changing the amplitude throughout.

SOME USE CASES
Consider the use case of a Bluetooth speaker that needs to be water resistant and is intended for use in up to 2″ of water for half an hour. This use case requires that the product is functional underwater. It also requires that the user can adjust the speaker in these circumstances. Such operation needs to be simple, consistent and reliable—even in the presence of water. Inductive sensing provides the solution for this. That’s because it has nothing much to do with the change in dielectric, but is only concerned with the metal detection.

For this application, metal-over-touch using inductive sensing would provide a consistent and reliable user performance (Figure 2). A light defection in metal can be detected as touch. Alternatively, a mechanical button and/or dial could be used. However, a mechanical interface is costly compared to a coil printed on a PCB and connected to a few passive components. Additionally, a mechanical button can break or fail, providing a much shorter useable lifespan than an inductive button would.

FIGURE 2 – Shown here is the architecture of a water-resistant Bluetooth speaker using inductive sensing.

Consider another use case for proximity sensing using inductive sensing technology. A vehicle detection system needs to monitor when another vehicle approaches within 2 m and signal the driver on the dashboard or navigation panel. This functionality can be implemented using inductive sensing. A hardware board containing multiple coils at different locations using a flex cable, all around the dashboard, can be designed around the four corners and center of the headlight areas (Figure 3). Data from the inductive coils is collected by an inductive sensing controller such as the PSoC 4700S from Cypress Semiconductor. The controller would then analyze the data to determine the presence or absence of other cars in a 4-m vicinity around the vehicle.

— ADVERTISMENT—

Advertise Here

FIGURE 3 – Using inductive sensing to determine vehicle proximity in an automotive application.

From an engineering point of view, inductive sensing is rugged, environment-independent, and easy to design and develop. In addition, little tuning is required to achieve the desired closed loop for an application. Note: The controller need not be placed far away from the coils to improve SNR. Individual controllers can be used to optimize the design. The block diagram mentioned in Figure 4 is a principle representation.

FIGURE 4 – Inductive sensor block diagram

SYSTEM DESIGN
In this section, I’ll discuss the complete system design along with the firmware design for the inductive sensing solution. To support the discussion, I will be using CY8CKIT-148 evaluation kit from Cypress as a reference.

In general, designing an inductive sensor is straightforward (Figure 4). A typical inductive sensor requires one or more inductive coils, as determined by the requirements of the application. To learn more about designing inductive sensing boards and controllers, make sure to check out the links on the Circuit Cellar article materials webpage. The sensor needs to be interfaced to the controller using suitable drivers or controllers to be understood by the microcontroller (MCU). This interface can be implemented using external components. However, to reduce system design and manufacturing complexity, PSoC integrates driver and converter circuitry to convert inductive sensor data into raw counts, which can then be processed using suitable algorithms.

Figure 4 shows the complete system block diagram of a typical PSoC-based Inductive Sensing board. A typical Inductive Sensing board using PSoC would require a programming and communication device, and here we use the PSoC 5LP device family. The sensor is interfaced with PSoC 4700S device, which communicates to external world using UART/I2C or any kind of feedback interface like LEDs. To program the inductive sensing controller, we need a suitable programmer either on board or using external programmers. You need to decide the maximum power to be provided. Here we have designed the system at 3.3 V, however it can range from 1.8 V to 5 V.

Designing an inductive sensing board using PSoC is straightforward compared to some other sophisticated systems. In an inductive sensing system, we need to take care of the design of tank circuit, which plays major role in tuning the circuitry for inductive sensing. Figure 5 shows the tank circuit involved in the functioning of the inductive sensing. Here L is the coil, Rs is the internal resistance. C is the tank capacitor, whose value is decided based on the frequency of resonance observed. Generally, the system is designed for higher frequency up to 1 MHz or 800 kHz for better performance, however lower frequency too can be chosen for it.

FIGURE 5 – Tank circuit for Inductive Sensing example

BUTTON OVERLAY DESIGN
The next important part in the system design of inductive sensing board is designing the metal assembly for the button. The overlay design has three major parameters that you need to decide:

1. Aluminum overlay thickness
2. Polycarbonate adhesive thickness
3. Cutout area of the sensor on the adhesive layer

Figure 6 shows the mechanical dimension of the overlay and adhesive layer for this kit. The thickness of overlay is an important parameter to decide the sensitivity of the coil response to MagSense. However, with a lower overlay thickness, the lifetime of the board reduces. A 0.5 mm thickness is typically an optimal choice from a button sensitivity and lifetime point of view. The metal target material determines the amount of deflection and response. We recommend using an aluminum overlay for inductive sensing application because of its better deflection and response. For button applications, a higher Newton force on the overlay causes deflection throughout the overlay, leading to undesirable false triggering throughout the coils. For this use case, the user should only be able to press the buttons just enough to generate feedback. Pressing the overlay harder can even deform the overlay.

FIGURE 6 – Aluminum overlay design

To tune the buttons and proximity sensor, it is necessary to measure the inductance and resistance of the coil by themselves and then with an aluminum overlay (for the buttons) and with the metal target at 2 cm (for the proximity sensor). Note here that, the proximity distance is directly proportional to the coil diameter. Once tuning has been completed, sensitivity can be adjusted by changing the resonant frequency by about 5% to 10% depending on your design. During this iteration, it is recommended to reduce the resonant frequency to detect the correct signal. In the CY8CKIT-148, there are a total of 4 inductive coils, out of which 3 are projected as buttons and 1 as proximity.

The first step in assembling the system or for the most part deciding the components for the tank circuitry, measure the inductance of the coil on board. The practical inductance observed would be different from the theoretically calculated ones.

Note: To measure the values of L and R of the coil, make sure to isolate it from other parts of the board by desoldering the series and parallel components of the coil on board. This is needed to get an accurate reading from the LCR meter. Table 1 shows the inductance and series resistance measured for the coils present in CY8CKIT-148 kit.

Without Aluminum Target Lp (Inductance) Rs (Resistance) External Parallel Capacitor External Resistor
BTN1 14.1 µH 7 Ω C41: 5 nF R32: 330 Ω
BTN2 14.1 µH 6.78 Ω C46: 5 nF R39: 330 Ω
BTN3 14.13 µH 6.9 Ω C51: 5 nF R49: 330 Ω
PROX 55.8 µH 16.9 Ω C42: 2.2 nF R34: 330 Ω
With Aluminum Target Lp Rs External Parallel Capacitor External Resistor
BTN1 5.5 µH 8.9 Ω C41: 5 nF R32: 330 Ω
BTN2 5.42 µH 8.5 Ω C46: 5 nF R39: 330 Ω
BTN3 5.51 µH 8.73 Ω C51: 5 nF R49: 330 Ω
PROX 18.3 µH 20 Ω C42: 2.2 nF R34: 330 Ω

TABLE 1 – Measurement of Lp and Rs using an LCR meter and values for external components

Figure 7 shows the design flow involved for a typical inductive sensing application. First, you assess how sensitive the system needs to be. Sensitivity determines the coil size and its number of turns are decided. The application also impacts the shape of the coil. For example, a slider interface requires a series of squares or an elongated rectangle. The next step is to calculate the tank capacitor and the inductance based on the number of turns, spacing, width, and diameter. To understand the detailed steps, refer to the Inductive Sensing Design guide. A link is available on Circuit Cellar’s article materials webpage.

FIGURE 7 – Design flow of a typical inductive sensing application

Once all these things are intact, the board is designed and fabricated. The advantage of PSoC Creator IDE is, it provides a user-friendly Inductive Sensing Tuner GUI that can be used by designers to serve their design needs

FIRMWARE DESIGN
This example showcases the features of inductive sensing in CY8CKIT-148 PSoC 4700S Inductive Sensing Evaluation Kit. When the user presses the buttons, the corresponding LEDs glow. When you bring a metal target, provided with the kit, from up to a 2 cm distance, closer to the proximity coil, the number of LEDs glowing on the board increases. A pre-requisite for the code example is that the reader must be well versed with PSoC Creator. To understand the PSoC Creator environment, refer to my three-part article series “Getting Started with PSoC Microcontrollers” in July, August and September 2017 (Circuit Cellar 324, 325, 326).

This example has a single workspace: Inductive Sensing Example. The code is available on Circuit Cellar’s article code download page. The MagSense component is configured for three buttons and one proximity coil. The EZI2C Slave Component is used to monitor sensor data on the computer using the MagSense Tuner, available in the PSoC Creator integrated design environment (IDE). Figure 8 shows the PSoC Creator schematic for this code example. This code example uses MagSense, SCB (configured as EZI2C Slave) and pins used to drive LEDs.

FIGURE 8 – Top design schematic

Table 1 shows the measurement of the inductance and resistance of the coil from an LCR meter as well as external capacitance and resistance components on the board. Based on these measurements the frequency for buttons are calculated to be 959 kHz. Similarly, the resonant frequency of the tank circuit for the proximity coil is calculated to 793 kHz. The code example firmware is implemented in the file main.c from the project. It implements a scanning algorithm as shown in Figure 9Table 2 lists the PSoC Creator Components used in this example, how they are used in the design, and the non-default settings required so they function as intended. For information on the hardware resources used by a Component, see the Component datasheet. Figure 10 shows the configuration for the MagSense Component.

FIGURE 9 – Flowchart of main.c

Component Instance Name Purpose
MagSense (6.0) MagSense Inductive Sensor processing and configuration
PSoC 4 Serial Communication Block (SCB) (4.0) EZI2C Communication with external interfaces or with Tuner
Digital Output Pin (2.20) LED_BTN1 Provide visual feedback
Digital Output Pin (2.20) LED_BTN2 Provide visual feedback
Digital Output Pin (2.20) LED_BTN3 Provide visual feedback
Digital Output Pin (2.20) LED_Level_1 Provide visual feedback
Digital Output Pin (2.20) LED_Level_2 Provide visual feedback
Digital Output Pin (2.20) LED_Level_3 Provide visual feedback
Digital Output Pin (2.20) LED_Level_4 Provide visual feedback

TABLE 2 – PSoC Creator components

FIGURE 10 – MagSense component configuration: basic tab

Enabling filters are necessary to eliminate noise. Figure 11 shows the settings for filter assignments on the component. An auto-reset feature has been enabled to prevent any kind of false triggering or stuck-on sensors. False triggering can happen due to touching the tank circuit, touching the coils or keeping the device on a metallic base. The auto-reset feature will reset all the pins after about 2 seconds.

FIGURE 11 – MagSense component configuration: advanced tab, general settings

On the Circuit Cellar article materials webpage there are a set of MagSense Component screen shots showing the tuning configuration parameters for the buttons and proximity along with settings for the SCB configured as EZI2C, and the EZI2C settings themselves. Figure 12 shows the .cydwr file (with the pin assignments) of the code example. Figure 13 shows the clock settings of the code example. We recommend to use 48 MHz as the IMO frequency and use the same setting for the modular clock frequency for the MagSense component.

FIGURE 12 – Shown here is the pin assignments of the code example.

FIGURE 13 – Clock settings of the code example in PSoC Creator

Follow these steps to begin operation:
1. Plug the CY8CKIT-148 kit board into your computer’s USB port (J2) using the USB Type-A to Type-C cable provided with the kit.
2. Install the MagSense Component from PSoC Creator using the instructions mentioned in kit guide of CY8CKIT-148.
3. Build the project and program it into the PSoC 4700S device from PSoC Creator by choosing Debug > Program. For more information on device programming, see PSoC Creator Help.
4. Observe that with a slight press on the Inductive Sensing Buttons, the corresponding LED glows.
5. Similarly, when you bring a metal target, provided with the kit, from up to a 2 cm distance closer to the proximity coil, the number of LEDs glowing on the board increases. As the distance between the metal target and the coil decreases, all four LEDs (LED4 to LED7) will begin to glow.

Note: When you operate the button or proximity sensor for a longer duration, the auto-reset feature will automatically disable the button or proximity and its corresponding LED.

For detailed article references and additional resources go to:
www.circuitcellar.com/article-materials

RESOURCES
Cypress Semiconductor | www.cypress.com

CIRCUIT CELLAR • FEBRUARY 2019 #343 — PURCHASE PDF

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
Systems Engineer | + posts

Nishant Mittal is a Hardware Systems Engineer in Hyderabad, India.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2023 KCK Media Corp.

Inductive Sensing with PSoC MCUs

by Nishant Mittal time to read: 10 min