Accessing a Analog Discovery without the Marlab supportpackage.

1 view (last 30 days)
Hello.
I have the past year if not for longer been trying and trying to get this to work but I am not succeeding, I don't want to seem to be moaning or anything like that but I want to tell you that I have severe ADD(and Aspberger syndrome) and that is in most instances a huge hurdle to overcome while trying to develop my understanding for Matlab or any other software(ADD that is), and I may, only may have found the solution to what I am trying to do without noticing or grasping it.
I have bought a Analog Discovery without being able to use it for what I bought it to use it for and I am really frustrated with this and I was hoping that someone here may know how to do and wouldn't mind telling me. I really have been doing all I can to solve this my self before I came back here.
You see the Analog Discovery is a USB device that enables things like Oscilloscope, waveform generator, network analyser digital pattern something something etc.
I don't know if I am allowed to post the files that you get when you install the Waveforms software(which since the 2015 version is very complicated to download, it is dead simple but before you could press "download" and be done with it but now you have to go through a purchase process as if you where buying a product only that it costs $0)
But when you have installed 'WaveForms 2015' or any other version you are also getting a folder named 'WaveFormsSDK' within which you find examples in C/Python and some other language, and you also get the following:
  • dwf.h file containing what is expected to be found in a header file(declarations for all the functions and so on).
  • dwf.lib file
  • dwf.dll file(which I don't think I will need to be messing with, oh and this isn't inside the 'WaveFormsSDK' folder but wound in my case in windows\system32 or some such system directory)
I have read a comment on a blog or something that some person used to use those files to access a Analog Discovery through Matlab and through my research I have figured out that I need to use to functions relating to external libraries such as loadlibrary()(I have to be a genius! right...). But I fail to understand how to call all the functions seen in the example files for C, there are a "WaveForms SDK Reference Manual.pdf" file but that isn't any help at all in regards to getting access to the device(not in the context of this thread). I have tried to do this through Visual Studio but failed and my last resort is to learn Python but that is something I don't have time for right now.
This shouldn't be that hard I think but I don't understand how it is done. This isn't any special case is it? it should be identical to any other situation in which you have a .h and .lib file and want to see those C files in Matlab
Could someone show me how to use a .h and .lib file and access those functions in Matlab?
I can't tell you how much I would appreciate it.
Edit: Quote: "We used to use matlab with direct dwf library calls using matlab's calllib() function"
Regards

Accepted Answer

David
David on 22 Apr 2016
Edited: David on 22 Apr 2016
Arg!
After all this time of searching and struggling to do this I finally come to search google for "Analog Discovery Matlab loadlibrary()" upon which action I found a example, I'm not sure what it gives me but it would appear that the example function tests to see if Matlab can connect to the device.
Aha, when I did the most of my work with this the thread showing this example had not been written jet... Here it is(this comes from: https://forum.digilentinc.com/topic/285-matlab-waveforms-sdk/ )
I have made some minor changes in the code to suit my file system.
function [] = DWFtest()
%DWFtest Test out the Analog Discovery Device SDK
addpath('WaveForms(2015)_SDK\inc')
addpath('WaveForms(2015)_SDK\lib\x64')
% 32 bit system
%hfile = 'C:Program FilesDigilentWaveFormsSDKincdwf.h';
%64 bit system
hfile = 'dwf.h';
display(['Set variable hfile: ' hfile]);
if ~libisloaded('dwf')
loadlibrary('dwf', hfile);
end
islibloaded = libisloaded('dwf');
fprintf('Check if dwf library is loaded: islibloaded = %dn',islibloaded)
% This is necessary to get the character strings
pBuffer = libpointer('int8Ptr',zeros(32,1));
calllib('dwf','FDwfGetVersion',pBuffer);
display(['Version: ' char(pBuffer.Value')]);
%Just opening and making sure the device is in a known state
phdwf = libpointer('int32Ptr',0);
calllib('dwf','FDwfDeviceOpen',-1,phdwf);
display(['FDwfDeviceOpen returned: ' num2str(phdwf.Value)])
% Close device and unload library
if phdwf.Value > 0
calllib('dwf','FDwfDeviceCloseAll');
end
unloadlibrary('dwf')
end

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!