DAQmx or traditional DAQ drivers?
Do not use DAQmx if the board is originally supported by traditional DAQ driver
The MATLAB can use DAQmx to control the M-series boards without problem; however, it cannot drive the E-series boards (originally supported by traditional DAQ driver) properly. The main issue is that the AO output is totally wrong (Data Acquisition Toolbox 2.11, 2.12?) when DAQmx is used. For example, running the following code in the MATLAB Workspace should give a continuous sine wave oscillating around zero volt on the screen of the oscilloscope:
ao = analogoutput('nidaq','Dev1');
addchannel(ao,0);
set(ao,'TriggerType','Immediate');
set(ao,'RepeatOutput',inf);
set(ao,'OutOfDataMode','DefaultValue');
ao.Channel.DefaultChannelValue = 1;
set(ao,'SampleRate',100000);
shift = 0;
aodata(:,1) = (0.5*sin(linspace(0,2*pi,200))+shift)';
putdata(ao,aodata);
start(ao)
Unexpectedly, when DAQmx is selected, the actual output from the board look like
rather than
For unknown reasons, negative values are set to zero when DAQmx is used. You may also play with the variable shift to test the outcome.
The device ID for traditional DAQ is a number, and the ID for DAQmx is something like 'Dev1'. To get the ID for your National Instruments board, use function daqhwinfo in the MATLAB workspace.
>> daqhwinfo('nidaq')
ans =
AdaptorDllName: 'C:\Program Files\MATLAB\R2007b\toolbox\daq\daq\private\mwnidaqmx.dll'
AdaptorDllVersion: '2.11 (R2007b)'
AdaptorName: 'nidaq'
BoardNames: {'PCI-6052E' 'PCI-6052E'}
InstalledBoardIds: {'Dev1' '1'}
ObjectConstructorName: {2x3 cell}
In this example, because both DAQmx and traditional DAQ drivers are installed in this computer, the same board (PCI-6052E) is counted twice by the MATLAB. The device IDs are displayed in the variable InstalledBoardIds. To use traditional DAQ driver, you have to create the AO object using device ID '1', but not 'Dev1'.
To select the desired driver, please open CapmeterSetting.m (or Capmeter1Setting.m for Capmeter1) by double clicking the file, and then edit the following command:
evalin('caller','handles.nidaqid = 2;');
This command means that the 2nd driver in the InstalledBoardIds is selected (i.e. '1', the traditional DAQ). Of course, if the InstalledBoardIds is {'1' 'Dev1'}, the command should be:
evalin('caller','handles.nidaqid = 1;');