Overview

This guide provides a simple example of how to use the CMSIS-DSP Python wrapper and how a CMSIS-DSP API is represented in Python.

Signal processing algorithms on embedded systems are often implemented with a library of optimized functions using a reference developed in a scientific computing environment. Popular environments include the open source Python library, SciPy, or MathWorks MATLAB software.

There are always differences between a scientific environment and a library of optimized functions.

Those differences may exist for different reasons, depending on:

  • What conventions are used, for example different normalization factors
  • What memory layout is used for the parameters of functions, for example the order of filter coefficients
  • Whether fixed-point arithmetic is used in the embedded system and floating-point arithmetic is used in the reference environment

These differences mean that translating the theoretical signal processing chain from the scientific environment to the embedded system does not happen immediately. The differences must be understood and under control.

To help, the Arm Digital Signal Processing (DSP) software team has introduced a Python wrapper for the CMSIS-DSP library that is compatible with NumPy. The CMSIS-DSP library is a rich collection of DSP functions that Arm has optimized for the various Arm Cortex-M processors. CMSIS-DSP is widely used in the industry, and also enables optimized C code generation from various third-party tools.

With this Python wrapper, you can design your signal processing algorithm with SciPy and progressively replace part of it with CMSIS-DSP functions that are callable from Python. Once your algorithm has been validated with the CMSIS-DSP functions, you can port the algorithm to your embedded system. This is because the Python API follows the C API of CMSIS-DSP as closely as possible.

The wrapper makes it easy to experiment and ensure that your final implementation will behave as intended.

This guide will show how to use the CMSIS-DSP Python API. At the end of this guide you'll be able to use the CMSIS-DSP Biquad filter to filter a signal defined in Python, plot the result and compare with the SciPy version.

The source code for this guide can be found in the CMSIS-DSP Python Wrapper

This guide will explain the steps related to CMSIS-DSP only. The example.py is contains Python code to load the data and build the SciPy filter.

The ECG data was taken from the PhysioNet database:
 
Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, Mietus JE, Moody GB, Peng C-K, Stanley HE. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation 101(23):e215-e220 [Circulation Electronic Pages; http://circ.ahajournals.org/cgi/content/full/101/23/e215]; 2000 (June 13).
 
And was created for the master thesis:
 
Lugovaya T.S. Biometric human identification based on electrocardiogram. [Master's thesis] Faculty of Computing Technologies and Informatics, Electrotechnical University "LETI", Saint-Petersburg, Russian Federation; June 2005.

Next