help,audio spectrum analyzer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

help,audio spectrum analyzer

Post by sonic11 »

Hello.

We need your help to make an audio spectrum analyzer using DSP.
I have enough knowledge to accomplish alone.
I intend to use dspic30f6012 and a 4x20 alphanumeric display oled.
I need some examples or documentation that could help me-r.


Thank you.

hyperion007
Posts: 528
Joined: Sat Dec 01, 2012 1:23 pm
Location: Sweden
Has thanked: 49 times
Been thanked: 101 times

Re: help,audio spectrum analyzer

Post by hyperion007 »

what kind of display is that? All I have found is a 2x16 oled

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: help,audio spectrum analyzer

Post by Benj »

Hello,

I will be doing an audio spectrum analyser example soon as part of the LED cube blog. Once this is done I will make sure that there is also a nice working example for the FFT component in the wiki but both of these will rely on the upcoming release of Flowcode to fix some problems currently existing in the FFT DSP component.

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

welcome

It is rec002004aypp5n0000 ws0010 driver, 4 lines and 20 characters
[urlhttp://octopart.com/rec002004aypp5n00000-raystar-30865142][/url]
Hello Benj.
You can put a link to that blog, mention that I have a lot of experience in programming and or what example I could use.

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

welcome

I have a question, how can I write on lcd custom character?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: help,audio spectrum analyzer

Post by Benj »

Hello,

Some info here that should help.
http://www.matrixmultimedia.com/mmforum ... =26&t=4796

This also might be applicable but based on a graphical LCD.
http://www.matrixmultimedia.com/mmforum ... =26&t=8142

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

It does not work that is posted in that thread, I changed and Fill LCDdispley.c that of topic and not working and not working any macro RAM_WRITE

I can give someone my tab correctly modified c


Here is the compiler error

VU-METER A LINIE.c (994:2): error: unknown identifier 'LCD_RAM_Write'
VU-METER A LINIE.c (994:2): error: failed to generated expression
VU-METER A LINIE.c (995:2): error: unknown identifier 'LCD_RAM_Write'
VU-METER A LINIE.c (995:2): error: failed to generated expression
VU-METER A LINIE.c (996:2): error: unknown identifier 'LCD_RAM_Write'
VU-METER A LINIE.c (996:2): error: failed to generated expression
VU-METER A LINIE.c (997:2): error: unknown identifier 'LCD_RAM_Write'
VU-METER A LINIE.c (997:2): error: failed to generated expression

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

Who wants to use LCD above REC002004 shall amend START LCD component values ​​below.

   RawSend (0x32, 0);
Wdt_Delay_Ms (2);
RawSend (0x28, 0);
Wdt_Delay_Ms (2);
RawSend (0x0C, 0);
Wdt_Delay_Ms (2);
RawSend (0x06, 0);
Wdt_Delay_Ms (2);
RawSend (0x02, 0);
Wdt_Delay_Ms (2);
RawSend (0x01, 0);
Wdt_Delay_Ms (2);

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

Hello

I need to help me with these two problems.
1 can print on custom LCD characters with ascii print macro
2 - How can I connect lcd in 8bit?

Please help me!

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: help,audio spectrum analyzer

Post by medelec35 »

Hi sonic11,
If you take a look at:
http://www.matrixmultimedia.com/mmforum ... 987#p51711
It shows a way to add custom characters which is compatible to V6
The values can be determined by scrolling to the top of the thread.

As for the 8bit LCD. Most LCDs can be 4 bit or 8bit.

If you really need 8 bit then I believe a custom component will require creating since the standard for flowcode is 4bit.
Perhaps you can request 8bit LCD here:
http://www.matrixmultimedia.com/mmforum ... m.php?f=56
There is a 4bit Adfruit OLED within flowcode V6

Sorry,
Apart from helping creating custom characters, I can't help you much more than that.

Maritn
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: help,audio spectrum analyzer

Post by medelec35 »

Hi sonic11,
If I am right, it looks like the controller for REC002004AYPP5N00000 is WS0010.
For datasheet see:
http://www.adafruit.com/datasheets/WS0010.pdf
Looking at the data sheet it can indeed be used in 4bit mode
So the existing oled used in Flowcode V6 may work?
The only issue is the oled in flowcode is 2x16 so that would pose a problem, I will see if there is a simple way around it or not?
It maybe worth wiring your LCD up in 4Bit mode, and sending some text to line 0 and giving it a try.
To connect in 4Bit mode the easiest way is to look at this datasheet:
http://www.matrixmultimedia.com/resourc ... 5-30-4.pdf
If you look at page 7, the connections should be the same as your OLED Display.

Martin
Martin

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

welcome medelec35

Do not connecting 4 bit is the problem, I have problems in connecting the 8 bit.
I need FC5_PIC_LCDDisplay.c file (for my friend's license) or modified file Flowcode v6 that I have it in demo.
I want a Connection Window 8bit mode for higher speed OLED
Point 1 is resolved, I was able to print out custom characters.

I see you have quite advanced knowledge.
Can you give me an example of a spectrum analizer alphanumeric LCD with DSP, FFT?
Not something complicated, something that I can start this proect
I thank you in advance

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: help,audio spectrum analyzer

Post by kersing »

For FFT with dsPic you might want to take a look at FFT Frequency Detection. It is written for FC5 and should provide a starting point.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

Hi everyone

I understand something there, but that article has no comments Flowcode not use DSP functions, FFT, ADC, all these functions are written ic C
I do not know the language C.
So I guess in Flowcode can not do that, than with C code sequences?
Suppose I derive from this example how can increment the custom characters?
For example,
100 Hz slider 0.3, 0.2, 0.1, 00
                       250Hz slider 1.3, 1.2, 1.1, 1.0
                       600Hz slider 2.3, 2.2, 2.1, 2.0
************************************************** *******************
                       20000Hz slider 20.3, 20.2, 20.1, 20.0

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

?????????????

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: help,audio spectrum analyzer

Post by kersing »

The only way to use the dsPICs DSP functions with flowcode 5 is by using C code. The Flowcode components do not use the DSP instructions of the controller. (Does not have to be a problem, but DSP instructions of the controller are faster)

However, all C code has been written, you just need to change the sample rate (properties of TMR3) and number of samples to determine the bucket size (see article for limits). After calling all the macros in the order listed in the example program the results can be found in the result array. Each element has the linear signal strength of that particular frequency range (bucket). (You might need to resize the result array, it should be at least half the number of samples)
When using a sample rate of 20kHz and 1024 samples each bucket will be 20000/1024 hertz wide, so 19,53Hz. (a sample rate of 20480 would result in nice 20Hz wide buckets).
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

here is fregventelor preselection? (look at the comment of attachment)
So 20000Hz (A frequent interruption tmr3) / 13 (token variable) = 1538Hz OK?
Then if TMR3 has A frequent interruption of 160000Hz / 8 = 20000Hz
is that correct?

So should I do fregventelor selection here

100Hz = 160000/1600
250Hz = 160000/640
600Hz = 160000/266
************************
20000 = 160000/8
?
How can inplementa this work?

Slider 100 Hz 0.3, 0.2, 0.1, 00
                        250Hz slider 1.3, 1.2, 1.1, 1.0
                        600Hz slider 2.3, 2.2, 2.1, 2.0
************************************************** *******************
                        20000Hz slider 20.3, 20.2, 20.1, 20.0
Attachments
FFT Frequency Detection on the dsPIC.fcf_pic16
(35.4 KiB) Downloaded 325 times

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

No one knows?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: help,audio spectrum analyzer

Post by kersing »

Someone knows, but is busy. Please do not expect us to respond instantly.

Have you done any research into FFT? Do you know how it should work? If not, please start there, you need to understand FFT for you project to succeed. FFT is not extremely complex, but too complex to expect things to work by simply changing example code (unless you are very lucky).

A couple of questions to help you get started:
- What is the upper limit of the frequencies to analyze.
- What size should the intervals be, 10Hz, 100Hz, 200Hz, 1kHz? (FFT uses frequency intervals, not specific frequencies. So 950-1050Hz is valid, 1000Hz not)
- What is are the characteristics of your input filter. Does is allow frequencies 0-1kHz, 0-10kHz, 0-20kHz.
- What is the clock for you dsPIC? (What is the crystal frequency and are you using PLL? Do you know how to program the oscillator circuit?)

Do you have a circuit diagram of your setup you can share?

I am not sure what
Slider 100 Hz 0.3, 0.2, 0.1, 00
250Hz slider 1.3, 1.2, 1.1, 1.0
600Hz slider 2.3, 2.2, 2.1, 2.0
************************************************** *******************
20000Hz slider 20.3, 20.2, 20.1, 20.0
means. Could you explain?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

I greet with respect.
 I want to run his machine spectrum analyzer 20 bands in the range 20 - 20000Hz , and bands will be possible in parts per 20,100 , 250, 400, 600, 800,900,1000,2000,3500,5000,7500,10000,11000,12500 , 14000 , 15000,16000,18000,20000 Hz
So I look at the final
http://hackaday.com/2011/09/08/spectrum ... 0-display/

Wondering how incremental custom characters vertically ( ie for 100Hz LCD will need to display a bar graph on the 4 vertical sliders and bit 0 ) 100 Hz 0.3 , 0.2, 0.1, 00
                        250Hz slider 1.3, 1.2 , 1.1, 1.0
                        600Hz slider 2.3, 2.2 , 2.1, 2.0
************************************************** *******************
                        20000Hz slider 20.3 , 20.2 , 20.1 , 20.0


I use DSpic30f3014 configuration : 10Mhz and PPLx4 ( 40MHz )
I have a project similar in which we want to inplementez the spectrum analyzer , but the rest of the commands will be displayed on the LCD and the other will be made ​​by another PIC
In conclusion I want to build a separate module that can display a spectrum analyzer and the drive of a button to display a gender stereo vu meter bargraph
LCD.
Attachments
INTERFATA AMPLIFICATOR.fcf
(49.37 KiB) Downloaded 253 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: help,audio spectrum analyzer

Post by kersing »

FFT is a linear process, so every band will be the same width. If you need different widths you will need to add adjacent bands to create one new value.

Given your frequency range of 0-20kHz you need to sample at 40kHz. Your controller has 8K RAM, for FFT every sample requires 4 bytes so the maximum number of samples is pobably 1024 (4K RAM for samples) as 2048 would require every byte, leaving no room for anything else. Sampling at 40kHz with 1024 samples provides 512 results with a width of nearly 40Hz. (sampling at 40960 would result in a nice 40Hz width). 20Hz can not be done.

In the example code you need to open the 'additional code' (in the project settings) and find a variable called something like SAMPLES, current value is 256, should become 1024. Next line variable is 8, should be changed to 10. Also size of result should be set to 512.
Next you need to set the controller type in the project settings and change the clock speed to 40000000 (you can type the value you need in this box). Next change the TMR3 settings so the frequency shown is as near to 40960 as possible.

Adjust the C code at the top of the main macro for your controller to use PLL if required.

In the main loop after ProcessFFT the result array has the energy values for each interval. So if there is as strong signal in the 0-40Hz range the value in result[0] will be large. The signal level in the 40-80Hz range will be in result[1]. If you need 120-200Hz to be one value, simply add result[3], result[4] and result[5]. The values for a certain signal level depend on your circuit. The values are linear, not logarithmic like a VU meter.
Make sure to filter the input signal to allow only 0-20kHz input and offset the level so no input is at 1/2 Vcc. (The article shows a simple solution for this using an opamp)

I can not help you with the graphics.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

I can not find this variable

"In the example code you need to open the 'additional code' (in the project settings) and find a variable called something like SAMPLES, current value is 256, should become 1024. Next line variable is 8, should be changed to 10."

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: help,audio spectrum analyzer

Post by kersing »

In the "Build" menu, choose "Project options", this will open this dialog:
options.jpg
options.jpg (41.99 KiB) Viewed 16016 times
Now click on the marked button, the next dialog will appear. in the upper window scroll down:
fft-adjust.JPG
fft-adjust.JPG (70.54 KiB) Viewed 16016 times
Adjust the SAMPLES line to have value 1024 and the L2SAMPLES to 10.

Click "OK" to save. Adjust the "Clock speed (Hz)" to 40000000. Choose TAB "Choose a Target" to select the correct target device.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

sonic11
Posts: 35
Joined: Tue Jan 21, 2014 10:04 pm
Has thanked: 7 times
Been thanked: 1 time

Re: help,audio spectrum analyzer

Post by sonic11 »

Please producers of this program (Flowcode) to show how the component can connect 8bit LCD.

I consider this a bug, it is not normal for a software of this size can not connect to LCD in 8bit mode!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: help,audio spectrum analyzer

Post by Benj »

Hello,

There is currently no way to use 8-bit data mode when talking to the LCD, not a bug just not currently supported. The only real advantage is a slight speed boost at the cost of 4 I/O pins. I'll add it to the list.

Post Reply