• 0
Sign in to follow this  
attila

Matlab Waveforms Sdk

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

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I am new to both C/C++ and MATLAB but have to use both in my engineering classes, could you possibly show an example of using one of the C source files in the 
"samples" folder in MATLAB? Any help would be greatly appreciated,

Share this post


Link to post
Share on other sites
  • 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)

Share this post


Link to post
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
Sign in to follow this