All TiePie engineering measuring instruments can work in close collaboration with MathWorks Matlab software. This provides the possibility to perform instant processing on the acquired data, rather than first storing the measurements to disk, import them in Matlab and finally do your calculations.
Earlier versions of Matlab required the use of .MEX files to be able to use the DLL's supplied with the measuring instruments, but Matlab 6.5.1 and higher are able to use the DLL's directly. You can find the DLL for your measuring instrument on the download page of your instrument in the download section of this website.
A Matlab example script is available to show how TiePie USB oscilloscopes can be controlled from Matlab.
To install the DLL for use with Matlab, make a directory on any hard drive, for example
c:\tiepie.
Make sure not to include spaces in the path, because some Matlab scripts cannot handle
that.
Copy the DLL (eg. HS3.dll) and the file TiePie.h that comes with it to the
directory that was just created.
If the DLL comes with .hex files, make sure to copy them to the same directory as the DLL.
Also copy the example scripts (.m files) to the same directory as the DLL.
To execute the example script, set the current directory in Matlab to the directory where the .m file is located. You can do this by executing 'cd ' followed by the path where you copied the DLL to in the command window of Matlab:
cd c:\tiepie
Before executing the script, set the DLL file name to the name of the DLL you want to use. By default, HS805.dll is used. For example, to use it with the Handyscope HS3, execute:
sDLL = 'HS3'
To run the example script, execute:
TPMeasure
The sample file is now executed: all channels are enabled, a measurement is performed and the measured data is shown in two figures. The first figure shows the measured data of all channels in the time domain and the second shows the frequency spectrum of all channels, calculated with the Matlab fft command. See the picture below for the result of a measurement performed with a TiePieSCOPE HS805.
Matlab measuring example with a TiePieSCOPE HS805.
When performing streaming measurements with a TiePie engineering instrument, the instrument DLL uses a callback function to notify the application that new data is available. Matlab does not support callback functions, but does support COM events. A universal callback to COM event adapter is available to enable performing streaming measurements in Matlab.
In order to use the callback adapter in Matlab, the tiepie.h file that comes with the instrument DLL needs a slight modification. Matlab cannot pass a pointer to a DLL, therefore the parameter in the DLL function SetDataReadyCallback() needs to be changed from pointer to DWORD. The original declaration in the tiepie.h file needs to be changed to:
#ifdef TP_TYPEDEFS
typedef word (WINAPI * LPFN_SetDataReadyCallback) ( dword dwAddress );
#ifndef TP_NOSTATICIMPORT
extern LPFN_SetDataReadyCallback SetDataReadyCallback;
#endif
#else
TP_EXTERN( word ) SetDataReadyCallback( dword dwAddress );
#endif
Matlab streaming example scripts are available to show how TiePie USB oscilloscopes can perform streaming measurements in Matlab using the callback adapter.