I did this some time ago and wanted to share with anyone interested. Basically it’s a Matlab/Simulink model that analyzes the input from the soundcard line-in using a FFT block and writes its output to a text file in /tmp/fft.out.

The systems works very well on PCs (x86) and ARMs (tested on BeagleBoard and PandaBoard). I used Matlab/Simulink Embedded IDE Link to generate C code and compiled it for the mentioned architectures.

After running the binary automatically generated from Matlab the model, we simply have to access a PHP page (fft.php). In the BeagleBoard i used lighthttpd as webserver. This PHP program reads the file /tmp/fft.out and draws a graphic spectrum on the web browser, automatically refreshing it at each 1 second.

There is also some labels in the web page showing the frequencies computed by the FFT present in the signal at a given instant. The output is very precise. I’ll try to post a screenshot of the system running later.

PHP and model are attached.

The S-Function is as simple as:

FILE *fp;
int i;

fp = fopen(“/tmp/fft.out”, “w”);

for (i=0;i<=31;i++) {
//u0 is the input from simulink block
fprintf(fp, “%frn”, u0[i]);


Here is a screenshot of the system working with a 3.2Khz sinewave input connected to the audio line in:


PHP code source file + Simulink Model file (.mdl)

This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to WebSpectrum

  1. Henry Withs says:

    Hey Rafael,
    Did you compile this Simulink model using the Beagleboard-simulink support package?.
    You say the model is attached, where can I download it from?.

  2. Rafael Aroca says:

    Hi Henry,

    sorry for the delay. I edited the post and added a link to the source files. Hope it helps.

    And yes, I did use the BeagleBoard support package that can be downloaded from http://www.mathworks.com/academia/beagleboard/. Please note that it did not work on Matlab R2010a and 2011. I had to use specifically Matlab R2010b. To get this model running you’ll also need to have a cross compiler installed in the machine Matlab is installed and ALSA libs. By the way, this I compiled this model for several ARM boards, and it worked fine on mini2440 also on PandaBoard!

  3. Avadhut says:

    Hi Rafael,
    I tried to install that package on 2009b,2010a,2010b,2011a..But I did get following error

    ??? Error using ==> patch_installer>checkVersion at 588
    This patch is released for product(s) {Target Support Package}. The patch installer cannot locate
    required products in your installation of MATLAB.

    Error in ==> patch_installer>installPatch at 162

    Error in ==> patch_installer at 27
    [succes, fullInstallDir] = installPatch(zipFileName);

    Please let me know..What I need to do.

    • Rafael Aroca says:

      Strange, most problems I had when helping other people was with wrong Matlab version, which you have tested.

      According to your error message, some required Matlab component could be not installed in your system. You must have Simulink and RTW (Real Time Workshop) installed. If you have access to a full version of Matlab, I suggest trying to install all simulink options and toolboxes to check if the error goes way.

      Sorry for not helping much.

  4. Devanand says:

    Hi Rafael,
    Did you compile this Simulink model using the Beagleboard-simulink support package on windows as host? which cross compiler should I install on windows?
    >>patch_installer(‘patch_beagleboard_r2010b_v1_1.zip’, ‘install’)
    gives out error like below

    Backing-up files…
    [1] Backing up “C:\Program Files\MATLAB\R2010b\resources\ECLIPSEIDEEXT\en\util.xml”
    status: WARNING: Cannot backup file.
    Do you want to continue with the installation? [y/n]: n
    Removing temporary files…

    • Rafael Aroca says:


      I used Linux as host. I helped a friend with Windows, and you should know the path_beagleboard documentation explains that cross compiling in native windows is not possible. You could achieve that with generic code generation (GRT). The solution recommended for Windows hosts is using remote compiler option of this patch. Please, check the documentation.

      About your error, this patch relies on a Matlab toolbox called “IDELink”. Seems like you don’t have IDELink on your matlab install (is it a full install?). The error [1] looks like the ECLIPSE IDE LINK was not found.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s