Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ADALM2000 #104

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

teoperisanu
Copy link

@teoperisanu teoperisanu commented Nov 17, 2020

ADALM2000 is an affordable USB-powered data acquisition module designed by Analog Devices Inc.

The adalm2000 driver integrates both the digital(16 channels) and analogical(2 channels) inputs and these are synchronized so that when both are running a mixed signal acquisition is performed.
The triggers for both components are configurable.
There are a variety of attributes that can be modified, such as vertical offset, the analogical range, oversampling ratio, the trigger delay and many others.

libm2k documentation: https://wiki.analog.com/university/tools/m2k/libm2k/libm2k

@resonantworks
Copy link

resonantworks commented Jun 22, 2021

Hi, I just tried compiling to Windows using sigrok-util/cross-compile/mingw/sigrok-cross-mingw script and it fails during configure of libsigrok. As it's a cross-compile, I'm assuming libm2k would need to be built and 'installed' within that script.

This could be a blocker for PR acceptance since the Windows target is automatically built by the nightlies. If you want to try give it go, you would (currently) need to checkout build-2020-06-06 after cloning mxe to get the script to work (found by trial and error).

Btw, PulseView uses CMake with its CMakeLists.txt detecting that it is being built under 'WIN32', so that might be a start.

...
checking for libieee1284... yes
checking for libgio... yes
checking for LIBM2K... no
configure: error: Package requirements (libm2k) were not met:

Package libm2k was not found in the pkg-config search path.
Perhaps you should add the directory containing `libm2k.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libm2k', required by 'world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBM2K_CFLAGS
and LIBM2K_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

@resonantworks
Copy link

If you need a place to start, check this comment left for building a MXE Windows target (for the KingST LA2016 PR):
#131 (comment)

@teoperisanu
Copy link
Author

I will have a look at the compiling script in the following weeks.

Teo Perisanu added 23 commits June 30, 2021 23:23
Build adalm2000 driver only if libm2k is found in the system.

Signed-off-by: Teo Perisanu <[email protected]>
libm2k is a C++ library. In order to use it for the driver, a C code
wrapper must be created.

Signed-off-by: Teo Perisanu <[email protected]>
adalm2000 has both a 16-channel logic analyzer and a 2-channel
oscilloscope. There are some global attributes, but also each
channel has several specific attributes.

Signed-off-by: Teo Perisanu <[email protected]>
Add the initial structure of the device. Scan for each USB connected
board. Also an IP can be provided, in order to create a connection.

Signed-off-by: Teo Perisanu <[email protected]>
After the device is opened, an ADC calibration is performed.

Signed-off-by: Teo Perisanu <[email protected]>
Signed-off-by: Teo Perisanu <[email protected]>
Retrieve the number of enabled channels for the logic analyzer
or for the oscilloscope.

Signed-off-by: Teo Perisanu <[email protected]>
The available samplerates are the common values between the LA and
the OSC. Always set the same samplerate for both components.

Signed-off-by: Teo Perisanu <[email protected]>
Store the oversampling ratio. It will be actually set just
before the acquisition starts.

Signed-off-by: Teo Perisanu <[email protected]>
The oscilloscope has a range of -2.5V +2.5V in the high resolution
mode. In the normal mode the range is between -25V and 25V.

Signed-off-by: Teo Perisanu <[email protected]>
Add an extra trigger state - NO_TRIGGER. Add function to convert
the libsigrok trigger to a libm2k trigger.

Signed-off-by: Teo Perisanu <[email protected]>
adalm2000 has a source trigger for the OSC and for each channel
has a trigger mode. Handle both attributes depending on the
trigger source.

Signed-off-by: Teo Perisanu <[email protected]>
Convert the libsigrok trigger slope into libm2k trigger condition.

Signed-off-by: Teo Perisanu <[email protected]>
Transform the pre-capture ratio into a delay value for both OSC and LA.
Always keep the same delay for both components.

Signed-off-by: Teo Perisanu <[email protected]>
… libm2k.

Add functions for creating the internal buffers, populating them,
canceling any operation performed on them and destroying them.

Signed-off-by: Teo Perisanu <[email protected]>
…bm2k.

Add functions for creating the internal buffers, populating them,
canceling any operation performed on them and destroying them.

Signed-off-by: Teo Perisanu <[email protected]>
…of libm2k.

Add functions for creating the internal buffers and destroying them
in the mixed signal mode.
Add function to check if the mixed signal is available.

Signed-off-by: Teo Perisanu <[email protected]>
Add functions for enabling the analogical channels, setting
the number of kernel buffers, and enabling the streaming mode.

Signed-off-by: Teo Perisanu <[email protected]>
Destroy all buffers and stop the streaming mode.

Signed-off-by: Teo Perisanu <[email protected]>
Configure the digital trigger.
Set the oversampling ratio.
Synchronize the OSC with the LA.
Start the acquisition in the streaming mode.
Acquire the exact number of samples to
fit in the given boundaries.

Signed-off-by: Teo Perisanu <[email protected]>
@resonantworks
Copy link

Thanks @teoperisanu! Btw, I tried your changes under Linux and seems to run great on the device - many thanks for the contribution! It might also be a good idea to put some docs together on how to install the Linux drivers and any other important information. Not sure where you could put that though - the best place would obviously be on the official sigrok website, but I suppose that can only be done once this PR has been merged. Maybe for now you could possibly update your PR comments to include at least a link to the driver setup/requirements for testing the PR.

@adisuciu
Copy link

adisuciu commented Jul 6, 2021

I managed to build this but only with dynamic linkage to libm2k, libiio, libxml2. Pulseview doesn't start if you don't have the dlls alongside pulseview.exe .

Is this a hard requirement, full static build ? If so, do you have any pointers to do so ? I'm getting some linkage errors when linking pulseview/sigrok-cli to libm2k. I can post a build log with static/dynamic linkage or you can test it yourself:
https://github.com/adisuciu/sigrok-util/tree/libm2k

image

image

-Adrian

@resonantworks
Copy link

Thanks for the work @adisuciu! Unfortunately I think only the maintainers know anything about the MXE-based Windows build. I just barely managed to get it work after a lot of trial and error.

@resonantworks
Copy link

@adisuciu, maybe if you post a snippet of the relevant error output for the static linking build, and also attach the full build log, then someone might recognise the error and be able to help out. This is another great piece of hardware for the money and it would be a shame to not find a solution to this to have it included in the mainline build.

@adisuciu
Copy link

Attached are the log files - the error is on the bottom of build_static.log

build.log - build with dynamic libs
build_static.log - build with static libs
diff_static.txt - diff from my fork to enable static build

build.log
build_static.log
diff_static.txt

@biot
Copy link
Contributor

biot commented Oct 2, 2024

There is another effort underway for an ADALM2000 driver in PR #243. Could you join forces with that PR? The use of libiio there isn't going to work out, and it looks like libm2k (a precursor to libiio?) is a similar thing: it brings nothing to the table that I can see, and the device interface should just be handled with libusb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants