Creation External Code DLL from MATLAB-code by TMC Compiler for using in LabView (TM)

Basic example 1:  2nd-order filter bode-plot viewer

The source of this example (tmc_labview_examples_0p99.zip) is available in subdirectories :

examples\NI_LabViewEx
examples\NI_LabViewDLLEx

of TMC Compiler installation

This example illustrates usage of TMC Compiler for creation an external code DLL from MATLAB-code by TMC Compiler for using in LabView (TM).
An example VI looks like this:

 
 
The block diagram is shown below:

 The external DLL FiltView.dll created by TMC Compiler exports a function with the following prototype:
 
void __stdcall FiltFreqResp(double w1,double d1,double w2,double d2, unsigned long NumFreqs, double* F,double* Mag,double *Ph);

The function accepts the filter parameters w1,d1,w2,d2, demanded number of frequencies in the plot and returns updated frequencies array F[], magnitudes array Mag[] and phases array Ph[].

The C-code for DLL is generated from files

\NI_LabViewDLLEx\Stubs\TestO.m
\NI_LabViewDLLEx\MatSRC\resp2nd.m

A wrapper file

\NI_LabViewDLLEx\Stubs\NI_DllEx.c

is manually written. It contains the call of TMC-style function
tmcTestO from this LabView-style function FiltFreqResp. It contains also TMC-runtime initialization. The DLL is build by MSVC and manually put in NI_LabViewEx\Libs directory.








 
 


 

No comments: