Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 1
DATAQ Instruments Matlab Adaptor
Beta Version 0.3.0.0
Getting Started
1. Download the DATAQMatLabAdaptor.zip file located on the DATAQ Instruments website at: http://
www.dataq.com/support/downloads/DATAQMatLabAdaptor.zip. The .zip file will contain the file: matlab.exe.
2. Extract and run matlab.exe. This will
open the installation program and install the necessary components to run
DATAQ Instruments’ MatLab Adaptor.
a. Select a Destination Directory. Rememb
er the destination or write it down - you will need to know the desti-
nation to setup the daqdevs.txt file in Step 3.
b. The Installation software will ask you if you would like to Backup
any overwritten files. Choose Yes to
backup the overwritten files, choose No to ignore.
c. The Installation software ends.
3. Edit the daqd
evs.txt file. See “Editing the daqdevs.txt file” on page 1 for more information. Correct Data for all
installed hardware must be entered into this file.
4. Start (or Restart) MatLab to grab the settings from the
daqdevs.txt file. MatLab’s Data Acquisition Toolbox must
be installed to run the DATAQ Instruments MatLab Adaptor. All “Analog In” functions of the Data Acquisition
Toolbox are available in the adaptor. View the MatLab Help Files for information regarding the use of MatLab.
View the “Sample Session” on page 9 or try the sample program downloaded in DATAQMatLabAdaptor.zip file
for examples.
Editing the daqdevs.txt file
The daqdevs.txt file is located in the Destination Directory specified during installation (Step 2a above). Use
Notepad or any other text editing software to access and change the file. All hardware you would like to use in the
MatLab Adaptor must be installed as well as WinDaq Software in order to correctly identify each device in MatLab.
The daqdevs.txt file contains three device descriptor lines per Hardware Device. The information in these lines
cannot be determined until both the Hardware Device and WinDaq Acquisition software have been installed. Each
device must have the correct Device Name, Driver Name, and Device ID to work correctly. See “Device Names,
Driver Names, and Device IDs” on page 2 for correct entries.
Use the following format for each device’s description (# is a comment line):
#Hardware Device #
Device Name
Driver Name
Device ID
For Example:
#Hardware Device 1
DI-194RS
DI102NT.DLL
COM2 194 4800
DATAQ Instruments Matlab Adaptor
2 Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope
Follow these rules when entering device descriptor lines:
1. All three device descriptor lines must be kept together.
2. There can be no extra spacing at the end of a line.
3. Comments must take up an entire line and cannot be on any of the three device lines.
4. You may enter as many devices as you have installed on your PC.
Devices installed to your system at a later date may be added to the daqdevs.txt file. MatLab must be restarted each
time the daqdevs.txt file is edited in order for the changes to take effect.
Device Names, Driver Names, and Device IDs
DI-194RS and DI-154RS
The Device Name must be entered exactly as shown in the above table.
In Driver Name xx = the COM port designation. See“Finding the COM port designation or LPT number of your
Printer Port, Serial Port, or Virtual Serial Port Instrument” on page 8 to determine what COM port your device was
installed to. Single Digit COM port designations require a “0” to be entered prior to the number (for a device installed
to COM port 1 enter “01”).
Device ID consists of three parts: the COM port designation (COMxx), the hardware model number (194 or 154), and
the Baud Rate (4800). The default Baud Rate for that instrument is shown. If the Baud Rate of the device has changed
be sure to enter the current Baud Rate of the Device. See “Baud Rates” on page 7 for all the possible Baud Rates of
your device.
Example: If you have installed a DI-194 to COM port 2 and never changed the Baud Rate you would enter the
following 3 lines to the daqdevs.txt file:
DI-194RS
DI102NT.DLL
COM2 194 4800
DI-148 and DI-158 products
The Device Name must be entered exactly as shown in the above table.
In Driver Name xx = the COM port designation. These USB devices use a “Virtual COM Port” for communication.
See“Finding the COM port designation or LPT number of your Printer Port, Serial Port, or Virtual Serial Port
Instrument” on page 8 to determine what COM port your device was installed to. Single Digit COM port designations
require a “0” to be entered prior to the number (for a device installed to COM port 1 enter “01”).
Device ID consists of three parts: the COM port designation (COMxx), the hardware model number (148 or 158), and
the Baud Rate (460800). The default Baud Rate for that instrument is shown. If the Baud Rate of the device has
Device Name Driver Name Device ID
DI-194RS DI1xxNT.dll COMxx 194 4800
DI-154RS DI1xxNT.dll COMxx 154 4800
Device Name Driver Name Device ID
DI-148U DI1xxNT.dll COMxx 148 460800
DI-158U DI1xxNT.dll COMxx 158 460800
DI-158UP DI1xxNT.dll COMxx 158 460800
DATAQ Instruments Matlab Adaptor
Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 3
changed be sure to enter the current Baud Rate of the Device. See “Baud Rates” on page 7 for all the possible Baud
Rates of your device.
Example: If you have installed a DI-158UP and have determined that it has been designated to COM port 7 and
never changed the Baud Rate you would enter the following 3 lines to the daqdevs.txt file:
DI-158UP
DI107NT.DLL
COM7 158 406800
DI-400 and DI-410
The Device Name must be entered exactly as shown in the above table.
In Driver Name and Device ID n = the WinRT virtual device number. The Driver Name can be found in the
tpdataq.ini file located in the Windows folder of your hard drive. Use the Driver Name to determine the Device ID
(“n” in Driver Name = Device ID).
Example: If you have installed a DI-400 and, after determining the Driver Name from tpdataq.ini is DI402NT.DLL,
you would enter the following 3 lines to the daqdevs.txt file:
DI-400
DI402NT.DLL
2
DI-500/510/750/760 Series
The Device Name must be entered exactly as shown in the above table.
In Driver Name and Device ID n = the WinRT virtual device number. The Driver Name can be found in the
tpdataq.ini file located in the Windows folder of your hard drive. Use the Driver Name to determine the Device ID
(“n” in Driver Name = Device ID).
Example: If you have installed a DI-510-32-P on a Windows XP machine and, after determining the Driver Name
from tpdataq.ini is DI501NT.DLL, you would enter the following 3 lines to the daqdevs.txt file:
DI-510-32-P
DI501NT.DLL
1
DI-710 Series
Device Name(s) Operating System Driver Name Device ID
DI-400 or DI-410 Win95/98 DI2s32.dll 0
WinNT/ME/200/XP DI40nNT.dll n
Device Name(s) Operating System Driver Name Device ID
DI-500-16-P
DI-510-32-P
DI-510-48-P
DI-750-16-D
DI-760-32-D
DI-760-48-D
Win95/98 DI2s32.dll 0
WinNT/ME/200/XP DI50nNT.dll n
Device Name(s) Driver Name Device ID
DATAQ Instruments Matlab Adaptor
4 Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope
The Device Name must be entered exactly as shown in the above table.
USB Devices
In the Driver Name xx = the COM port designation. These USB devices use a “Virtual COM Port” for
communication. See“Finding the COM port designation or LPT number of your Printer Port, Serial Port, or Virtual
Serial Port Instrument” on page 8 to determine what COM port your device was installed to. Single Digit COM port
designations require a “0” to be entered prior to the number (for a device installed to COM port 1 enter “01”).
Device ID consists of three parts: the COM port designation (COMxx), the hardware model number (710), and the
Baud Rate (115200). The default Baud Rate for that instrument is shown. If the Baud Rate of the device has changed
be sure to enter the current Baud Rate of the Device. See “Baud Rates” on page 7 for all the possible Baud Rates of
your device.
Example: If you have installed a DI-710-UH that has been designated to COM Port 4 and have never changed the
Baud Rate you would enter the following 3 lines to the daqdevs.txt file:
DI-710-UH
DI104NT.DLL
COM04 710 115200
Ethernet Devices
In Driver Name nn = the order in which the Ethernet device was installed (in comparison with other DI-710
instruments). This number will be in the range of 40 to 69 and can be determined by running the device in WinDaq
Acquisition. The title bar in WinDaq Acquisition software will contain (from left to right): the Model Number of the
device; the word “Acquisition”; the 3 digit Driver Name number; and the Serial Number of the Device.
The Device ID is the IP address of the instrument. If you are accessing the device over the internet you will also need
to enter the Port number designation.
Example: If you have installed a DI-710-EHS to your local network and have determined the Device Driver number
is 640 (by opening WinDaq Acquisition software) and the IP address is 192.168.1.2 you would enter the following 3
lines to the daqdevs.txt file:
DI-710-EHS
DI640NT.DLL
192.168.1.2
DI-710-UH
DI-710-UL
DI-710-UHS
DI-710-ULS
DI1xxNT.dll COMxx 710 115200
DI-710-EH
DI-710-EL
DI-710-EHS
DI-710-ELS
DI6nnNT.dll IPaddress
or
IPaddress:Port
DATAQ Instruments Matlab Adaptor
Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 5
DI-715B Series
The Device Name must be entered exactly as shown in the above table.
USB Devices
In the Driver Name xx = the COM port designation. These USB devices use a “Virtual COM Port” for
communication. See“Finding the COM port designation or LPT number of your Printer Port, Serial Port, or Virtual
Serial Port Instrument” on page 8 to determine what COM port your device was installed to. Single Digit COM port
designations require a “0” to be entered prior to the number (for a device installed to COM port 1 enter “01”).
Device ID consists of three parts: the COM port designation (COMxx), the hardware model number (715), and the
Baud Rate (115200). The default Baud Rate for that instrument is shown. If the Baud Rate of the device has changed
be sure to enter the current Baud Rate of the Device. See “Baud Rates” on page 7 for all the possible Baud Rates of
your device.
Example: If you have installed a DI-715B-U that has been designated to COM Port 11 and have never changed the
Baud Rate you would enter the following 3 lines to the daqdevs.txt file:
DI-715B-U
DI111NT.DLL
COM11 715 115200
Ethernet Devices
In Driver Name nn = the order in which the Ethernet device was installed (in comparison with other DI-715B
instruments). This number will be in the range of 70 to 99 and can be determined by running the device in WinDaq
Acquisition. The title bar in WinDaq Acquisition software will contain (from left to right): the Model Number of the
device; the word “Acquisition”; the 3 digit Driver Name number; and the Serial Number of the Device (see DI-710
Ethernet Devices on page 4 above).
The Device ID is the IP address of the instrument. If you are accessing the device over the internet you will also need
to enter the Port number designation.
Example: If you have installed a DI-715B-E to your local network and have determined the Device Driver number is
670 (by opening WinDaq Acquisition software) and the IP address is 192.168.1.5 you would enter the following 3
lines to the daqdevs.txt file:
DI-715B-E
DI670NT.DLL
192.168.1.5
DI-718B Series
Device Name(s) Driver Name Device ID
DI-715B-U
DI-715B-US
DI1xxNT.dll COMxx 715 115200
DI-715B-E
DI-715B-ES
DI6nnNT.dll IPaddress
or
IPaddress:Port
Device Name(s) Driver Name Device ID
DI-718B-U
DI-718B-US
DI1xxNT.dll COMxx 718 115200
DATAQ Instruments Matlab Adaptor
6 Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope
The Device Name must be entered exactly as shown in the above table.
USB Devices
In the Driver Name xx = the COM port designation. These USB devices use a “Virtual COM Port” for
communication. See“Finding the COM port designation or LPT number of your Printer Port, Serial Port, or Virtual
Serial Port Instrument” on page 8 to determine what COM port your device was installed to. Single Digit COM port
designations require a “0” to be entered prior to the number (for a device installed to COM port 1 enter “01”).
Device ID consists of three parts: the COM port designation (COMxx), the hardware model number (718), and the
Baud Rate (115200). The default Baud Rate for that instrument is shown. If the Baud Rate of the device has changed
be sure to enter the current Baud Rate of the Device. See “Baud Rates” on page 7 for all the possible Baud Rates of
your device.
Example: If you have installed a DI-718B-US that has been designated to COM Port 3 and have never changed the
Baud Rate you would enter the following 3 lines to the daqdevs.txt file:
DI-718B-US
DI103NT.DLL
COM03 718 115200
Ethernet Devices
In Driver Name nn = the order in which the Ethernet device was installed (in comparison with other DI-718B
instruments). This number will be in the range of 0 to 39 and can be determined by running the device in WinDaq
Acquisition. The title bar in WinDaq Acquisition software will contain (from left to right): the Model Number of the
device; the word “Acquisition”; the 3 digit Driver Name number; and the Serial Number of the Device (see DI-710
Ethernet Devices on page 4 above).
The Device ID is the IP address of the instrument. If you are accessing the device over the internet you will also need
to enter the Port number designation.
Example: If you have installed a DI-718B-E to your local network and have determined the Device Driver number is
600 (by opening WinDaq Acquisition software) and the IP address is 192.168.1.1 you would enter the following 3
lines to the daqdevs.txt file:
DI-718B-E
DI600NT.DLL
192.168.1.1
DI-720/730/740 Series
DI-718B-E
DI-718B-ES
DI6nnNT.dll IPaddress
or
IPaddress:Port
Device Name(s) Operating System Driver Name Device ID
DI-720-P
DI-730-P
DI-740-P
Win95/98 DI2s32.dll 0
WinNT/ME/2000/XP DI50nNT.dll n
DI-720-USB
DI-730-USB
DI-740-USB
Win95/NT N/A N/A
Win98/ME/200/XP DI72nNT.dll n
DI-720-EN
DI-730-EN
DI-740-EN
All DI80xNT.dll IPaddress
DATAQ Instruments Matlab Adaptor
Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 7
The Device Name must be entered exactly as shown in the above table.
Printer Port Devices
In Driver Name n = LPT port number the instrument was installed on. If you don’t know which Printer Port your
device has been installed to see “Finding the COM port designation or LPT number of your Printer Port, Serial Port,
or Virtual Serial Port Instrument” on page 8.
Example: If you have installed a DI-720-P to LPT 1 in Windows XP you would enter the following 3 lines to the
daqdevs.txt file:
DI-720-P
DI501NT.DLL
1
USB Devices
In Driver Name and Device ID n = the USB ID of the device. If you don’t know the USB ID of your device look in
the tpdataq.ini file (located in the Windows folder on your hard drive) for the Driver Name. The USB ID is
designated when installing multiple devices and increases by one starting with 0 (i.e., if you only installed one DI-
720/730/740 USB device your USB ID will be 0).
Example: If you have installed one DI-720-USB you would enter the following 3 lines to the daqdevs.txt file:
DI-720-USB
DI720NT.DLL
0
Ethernet Devices
In Driver Name n = the order of WinDaq/IP installation. Look in the tpdataq.ini file (located in the Windows folder
on your hard drive) for the correct Driver Name.
Example: If you have installed DI-720-EN at IP address 192.168.1.1 and, after determining the Driver Name from
tpdataq.ini is DI800NT.DLL, you would enter the following 3 lines to the daqdevs.txt file:
DI-720-EN
DI800NT.DLL
192.168.1.1
Baud Rates
This Table lists all the possible Baud Rates for each Serial Port (or Virtual Serial Port) instrument where Device ID
requires a Baud Rate.
Instruments Possible Baud Rates
DI-154RS, DI-194RS 2400, 4800, 9600
DI-148U, DI-158U, DI-158UP 4800, 9600, 19200, 38400, 57600,
115200, 230400, 460800, 921600
DI-710 USB Devices, DI-715B USB
Devices, DI-718B USB Devices
4800, 9600, 19200, 38400,
57600, 115200
DATAQ Instruments Matlab Adaptor
8 Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope
Finding the COM port designation or LPT number of your Printer Port, Serial Port,
or Virtual Serial Port Instrument
You must know the COM Port (serial devices or virtual serial devices) or LPT number (printer port devices) your
device has been installed to in order to use your device in MatLab.
1. Access the Device Manager utility in Windows.
2. Right-click on the My Computer icon.
3. Click on Properties.
4. Depending on which operating system you have:
a. Win98/ME - Click on the Device Manager Tab
b. Win2000/XP - Click on the Hardware Tab, then click on the Device Manager Option.
5. Find Ports (COM & LPT) and expand the list by clicking on the + box directly to the left. This shows all COM
and LPT ports currently assigned on your computer. Find your DATAQ device(s) in the list. The COM port num
-
ber or LPT number will be in parentheses immediately after the model name. For example DATAQ DI158-UP
(COM3) means your DI-158-UP instrument is intalled to COM port 3.
DATAQ Instruments Matlab Adaptor
Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 9
Common Errors
Sample Session
The following is a sample Matlab Session using the DATAQ Adaptor. Comments appear in Green. To learn more
about the MatLab Data Acquisition Toolbox commands, consult the MatLab Help documentation.
% Use daqhwinfo to display data acquisition hardware information. The following
line returns general information about the Data Acquisition Toolbox.
>> d=daqhwinfo
d =
ToolboxName: 'Data Acquisition Toolbox'
ToolboxVersion: '2.7 (R14SP3)'
MATLABVersion: '7.1 (R14SP3)'
InstalledAdaptors: {3x1 cell}
% Get a list of the Installed Adaptors. If the dataq.dll has been properly
registered it will show up as dataq in the adaptor list.
>> d.InstalledAdaptors
ans =
Error Probable Cause Resolution
The Device Name
has been entered
incorrectly into
daqdevs.txt.
Check the tables
above for the correct
Device Name and
enter it exactly as
shown.
DI-148 and DI-158
products have an
intermittent error
when attempting to
start if not using a
suggested Baud Rate
(see “DI-148 and DI-
158 products” on
page 2 for the sug-
gested Baud Rate).
Edit the daqdevs.txt
file (see “Editing the
daqdevs.txt file” on
page 1) with a sug-
gested Baud Rate
(see “DI-148 and DI-
158 products” on
page 2) and re-issue
the start command.
Most likely means
that the COM port is
not set up correctly
in the daqdevs.txt
file.
Check what COM
port your device is
connected to in the
Hardware Manager
and enter it correctly
in the daqdevs.txt
file.
DATAQ Instruments Matlab Adaptor
10 Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope
'dataq'
'parallel'
'winsound'
% Set d equal to hardware information about the dataq adaptor.
>> d=daqhwinfo('dataq')
d =
AdaptorDllName: 'C:\0.2.7.0\dataq.dll'
AdaptorDllVersion: '0.2.9.3'
AdaptorName: 'dataq'
BoardNames: {'DI-158-UP' 'DI-158-U' 'DI-710-EHS'}
InstalledBoardIds: {'0' '1' '2'}
ObjectConstructorName: {3x3 cell}
% Create the analog input object ai for dataqsdk adaptor. For this example
session, the hardware ID = 0 for the DI-158-UP, 1 for the DI-158-U, 2 for the
DI-710-EHS. Hardware ID’s are listed in the adaptor properties above -
BoardNames: {'DI-158-UP' 'DI-158-U' 'DI-710-EHS(42277E12)'},
InstalledBoardIds: {'0' '1' '2'}.
% The next line selects the DI-710-ELS device for analog input.
>> ai=analoginput('dataq',2)
Display Summary of Analog Input (AI) Object Using 'DI-710-EHS'.
Acquisition Parameters: 1000 samples per second on each channel.
1000 samples per trigger on each channel.
1 sec. of data to be logged upon START.
Log data to 'Memory' on trigger.
Trigger Parameters: 1 'Immediate' trigger(s) on START.
Engine status: Waiting for START.
0 samples acquired since starting.
0 samples available for GETDATA.
AI object contains no channels.
% Add a range of channels 1, 2, 3, 4 (0=1, 1=2, etc.)
>> addchannel(ai,0:3)
% Set the SampleRate.
>> set(ai,'SampleRate',240)
% Set the SamplesPerTrigger to Infinity, this will allow for continuous scanning
until the stop(ai) command is issued.
>> set(ai,'SamplesPerTrigger',Inf)
% Use the inspect command to change the analog input properties in the Property
Inspector
Index: ChannelName: HwChannel: InputRange: SensorRange: UnitsRange: Units:
1 'Phys. Chan. 1' 0 [-10 10] [-10 10] [-10 10] 'Volts'
2 'Phys. Chan. 2' 1 [-10 10] [-10 10] [-10 10] 'Volts'
3 'Phys. Chan. 3' 2 [-10 10] [-10 10] [-10 10] 'Volts'
4 'Phys. Chan. 4' 3 [-10 10] [-10 10] [-10 10] 'Volts'
DATAQ Instruments Matlab Adaptor
Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 11
>> inspect(ai)
% Look at the analog input object properties again to review your settings.
>> ai
Display Summary of Analog Input (AI) Object Using 'DI-710-EHS'.
Acquisition Parameters: 240 samples per second on each channel.
Continuous sampling on each channel.
Inf sec. of data to be logged upon START.
Log data to 'Memory' on trigger.
Trigger Parameters: 1 'Immediate' trigger(s) on START.
Engine status: Waiting for START.
0 samples acquired since starting.
0 samples available for GETDATA.
AI object contains channel(s):
% Start acquiring data
>> start(ai)
% Put acquired data into m-by-n matrix, where m rows = samples, and n columns =
number of channels. The next statement gets 100 samples of data returned in the
native data format of the device.
>> d=getdata(ai,100,'native')
Index: ChannelName: HwChannel: InputRange: SensorRange: UnitsRange: Units:
1 'Phys. Chan. 1' 0 [-10 10] [-10 10] [-10 10] 'Volts'
2 'Phys. Chan. 2' 1 [-10 10] [-10 10] [-10 10] 'Volts'
3 'Phys. Chan. 3' 2 [-10 10] [-10 10] [-10 10] 'Volts'
4 'Phys. Chan. 4' 3 [-10 10] [-10 10] [-10 10] 'Volts'
Product Links: Data Acquisition | Data Logger | Chart Recorder | Thermocouple | Oscilloscope 12
% NOTE: Currently you must use the ‘native’ data format for getdata.
% Convert the native data to Volts with the formula below.
% First you must convert the native data to a double:
>> d2 = double(d)
% Then convert to volts by multiplying the native data (in double format) by the
% full scale range (this example uses a +/- 10 volts full scale device), then
% divide by 32767
>> volts = (d2*10)/32767
% Plot the data and label the figure axes.
>> plot(volts)
>> xlabel('Samples')
>> ylabel('Signal (Volts)')
% Stop acquiring data.
>> stop(ai)
% Delete the analog input object.
>> delete(ai)
% Remove the object from the MATLAB workspace.
>> clear ai