Wiki

This version is outdated by a newer approved version.DiffThis version (18 Jan 2021 08:56) was approved by Teo Perisanu.The Previously approved version (18 Jan 2021 08:30) is available.Diff

This is an old revision of the document!


What is libm2k?

A C++ library for interfacing with the ADALM2000, splitted into more correlated components, interconnected by a context.

These m2k components represent the functionalities of ADALM-2000:

  • AnalogIn - oscilloscope or voltmeter
  • AnalogOut - signal generator
  • Digital - logic analyzer or pattern generator
  • PowerSupply - constant voltage generator
  • DMM - digital multimeter

Libm2k can be used for encoding and decoding digital signals, communicating with a wide variety of chips, using some well known protocols, such as SPI, I²C or UART. Created based on no-OS communication headers, libm2k communication segment is build to interact with ADI's chips in a generic way. Regardless of protocol, there are three common steps in any communication process: initialization, writing/reading, freeing the resources. A more detailed view of communicating with a peripheral is documented here.

For an easier and faster control of m2k components, libm2k offers a command-line frontend, called m2kcli. This command line tool also includes the fuctionality of encoding and decoding digital signals. More information about m2kcli can be found on our wiki page.

ADALM2000 drivers

Make sure you install the ADALM2000 drivers for your operating system before using the board.

Linux

In order to access some USB functions without root privileges, it's recommended to install the ADALM2000 udev rules. Simply download 53-adi-m2k-usb.rules and copy into the /etc/udev/rules.d/ folder

Windows

Instructions to install Windows drivers can be found here.

Mac OS X

Instructions to install Mac OS X drivers can be found here.

How to install it?

Download

Go to the latest release page and download the package that fits your system.

Installation

libm2k for Windows

  • Download the libm2k-Windows-setup.exe and run through all the required steps.

libm2k for Linux

  • Download the libiio-ubuntu.deb for your system (from the nightly builds) and install it by running sudo apt install -f ./libiio-package.deb.
  • Download the libm2k-ubuntu.deb for your system and install it by running sudo apt install -f ./libm2k-package.deb.
  • Download the Python bindings python3-libm2k-ubuntu-amd64.deb for Ubuntu 16.04 or 18.04 and install it by running sudo apt-get install ./package.deb.

libm2k for OSX

  • Download the libiio-darwin.pkg for your system (from the nightly builds) and install it by running sudo installer -pkg /path/to/package.pkg -target /.
  • Download the libm2k-darwin.pkg for your system and install it by running sudo installer -pkg /path/to/package.pkg -target /.

How to build it?

Building bindings

Python bindings

The Python bindings are enabled by default if SWIG and a correct Python version are detected on your system. They can be specifically enabled or disabled by using the following:

~/libm2k/build$ cmake -DENABLE_PYTHON=ON/OFF ..

C# bindings

The C# bindings are disabled by default. They can be specifically enabled(requires SWIG and a correct C# compiler) or disabled by using the following:

~/libm2k/build$ cmake -DENABLE_CSHARP=ON/OFF ..

MATLAB bindings

MATLAB bindings come pre-packaged through installers for Linux and Windows. Further documentation is provided on a separate page.

LabVIEW bindings

LabVIEW bindings come pre-packaged through a .vip installer for Windows. Further documentation is provided on a separate page.

Building on Linux

Dependencies

Install git, cmake, swig, python:

~$ sudo apt-get install git cmake swig g++ python3-dev python3-setuptools libgoogle-glog-dev
Build and install libiio. Instructions can be found here.

Building with logging support

The logging system is disabled by default. It can be specifically enabled(requires glog library) or disabled by using the following:

~/libm2k/build$ cmake -DENABLE_LOG=ON/OFF ..

There is one more layer of controlling the logging. After building libm2k with logging support the user must enable the logging system from code, calling the method enableLogging(true). By default the logging system is disabled.

Install libm2k

Build and install libm2k:

~$ git clone https://github.com/analogdevicesinc/libm2k.git
~$ cd libm2k
~/libm2k$ mkdir build
~/libm2k$ cd build
~/libm2k/build$ cmake ../
~/libm2k/build$ make
~/libm2k/build$ sudo make install

If the Python bindings were enabled, they will be automatically installed in the site-packages folder specific for Python, once sudo make install is called.

Python bindings can also be built and installed manually using:

~/libm2k$ cd libm2k/build
~/libm2k$ python3 setup.py build
~/libm2k$ python3 setup.py install

Building on OSX

Dependencies

Install git, cmake, swig and python:

~$ brew install git cmake g++ swig python3

Download and install libiio.

Install libm2k

Build and install libm2k:

~$ git clone https://github.com/analogdevicesinc/libm2k.git
~$ cd libm2k
~/libm2k$ mkdir build
~/libm2k$ cd build
~/libm2k/build$ cmake ../
~/libm2k/build$ make
~/libm2k/build$ sudo make install

Install libm2k Python bindings

Make sure you installed libm2k first then run the following commands in order to install the Python bindings in your system.

~/libm2k$ cd libm2k/build
~/libm2k$ python3 setup.py install_lib
This will install libm2k.py and _libm2k.so in the site-packages folder used by your python3 executable.

Building on Windows

Get the latest installer from here.

Dependencies

  • libiio
    • Download the libiio zip from this page.
    • Choose a location and extract libiio.
  • CMake
  • Swig
    • Download the SWIG zip from this page.
    • Choose a location and extract SWIG.
  • Python3
    • Download and install Python3 from the official page.
    • Set path to program files or C:\Python37.

Install libm2k

  1. Clone libm2k or download zip and extract it.
  2. Use the CMake-gui and open libm2k/CMakeLists.txt. At startup, select platform x64.
  3. Press the Configure button. Some of the parameters will be set to their correct value.
  4. Browse the location where you extracted libiio and set IIO_LIBRARIES to libiio/MS64/libiio.lib and IIO_INCLUDE_DIRS libiio/include.
  5. Press the Configure button again.
  6. Set the PYTHON_EXECUTABLE to have the python install folder (C:/Python37/python.exe).
  7. Press the Configure button again.
  8. Browse the location where you extracted SWIG and the SWIG_DIR to that location.
  9. Press the Configure button again.
  10. If no errors, click Generate button in CMake-gui
  11. Click Open Project in CMake-gui - this will open Visual Studio.


Build solution in visual studio

If you want to install the library in the system:

  1. Open a Command Prompt in the libiio folder and copy all the .dll files in C:\Windows\System32.
  2. Open a Command Prompt in the build folder and copy libm2k.dll in C:\Windows\System32.
  3. In the build folder run pip install wheel and python setup.py bdist_wheel in order to build and install the Python Bindings.


C# bindings

  1. The C# bindings are built by default. In order to disable them, set ENABLE_CSHARP=OFF in the CMake configuration.
  2. In order to use the C# bindings, you need to copy the following dlls in your build folder: libm2k-sharp.dll and libm2k-sharp-cxx-wrap.dll . These can be found in C:\Program Files\Common Files\libm2k if you installed libm2k using the system installer. Otherwise, you can download the latest archive from appveyor: Appveyor artifacts and get the dlls from there.
  3. Add libm2k-sharp.dll as a reference in your project.
  4. Check the examples from the source code.

Documentation

API reference

An automatically generated documentation of the API can be found here: https://analogdevicesinc.github.io/libm2k/annotated.html.

calibration

Libm2k offers a software solution for calibrating the board. Please visit the dedicated page for more information.

m2kcli

Documentation can be found here.

digital communication

See the dedicated page.

university/tools/m2k/libm2k/libm2k.1610956575.txt.gz · Last modified: 18 Jan 2021 08:56 by Teo Perisanu