Jump to content
  • 0

Matlab Waveforms Sdk


attila

Question

The MatLab DAQ toolbox support for Analog Discovery offers limited functionality, but the underlying WaveForms SDK functions can be accessed too.

 

For manual and examples in Python and C++ see the SDK located in the default Windows installation path:

- 32bit C:Program FilesDigilentWaveFormsSDK

- 64bit C:Program Files (x86)DigilentWaveFormsSDK

function DWFtest();

% 32 bit system
%hfile = 'C:Program FilesDigilentWaveFormsSDKincdwf.h';
%64 bit system
hfile = 'C:Program Files (x86)DigilentWaveFormsSDKincdwf.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
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I don't have too much MatLab experience either. I don't even have it installed at the moment.

 

Looking at the documentation the function calling and data passing should look like this:

http://www.mathworks.com/help/matlab/matlab_external/working-with-pointers.html

...
% opened device id
hdwf = phdwf.Value;

% set parameter
calllib('dwf', 'FDwfAnalogInFrequencySet', hdwf, double(20000000.0))
...

% configure and start scope acquisition
calllib('dwf', 'FDwfAnalogInConfigure', hdwf, 0, 1)

% wait to finish
pstate = libpointer('int8Ptr',0);
while true
	calllib('dwf', 'FDwfAnalogInStatus', hdwf, pstate)
	if pstate.Value == 2 % Done; break; end
end

pData = libpointer('doublePtr', zeros(1,8192));
% get the acquired samples for first channel (0)
calllib('dwf', 'FDwfAnalogInStatusData', hdwf, 0, pData, 8192)

display(pData.Value)
Link to comment
Share on other sites

  • 0

Digilent has been working on a new MATLAB plugin that supports some more functionality than the original plugin developed by MathWorks. If anybody reading this thread wants to try out the beta, they can learn more information and sign up for the beta here:

Thanks,
JColvin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...