DSP FFT COMPONENT

For general Flowcode discussion that does not belong in the other sections.
DAVIDJOINER
Posts: 140
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

DSP FFT COMPONENT

Post by DAVIDJOINER »

Hi

I need to use the DSP FFT component in my current Project in FC9

I already can input from EB086 A/D put it through a DSP filter and display on a graph and also output to EB085 D/A thats fine

But i am having difficulty in taking the output from the filter feeding it into FFT and displaying the FFT on a separate graph

I ask this as unfortunately as the DSP functionality has significantly changed in FC9 versus FC8 and the Wiki example for FFT does therefore not now function so i cannot easily use the example to experiment and fully understand the detailed FFT operation to allow me to achieve the above

Can you update the WIKI FFT example or advise how to configure the DSP / FFT component to achieve the above

Best Regards
David

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 684 times

Re: DSP FFT COMPONENT

Post by BenR »

Hi David,

Yes good call I'm on with updating the example for you now.

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 684 times

Re: DSP FFT COMPONENT

Post by BenR »

Hi David,

We now have a new example up and running here.

https://www.flowcode.co.uk/wiki/index.p ... )#Examples

Please note I found a couple of minor bugs which have also now been fixed so you will need to use the Help -> Library Updates menu to get the latest component versions.

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

Re: DSP FFT COMPONENT

Post by DAVIDJOINER »

Hi Ben

Many thanks for the new example which is just what i wanted and in principle it appears to work adding the 2 sine waves together and will allow me to fully investigate and understand the FC9 FFT component operation

However as i was quickly testing it on just 1 sine wave it displays the peak where i expected

But i notice the amplitude varies significantly on each scan

I would have thought the amplitude peak would be the same on each scan as it is only doing a digital simulation and should therefore be identical on each scan

I have enclosed a copy of the 1 sine wave program

Any ideas

David
Attachments
DJ_FFT_Test_REV01 .fcfx
(29.52 KiB) Downloaded 588 times

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 684 times

Re: DSP FFT COMPONENT

Post by BenR »

Hi David,

Yes I see the problem. The FFT component currently requires that the input buffer hold all of the values or it to process. Currently it looks like only a single value is being loaded and hence the varying output.
BufferSize.png
BufferSize.png (10.12 KiB) Viewed 7329 times
With this set the value is now much more stable.

I might see if I can rejig things so you can pass a single value to the FFT at a time and it will do the FFT calculations once it gets enough values. This will reduce the RAM usage by a full buffer, in the case of the example by 256 * 2 bytes.

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

Re: DSP FFT COMPONENT

Post by DAVIDJOINER »

Hi Ben

Many thanks Ben I changed the generator to 256 and thats a lot better and is now usable for me to experiment with and move to next phase in my FC9 Project

1 But I still cannot quite understand why the amplitude and waveform still moves around a small bit as i presume the input wave is generated from a fixed LUT not a real signal and the rest of the calculations are fixed. Any ideas ?

2 I also checked each available generator wave form against the expected harmonic output and they all with the exception of the pulse waveform appear to be giving roughly the expected results with the limited tests i have carried out to date

Note i am using the book " Digital signal processing by Stehen W smith a practical guide for engineers and scientists" page 257 as a reference " which appears to be an excellent reference book for amature's like me in DSP

It does appear however that the pulse output is not giving any readable output through the FFT
i have looked at the wave data for the LUT for the component and all look to be zero's ??


David

stefan.erni
Valued Contributor
Posts: 997
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 190 times
Been thanked: 217 times

Re: DSP FFT COMPONENT

Post by stefan.erni »

Hi David

I found the book and the page... Thanks a lot

http://www.dspguide.com/

http://www.dspguide.com/CH13.PDF

regards

Stefan

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

Re: DSP FFT COMPONENT

Post by DAVIDJOINER »

Ben

Following on from my last email yesterday after doing more tests
I notice that the initial chart plot in the looks stable on its first run but if you leave it running thats when the variance in the amplitude and waveform profile becomes greater the longer you leave it running

Also if you stop the program and restart it , it carries on from the last chart display, you would think it would restart okay and then start drifting again

I even tried resetting the chart between restarts but still the same

Only if you totally reload the program into FC9 and start does it start from its initial stable reading before drifting again in time

Any ideas


Stefan

Glad you liked the book on DSP I referenced, and its free on line
(Note I even eventually bought the hard copy as well as i like to use it as a reference book)

David

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 684 times

Re: DSP FFT COMPONENT

Post by BenR »

Hello,

I've replicated the problem your were having where the results start to drift and think I have solved the issue. I've also added in the memory optimisation I mentioned previously and in doing so I have reworked the wiki example slightly.

The DSP component passing data to the FFT component now only needs to have a single buffer value and we now call the QueueData function until it returns true.

Latest example is also available here to save you searching for it.

FFT_Test.fcfx
(28.92 KiB) Downloaded 638 times

With these changes the output for me is now very stable which is much more what we should be expecting. I've also managed to fix a couple of compilation errors along the way so should be much better all round now.

Here's your latest ammended project file.

DJ_FFT_Test_REV01 .fcfx
(24.79 KiB) Downloaded 573 times

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

Re: DSP FFT COMPONENT

Post by DAVIDJOINER »

Hi Ben

Many thanks excellent service have tested using the sine wave waveform and now amplitude appears to be resolved so i can now start to use the component

One aspect however still surprises me a bit however using our revised DJ_FFT_Test_REV01 .fcfx
program the fundamental peak appears to spreads over around 8 FFT bins

Thats very wide i would have expected to be spread over much less in a computer simulation

Is that because of the simulation sine wave generation resolution (I notice currently 50 points) or internal FC9 calculations / formulas or resolutions

Or am I misunderstanding something

David

Post Reply