Have you ever considered incorporating AI into embedded devices such as home appliances, industrial equipment, or wearable devices?
Until now, machine learning inference processing was thought to require high-performance processors or cloud computing. However, recent advancements in model optimization and dedicated hardware have made it possible to perform AI inference even on low-cost microcontrollers.
Texas Instruments (TI) offers the MSPM0G5187, which incorporates a TinyEngine NPU (Neural Processing Unit) dedicated to AI inference into its MSPM0 microcontroller, which uses an Arm Cortex-M0+ core.
This article will provide an overview of MSPM0 and the features of TinyEngine NPU, and then introduce three SDK demos from the MSPM0-SDK: "waveform classification," "handwritten digit recognition," and "occupant identification," along with their model configurations and performance data.
What is TI's general-purpose microcontroller MSPM0?
Arm Cortex-M0+ microcontrollers are characterized by their low cost, small size, and integrated analog features.
MSPM0 is a family of 32-bit general-purpose microcontrollers developed by TI, featuring an Arm Cortex-M0+ core.
With operating frequencies of 24MHz, 32MHz, and 80MHz available, and a range of low-priced products, this product line is easy to adopt in a variety of devices.
A major feature of the MSPM0 is that it integrates analog functions within the microcontroller. Some products incorporate analog peripheral circuits such as zero-drift operational amplifiers, comparators, and 12-bit A/D converters, making it easier to complete the entire process from sensor signal acquisition to processing on a single chip, contributing to a reduction in external components and miniaturization of the circuit board.
Wide range of packages and pin-compatible options
MSPM0 is available in a wide range of packages, from 8-pin to 100-pin. Pin compatibility is ensured between products with different packages and memory capacities, and the software is designed to be common across all products, allowing for flexible device changes to accommodate added functionality or cost reductions.
Among the MSPM0 family, the MSPM0G5187 (80MHz, Flash 128KB, SRAM 32KB), which incorporates a TinyEngine NPU specifically for AI inference, is the product we will introduce in the following chapters.
Why is Edge AI on microcontrollers attracting attention now?
The number of challenges that cannot be adequately addressed by rule-based processing is increasing.
Traditionally, the process of determining whether "a person has moved" or "an anomaly has occurred" from sensor signals has been implemented using rule-based code that combines thresholds and conditional branching.
However, as the input patterns become more diverse, the conditions become more complex, leading to an increase in false positives and a greater amount of tuning effort.
Machine learning models, which learn features from data, can flexibly handle such diverse inputs.
Need for intuitive user input
There is a growing need for intuitive input methods, such as handwriting, as an alternative to buttons and switches.
Because these inputs vary greatly depending on the person, making rule-based judgment difficult, the use of machine learning is effective.
The advantages of inference on microcontrollers
By completing the inference process on a microcontroller, it is possible to achieve both real-time response and low power consumption.
Especially in battery-powered devices and detection applications requiring continuous operation, inference latency and power consumption significantly impact product value.
What is the TinyEngine NPU in MSPM0G5187?
The TinyEngine NPU integrated into the MSPM0G5187 is an AI accelerator optimized for convolutional neural network (CNN) computations, achieving a performance of 2.56 GOPS (2.56 billion operations per second) at 80MHz operation. It supports 8-bit, 4-bit, and 2-bit weights, and memory usage can be reduced by quantizing the model to make it smaller.
The Arm Cortex-M0+ is a simple core that prioritizes small size and low power consumption, and it does not have a floating-point unit (FPU) or DSP extension instructions. Therefore, neural network inference, which requires a large number of multiply-accumulate operations, is very demanding on the CPU alone, and the inclusion of a dedicated NPU is highly significant.
Offloading CNN calculations from the CPU to the NPU reduces inference processing time and power consumption. The three demos presented in the next chapter all use TinyEngine NPU for inference.
In addition, the MSPM0G5187 features a 12-bit 1.6Msps A/D converter with up to 26 channels, an I2S-compatible digital audio interface for connecting microphones and other devices, USB 2.0 full speed, and an AES encryption accelerator, allowing for a single-chip solution from sensor signal acquisition to AI inference and result communication.
Source: Texas Instruments, MSPM0G5187 product page https://www.ti.com/product/MSPM0G5187
Three Edge AI Demo Examples You Can Try with MSPM0G5187
From here, we will introduce three SDK demos available in MSPM0-SDK. All of them are examples of "classification tasks" that classify input data into multiple classes.
Note that it uses a quantized CNN model for INT8 and operates with small memory requirements: tens of KB of Flash memory and a few KB to a dozen KB of RAM.
Case Study 1: Waveform Classification (SDK Demo)
This is a demonstration of classifying three types of waveform signals: sawtooth wave, sine wave, and square wave. The waveform input from the function generator is captured by the A/D converter, feature quantities are extracted, inference is performed by the MSPM0G5187 's TinyEngine NPU, and the classification result is displayed by the color of the LED.
Although it's a simple topic, by reviewing it using motor current and vibration waveforms, it can be applied to fault monitoring and anomaly detection.
According to TI 's publicly available data, the results show 100% accuracy, an inference latency of 5.84 ms when running on an NPU, and an average inference energy consumption of 412.90 µJ. A sample running the same model on a CPU showed an inference latency of 54.06 ms, meaning the NPU reduces it to approximately one-ninth of that.
Waveform classification AI model information
|
item |
value |
|
Model Configuration |
CNN |
|
Number of parameters |
14,124 |
|
Input shape |
Tensor [(1, 1, 128, 1)] |
|
Output class |
3(Sawtooth、Sine、Square) |
|
Quantization |
INT8 |
Waveform classification Edge AI solution performance
|
index |
value |
|
accuracy |
100% |
|
Flash usage |
21.5KB |
|
RAM usage |
3.3KB |
|
Inference latency (NPU) |
5.84ms |
|
Inferred energy consumption (average) |
412.90µJ |
Source: Texas Instruments, SDAA429 https://www.ti.com/lit/pdf/sdaa429 / MSPM0-SDK waveform_classifier_ai README (Inference Latency during CPU Execution) https://github.com/TexasInstruments/mspm0-sdk/tree/main/examples/nortos/LP_MSPM0G5187/edgeAI/waveform_classifier_ai
Case Study 2: Handwritten Digit Recognition (SDK Demo)
Example of the MNIST dataset used for training
Source: Texas Instruments, Digit recognition with TI's microcontrollers (MCUs) https://www.ti.com/technologies/edge-ai/use-cases/character-recognition-with-edge-ai.html
GUI for handwritten digit recognition demo (displays recognition results, inference time, and classification probability for each digit)
Source: Texas Instruments, Digit recognition with TI's microcontrollers (MCUs) https://www.ti.com/technologies/edge-ai/use-cases/character-recognition-with-edge-ai.html
Potential applications include the automatic reading of nameplates, labels, and inventory tags in industrial IoT, as well as the real-time digitization of analog meter readings.
Handwritten digit recognition AI model information
|
item |
value |
|
Model Configuration |
CNN |
|
Number of parameters |
60,000 |
|
Input shape |
(1, 28, 28) |
|
Output class |
10 |
|
Quantization |
INT8 |
Performance of the Edge AI solution for handwritten digit recognition
|
index |
value |
|
accuracy |
Approximately 99% |
|
Flash usage |
73KB |
|
RAM usage |
10.9KB |
|
Inference latency (NPU) |
6.05ms |
Source: Texas Instruments, SDAA429 https://www.ti.com/lit/pdf/sdaa429
Case Study 3: Occupant Identification (SDK Demo)
A PIR (pyroelectric infrared) sensor is a sensor that detects the presence and movement of people by capturing changes in temperature (infrared spectrum). In this demo, a lightweight machine learning model that classifies the type of movement from the signal of a single PIR sensor into three classes—"human movement," "background movement," and "dog movement"—will be run on the TinyEngine NPU of the MSPM0G5187.
Diagram of detection using a PIR (pyroelectric infrared) sensor.
Source: Texas Instruments, PIR based building securityhttps://www.ti.com/ja-jp/technologies/edge-ai/use-cases/motion-detection-pir-building-security
Conventional PIR sensor detection methods have been plagued by false alarms caused by non-human movements. By collecting, labeling, and training data in-house to create a model, a single PIR sensor can distinguish between human and other movements, reducing false detections.
TI uses Goodness of Fit (GoF) evaluation to verify that the training data sufficiently reflects the variability of real-world environments. The left side of the figure shows an example of low-quality data where areas of overlap between human and non-human movements remain, while the right side shows an example where human, dog, and non-human movements are cleanly separated by extracting features such as temporal kurtosis and dominant frequencies. This demonstrates that data quality and preprocessing significantly affect the accuracy of the model.
For data collection, you can use the Edge AI Sensor BoosterPack, which is equipped with various sensors including a PIR sensor. Potential applications include building automation such as smart homes, and waking up displays when a person approaches. Because it reduces false alarms with a minimal configuration of just a PIR sensor and a single microcontroller, it can also enhance the added value of existing motion sensor products.
Checking the quality of training data using GoF evaluation (Left: Example of low-quality data where human and non-human movements overlap; Right: Example where each class is separated by feature extraction)
Texas Instruments, Multi-class motion detection for PIR based building security https://www.ti.com/technologies/edge-ai/use-cases/motion-detection-pir-building-security.html
Occupant Identification AI Model Information
|
item |
value |
|
Model Configuration |
CNN |
|
Number of parameters |
Approximately 53,000 or more |
|
Input shape |
Tensor[(1, 1, 25, 25)] |
|
Output class |
3(Human Motion、Background Motion、Dog Motion) |
|
Quantization |
INT8 |
Performance of the Occupant Identification Edge AI Solution (measured with LP-MSPM0G5187)
|
index |
value |
|
Precision (R square) |
Approximately 92.46 |
|
Flash usage |
64.1KB |
|
RAM usage |
10.4KB |
|
Inference latency (NPU) |
5.25ms |
Source: Texas Instruments, MSPM0-SDK pir_detection_ai_npu README https://github.com/TexasInstruments/mspm0-sdk/tree/main/examples/nortos/LP_MSPM0G5187/edgeAI/pir_detection_ai_npu
Summary of performance in case studies
The performance of the three demos is summarized in the table below. All of them achieve inference times of less than 10ms with less than 100KB of Flash and less than 11KB of RAM.
The MSPM0G5187 has ample memory (128KB Flash, 32KB SRAM), making it easy to integrate sensor control, communication, and other application processing tasks alongside it.
Performance list of Edge AI case studies by MSPM0G5187 (publicly available values from each source)
|
application |
Model |
Flash |
RAM |
Inference latency |
|
Waveform classification |
CNN(14,124) |
21.5KB |
3.3KB |
5.84ms |
|
Handwritten digit recognition |
CNN(60,000) |
73KB |
10.9KB |
6.05ms |
|
Identification of people in the room |
CNN (about 53k) |
64.1KB |
10.4KB |
5.25ms |
To get started with Edge AI on MSPM0
The three examples introduced in this article are available as sample projects in the MSPM0-SDK (waveform_classifier_ai_npu, character_recognition_npu, pir_detection_ai_npu) and can be tried out immediately on the evaluation board LP-MSPM0G5187.
The MSPM0-SDK also includes numerous other Edge AI samples, such as motor fault detection, arc fault detection, and wake word detection.
From model creation to implementation using the development tool "Edge AI Studio"
After evaluating the SDK demo, TI 's development tool, "Edge AI Studio," is useful when developing Edge AI with your own data. Part of the CCStudio integrated development environment ecosystem, it consists of GUI and command-line tools for processors, microcontrollers, wireless devices, and radar sensors. It supports not only devices with TinyEngine NPUs but also devices without dedicated accelerators.
The GUI allows you to perform data collection and annotation (labeling), model training, and deployment to evaluation boards all in one place. You can improve accuracy and performance by selecting an optimized, pre-trained model provided by TI Model Zoo and retraining it with your own collected data (BYOD: Bring Your Own Data). A major advantage is that you can engage in Edge AI from the preparation of sensor data without having to design a model from scratch.
The latest version for microcontrollers (v1.8.0) includes additional features such as model quantization (2/4/8 bits or automatic mixed precision) and comparison of training results. It is available in cloud and desktop versions (Windows / Linux) and is compatible with the MSPM0G5187 LaunchPad evaluation board (LP-MSPM0G5187).
Source: Texas Instruments, EDGE-AI-STUDIO https://www.ti.com/tool/EDGE-AI-STUDIO
Summary
Among the low-cost Arm Cortex-M0+ microcontrollers in the MSPM0 series, the MSPM0G5187, which incorporates a TinyEngine NPU, allows you to perform AI inference on a microcontroller, a task that previously required a high-performance processor.
The three demos introduced in this article—waveform classification, handwritten digit recognition, and occupant identification—all achieve inference in under 10ms with less than 100KB of Flash and less than 11KB of RAM. Why not start your journey with Edge AI using MSPM0G5187 by running the MSPM0-SDK demo on the evaluation board and creating a model with your own data using Edge AI Studio?
Contact Us
For any questions or inquiries regarding the products introduced in this article, or regarding the evaluation and implementation of Edge AI using MSPM0 microcontrollers, please feel free to contact us using the information below.
TI analog product catalog
To help customers considering TI products choose the appropriate product, we have prepared the Company original catalog that focuses on a wide variety of analog products.
Please download it from the link and use it.