Jump to content
  • 0

AD2 + DWF on Raspberry Pi using C# (.NET 5)


Andras

Question

Hi,

I have a very basic .NET 5 based C# console application that opens the Analog Discovery 2 using the DWF.cs wrapper class included in the WaveForms SDK v3.15.5 (64-bit) on Windows.

I could install the .NET 5 runtime on my Raspberry Pi 4 B, and I could run other .NET apps on it without any issues.

I created a small application that opens my AD2 and starts acquiring data from its CH1 input.

It runs as expected on Windows 10, but when I run it on the 32-bit Raspberry Pi OS I got the following error:

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'dwf.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libdwf.dll: cannot open shared object file: No such file or directory
   at dwf._FDwfGetVersion(StringBuilder szVersion)
   at dwf.FDwfGetVersion(String& szVersion) in /home/pi/Work/BioBalanceDetector/Measurements/WaveForms/Experiments/SleepLogging/csharp/SleepLogger/dwf.cs:line 212
   at SleepLogger.Program.Main(String[] args) in /home/pi/Work/BioBalanceDetector/Measurements/WaveForms/Experiments/SleepLogging/csharp/SleepLogger/Program.cs:line 17

Is there a way to install the missing DWF DLLs or their Linux/Raspberry alternatives on my Raspberry Pi and make my app work?

I have WaveForms 3.14.3 (32-bit) already installed on the Raspberry Pi.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Szia @Andras

The WF (application and runtime) is available for Linux ARM32 (armhf) and ARM64 (arm64):
https://reference.digilentinc.com/reference/software/waveforms/waveforms-3/start

For Linux you could try changing in the dwf.cs wrapper the DllImport("dwf.dll" to DllImport("libdwf.so" or DllImport("dwf.so" or DllImport("dwf"
... Sorry but I'm not familiar with .Net on Linux

Link to comment
Share on other sites

Szia @attila,

I fixed the C# wrapper, now it works on both Windows and Linux and I corrected two method signatures in that file, please find it attached.

I played around with the Record function (using the FDwfAnalogInStatusRecord method) on my Windows desktop and on Raspberry Pi 4. I used .NET 5 and C#, so my actual source code is identical on both platforms.

I noticed that as I raised the sampling rate, I started to get corrupted recordings above a certain sampling rate. On Windows I could reach 1 MHz, but the highest value was only 125kHz on the Pi.

I also tested this with WaveForms and I got the same results, so I suppose it's a hardware limitation. I also realized that I could potentially double the maximum rate if I could change the mode of my AD2 to the one that have 2x16k buffer for the scope. Is there a way to change to that mode programmatically using DWF?

dwf.cs

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...