Digital Signal Processing Reference
In-Depth Information
The added lines of code can be verified from the file rtdx _ vc _ sineDlg.cpp (on the
CD). Select Build (menu item from the main project window)
Æ
Rebuild All to
create the application (executable) file.
Example 9.8: Visual C
-DSK Interface Using RTDX with MATLAB
Functions for FFT and Plotting ( rtdx_vc_FFTmatlab )
++
This example illustrates real-time data communication using RTDX with Microsoft
Visual C
, invoking MATLAB's FFT and plotting functions. MATLAB is not used
in this example to provide the RTDX communication link between the PC and the
DSK, as in Examples 9.4-9.6. Instead, only the MATLAB's functions for FFT and
plotting are invoked.
The folder rtdx_vc_FFTmatlab contains the Visual C
++
support files, includ-
ing the application/executable file rtdx_vc_FFTmatlab.exe (already built). See
also Example 9.7.
++
Running Executable from CCS
The folder rtdx _ MatlabFFT for Example 9.5 includes the main C source program
(Figure 9.8) rtdx_MatlabFFT.c , which implements a loop program. It also
creates and enables an output channel to write/send data acquired from the DSK
to the PC. It illustrated RTDX with MATLAB in Example 9.5, and it can be used
in this example to illustrate this Microsoft Visual C
application. The ( .m )
MATLAB file that provides the RTDX communication link between the DSK and
the PC in Example 9.5 is not used in this example. Only, the MATLAB's FFT and
plotting functions are used.
Input into the DSK a 2-kHz sine wave with an approximate amplitude of 1 V
p-p. Within the CCS window, select Tools
++
Enable RTDX (check it).
Load and run rtdx_matlabFFT.out . The RTDX communication link is not yet
produced, and “waiting” is printed continuously within the CCS window.
Æ
RTDX
Æ
Running Visual C
++
Application
Run the Visual C
application rtdx_vc_FFTMatlab.exe located in the folder
rtdx _ vc _ FFTMatlab\debug (double-click on it).
Verify a loop program with the DSK output to a scope, and an FFT plot of the
2-kHz sine wave as shown in Figure 9.17, obtained using MATLAB's FFT and plot-
ting functions (see also Example 9.5). Change the input sine wave frequency to
3 kHz and verify that the MATLAB plots 3-kHz sine wave.
You can readily add the labels for the x and y axes in Figure 9.17 by modify-
ing the file rtdx_vc_FFTMatlabDlg.cpp . Find the section of code where
the MATLAB functions are invoked for FFT and plotting. After the line of
code for the figure's title, insert the appropriate xlabel and ylabel functions.
Launch Microsoft Visual C
++
. Select File and open the workspace ( .dsw ) file
located in the folder rtdx _ vc _ FFTmatlab . Select Build
++
Æ
Rebuild All to recreate a
Search WWH ::




Custom Search