DSPRelated.com
Forums

I need some advice ( using matlab with DSP )

Started by gavi...@gmail.com November 25, 2007
Hi all,

I am a newbie to DSP and I am currently designing a fingerprint recognition system using DSK c6416. I need to ask a few questions to make sure that I am not on the wrong way.

I had a m-file fingerprint recognition code.

1) Is that possible for me to execute the m-file directly on the DSP ?
2) If so, any suggestion for me ? what am I suppose to learn/do ?
3) Do I need extra softwares ? ( maybe, a m-file to C compiler )

Thanks for helping.

Best regards,
Huat
Hi,

I am not sure of any arbitrary m-file to C compiler. You can use Realtime Workshop to produce some C code for some DSP targets for level-2 m-files (not the normal one) but the result is not very promising because of so much garbage code it produces. In addition you need to buy Realtime Workshop which I do not suggest, because for performance issues you end up writing redundant codes as TLC functions (and C again) with so much details and tricks and debugging and time. However, if you have Realtime Workshop you can compile the Level-2 m-file to C file as the starting point for your project (to be refined).
I have another solution for you as well, try hand-converting the m-files to C functions while compiling the functions as individual MEX functions and testing the MEX functions along with the rest of your code (in MATLAB) to see if the individual function is working fine. Nothing is better than writing C codes from scratch to have a clean and readable code.

Regards,
Ehsan
http://www.ece.utah.edu/~azarnasa/

g...@gmail.com wrote: Hi all,

I am a newbie to DSP and I am currently designing a fingerprint recognition system using DSK c6416. I need to ask a few questions to make sure that I am not on the wrong way.

I had a m-file fingerprint recognition code.

1) Is that possible for me to execute the m-file directly on the DSP ?
2) If so, any suggestion for me ? what am I suppose to learn/do ?
3) Do I need extra softwares ? ( maybe, a m-file to C compiler )

Thanks for helping.

Best regards,
Huat
Thanks again.

I found some webinars from mathworks for embedded matlab. Just as you
mentioned, there are many restriction. I think I will have to take a couple
of days to understand the concept of RTDX and embedded matlab. May I ask
more questions when I get stucked ? Thank you so much.

Best regards,
Huat
Hi,
I think you should find more in the appropriate news-group, here most of the stuff is about C6x exclusively.
The way Level-1 mfile works is Realtime Workshop in conjunction with Simulink and yes with user defined blocks. But this m-file is very limited. It is called Embedded MATLAB Function in Simulink and here is an example for 4QAM modulator:
Many restrictions apply: those that basically let MATLAB be compiled using reduction of dynamic assignments and so on. So at the end it is better to write in pure C ;)
--------------------
function y = fcn(u)
% This block supports an embeddable subset of the MATLAB language.
% See the help menu for details.

%the average energy per symbol is 1
fxRealOne = uint32(23170) ; % real Q15 fixed +1/sqrt(2)
fxRealNone = uint32(23170+32768); % real Q15 fixed -1/sqrt(2)

fxImOne = uint32(23170 * 65536) ; % imaginary Q15 fixed +1/sqrt(2)
fxImNone = uint32((23170+32768) * 65536) ; % imaginary Q15 fixed -1/sqrt(2)

%1+i -> fxRealOne + fxImOne

% modulation
fix_mod =[fxRealOne + fxImOne ;fxRealNone+fxImOne;
fxRealOne + fxImNone;fxRealNone+fxImNone]; %Gray coding

% index
ind = [bitshift(bitand(uint8(u),3*64),-6);
bitshift(bitand(uint8(u),3*16),-4);
bitshift(bitand(uint8(u),3*4 ),-2);
bitshift(bitand(uint8(u),3*1 ), 0)];

y = fix_mod(ind+1);

Ngan Huat wrote: Thank you all for the useful advices. I appreciate it.

I cant locate the RTDX in matlab start menu. Is "link for ccs" same as "rtdx link" ?

Well, I found a RTDX topic in www.mathworks.com . But, it seems only simulink models is available for linking. Am I right ? What I have now is a m-file fingerprint recognition algorithm from my senior. If that is true, is that possible to convert the m-file into simulink blocks by "user defined functions" ?

Can Simulink handles any function defined by user ? Any restriction ?
Thank you all for the useful advices. I appreciate it.

I cant locate the RTDX in matlab start menu. Is "link for ccs" same as "rtdx
link" ?

Well, I found a RTDX topic in www.mathworks.com . But, it seems only
simulink models is available for linking. Am I right ? What I have now is a
m-file fingerprint recognition algorithm from my senior. If that is true, is
that possible to convert the m-file into simulink blocks by "user defined
functions" ?

Can Simulink handles any function defined by user ? Any restriction ?