Sign in

username:

password:



Not a member?

Search msp430



Search tips

Subscribe to msp430



Ads

Discussion Groups

Discussion Groups | MSP430 | More about FFT

The purpose of this group is to foster exchange of information on the Texas Instruments MSP430 family of microcontrollers and related tools. Everyone welcome, all levels of familiarity/expertise.

More about FFT - "keller.lima" - Sep 10 7:39:45 2008


Hi friend, Hi Onestone ...

Can you help again?

I understand the Onestone explanation about FFT output. Now I
would like to understand more about the input. I know that the input
of the FFT algorithm is a complex signal with the real values (R) and
imaginary values (Q).
The signal that I want to apply the FFT is a AD output and has
only the real values.
How I transform this signal in complex number for aplly in FFT?

Onestone: can you help me?

Thank you,

KAL
------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )


Re: More about FFT - p_murayama - Sep 10 7:45:39 2008

Hello!

Q: What is a real number?
A: It's a complex numher, the imaginary part of which is 0.

Conclusion: enter your real signal as an input array, and
enter nothing (or make sure that the imaginary array is 0).

Pascal

--- In m...@yahoogroups.com, "keller.lima" wrote:
> Hi friend, Hi Onestone ...
>
> Can you help again?
>
> I understand the Onestone explanation about FFT output. Now I
> would like to understand more about the input. I know that the input
> of the FFT algorithm is a complex signal with the real values (R) and
> imaginary values (Q).
> The signal that I want to apply the FFT is a AD output and has
> only the real values.
> How I transform this signal in complex number for aplly in FFT?
>
> Onestone: can you help me?
>
> Thank you,
>
> KAL
>

------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: More about FFT - Onestone - Sep 10 8:15:38 2008

As pascal points out the input to the FFt contains complex data, whose
imaginary part is 0. Similarly, and i tried to avoid getting overly
complex in my last post, the output contans real and imaginary
components to both the phase and amplitude data, but for most simple FFt
purposes the imaginary part can simply be ignored in both the input and
the output data. Run the FFT in reverse on the REAl amplitude and phase
data and you will see the REAL input data, or VERy close to it.

Now the simple brute force form of an FFT is very simple to implement,
and very simple to understand. it is a pair of nested loops each as long
as the number of FFT 'taps'. Of course there are optimised variations,
of which the RADIX 2 is perhaps the most commonly used, but for simple
understanding the brute fore method works very well indeed, and allows
you to experiment quite freely with the variables.

INput data is a real sampled analog signal of any complexity. Tha data
must be sampled at a pre-determined time interval. The sample rate
should be at least twice the required bandwidth of the incoming data
(for the reasons you will need to study Nyquist). below is some
extremely crude brute force FFT code with standard and inverse FFT. This
is just the two base functions there are glaringly obvious places where
this code could be streamlined, but it is over 20 years old, and the
code I used to learn and understand the way the FFT worked, so you get
it as is. as you can see the code is deceptively simple. Surround this
with a quick and dirty graphing routine and you can asily experiment
with sign al analysis. deconstryuct the signal and display the phase and
amplitude array results as a bar graph, try different graphs, display
the original signal as a raw waveform, then reconstruct it and view the
results. Then play with just reconstructing using a few selected 'tap'
results. Hint do NOT use 0 for unselected taps, just skip them.

using this I developed many analysers including various forms of
logarithmic analysis. The variable 'gap'ooks like it may have been used
as a chordic analyser of some kind, or most probably given the era it
was an octave based model of the human ear, so this sould probably be
set to 1.

Cheers

Al

void ifft(double freq)
{
double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
char c;
for(indx = 0;indx < 512;indx++)
{
temp = 0;
for(index = 0;index < 512;index++)
{
G = wave * indx * index / N;
temp = temp + dfft[2][index] * cos(G) - dfft[3][index] * sin(G);
}
reduce[6][indx] = (int)temp/ N;
c = 0;
}
}

void fft(double freq)
{
double real = 0,two = 2,imag = 0,point,rfreq = (double)freq,sam =
512,ing;
int indx;
for(ing = 0;ing < 512;ing++)
{
real = imag = 0;
for(indx = 0;indx < 512;indx++)
{
point = wave * ing * (double)indx/sam;
real += (double)(reduce[0][indx]) * cos(point);
imag -= (double)(reduce[0][indx]) * sin(point);
}
dfft[0][ing] = sqrt(imag*imag + real*real);
dfft[1][ing] = atan(imag/real);
dfft[2][ing] = real;
dfft[3][ing] = imag;
}
}

keller.lima wrote:

>Hi friend, Hi Onestone ...
>
> Can you help again?
>
> I understand the Onestone explanation about FFT output. Now I
>would like to understand more about the input. I know that the input
>of the FFT algorithm is a complex signal with the real values (R) and
>imaginary values (Q).
> The signal that I want to apply the FFT is a AD output and has
>only the real values.
> How I transform this signal in complex number for aplly in FFT?
>
> Onestone: can you help me?
>
>Thank you,
>
>KAL
>------------------------------------



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: More about FFT - "keller.lima" - Sep 11 0:23:21 2008

Thank you very much

You always helped me as much.

Sorry but I have another question. There is a problem if I work with
ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
between 450KHz and 6MHZ. It is true?

I need sampled 2 seconds of a signal with a sampling rate very low,
approximately 30Hz. It's possible? Can I put a cristral often very
low, like 1KHz in LFXT1CLK?

Thanks, thanks, thanks....

KAL

--- In m...@yahoogroups.com, Onestone wrote:
>
> As pascal points out the input to the FFt contains complex data,
whose
> imaginary part is 0. Similarly, and i tried to avoid getting overly
> complex in my last post, the output contans real and imaginary
> components to both the phase and amplitude data, but for most
simple FFt
> purposes the imaginary part can simply be ignored in both the input
and
> the output data. Run the FFT in reverse on the REAl amplitude and
phase
> data and you will see the REAL input data, or VERy close to it.
>
> Now the simple brute force form of an FFT is very simple to
implement,
> and very simple to understand. it is a pair of nested loops each as
long
> as the number of FFT 'taps'. Of course there are optimised
variations,
> of which the RADIX 2 is perhaps the most commonly used, but for
simple
> understanding the brute fore method works very well indeed, and
allows
> you to experiment quite freely with the variables.
>
> INput data is a real sampled analog signal of any complexity. Tha
data
> must be sampled at a pre-determined time interval. The sample rate
> should be at least twice the required bandwidth of the incoming
data
> (for the reasons you will need to study Nyquist). below is some
> extremely crude brute force FFT code with standard and inverse FFT.
This
> is just the two base functions there are glaringly obvious places
where
> this code could be streamlined, but it is over 20 years old, and
the
> code I used to learn and understand the way the FFT worked, so you
get
> it as is. as you can see the code is deceptively simple. Surround
this
> with a quick and dirty graphing routine and you can asily
experiment
> with sign al analysis. deconstryuct the signal and display the
phase and
> amplitude array results as a bar graph, try different graphs,
display
> the original signal as a raw waveform, then reconstruct it and
view the
> results. Then play with just reconstructing using a few
selected 'tap'
> results. Hint do NOT use 0 for unselected taps, just skip them.
>
> using this I developed many analysers including various forms of
> logarithmic analysis. The variable 'gap'ooks like it may have been
used
> as a chordic analyser of some kind, or most probably given the era
it
> was an octave based model of the human ear, so this sould probably
be
> set to 1.
>
> Cheers
>
> Al
>
> void ifft(double freq)
> {
> double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
> char c;
> for(indx = 0;indx < 512;indx++)
> {
> temp = 0;
> for(index = 0;index < 512;index++)
> {
> G = wave * indx * index / N;
> temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
* sin(G);
> }
> reduce[6][indx] = (int)temp/ N;
> c = 0;
> }
> }
>
> void fft(double freq)
> {
> double real = 0,two = 2,imag = 0,point,rfreq = (double)
freq,sam =
> 512,ing;
> int indx;
> for(ing = 0;ing < 512;ing++)
> {
> real = imag = 0;
> for(indx = 0;indx < 512;indx++)
> {
> point = wave * ing * (double)indx/sam;
> real += (double)(reduce[0][indx]) * cos(point);
> imag -= (double)(reduce[0][indx]) * sin(point);
> }
> dfft[0][ing] = sqrt(imag*imag + real*real);
> dfft[1][ing] = atan(imag/real);
> dfft[2][ing] = real;
> dfft[3][ing] = imag;
> }
> }
>
> keller.lima wrote:
>
> >Hi friend, Hi Onestone ...
> >
> > Can you help again?
> >
> > I understand the Onestone explanation about FFT output. Now I
> >would like to understand more about the input. I know that the
input
> >of the FFT algorithm is a complex signal with the real values (R)
and
> >imaginary values (Q).
> > The signal that I want to apply the FFT is a AD output and
has
> >only the real values.
> > How I transform this signal in complex number for aplly in
FFT?
> >
> > Onestone: can you help me?
> >
> >Thank you,
> >
> >KAL
> >
> >
> >------------------------------------
> >
> >
> >
> >



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RES: Re: More about FFT - Augusto Einsfeldt - Sep 11 0:39:52 2008

You can still use the high frequency clock to make ADC samples and another
interrupt service to collect one of these conversions at each time.

So, you can have a 30Hz interrupt using Timer_A, for instance, and on every
interrupt read the last conversion from ADC12.

I never tried slow ADC12 clock and since I do not have the data sheet here
cannot even check if it is possible. Slow conversion can be a problem in SAR
ADCs since it uses switch capacitors (very small ones) and leakage could
result in errors if every SAR step takes too long.

So, if you need lower frequencies for sampling use a simple timer interrupt
to know when you can get the ADC result and keep the ADC sampling free run
with its own ADC12OSC clock.

-Augusto

-----Mensagem original-----
De: m...@yahoogroups.com [mailto:m...@yahoogroups.com] Em nome de
keller.lima
Enviada em: quinta-feira, 11 de setembro de 2008 01:23
Para: m...@yahoogroups.com
Assunto: [msp430] Re: More about FFT

Thank you very much

You always helped me as much.

Sorry but I have another question. There is a problem if I work with
ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
between 450KHz and 6MHZ. It is true?

I need sampled 2 seconds of a signal with a sampling rate very low,
approximately 30Hz. It's possible? Can I put a cristral often very
low, like 1KHz in LFXT1CLK?

Thanks, thanks, thanks....

KAL

--- In msp430@yahoogroups. com, Onestone
wrote:
>
> As pascal points out the input to the FFt contains complex data,
whose
> imaginary part is 0. Similarly, and i tried to avoid getting overly
> complex in my last post, the output contans real and imaginary
> components to both the phase and amplitude data, but for most
simple FFt
> purposes the imaginary part can simply be ignored in both the input
and
> the output data. Run the FFT in reverse on the REAl amplitude and
phase
> data and you will see the REAL input data, or VERy close to it.
>
> Now the simple brute force form of an FFT is very simple to
implement,
> and very simple to understand. it is a pair of nested loops each as
long
> as the number of FFT 'taps'. Of course there are optimised
variations,
> of which the RADIX 2 is perhaps the most commonly used, but for
simple
> understanding the brute fore method works very well indeed, and
allows
> you to experiment quite freely with the variables.
>
> INput data is a real sampled analog signal of any complexity. Tha
data
> must be sampled at a pre-determined time interval. The sample rate
> should be at least twice the required bandwidth of the incoming
data
> (for the reasons you will need to study Nyquist). below is some
> extremely crude brute force FFT code with standard and inverse FFT.
This
> is just the two base functions there are glaringly obvious places
where
> this code could be streamlined, but it is over 20 years old, and
the
> code I used to learn and understand the way the FFT worked, so you
get
> it as is. as you can see the code is deceptively simple. Surround
this
> with a quick and dirty graphing routine and you can asily
experiment
> with sign al analysis. deconstryuct the signal and display the
phase and
> amplitude array results as a bar graph, try different graphs,
display
> the original signal as a raw waveform, then reconstruct it and
view the
> results. Then play with just reconstructing using a few
selected 'tap'
> results. Hint do NOT use 0 for unselected taps, just skip them.
>
> using this I developed many analysers including various forms of
> logarithmic analysis. The variable 'gap'ooks like it may have been
used
> as a chordic analyser of some kind, or most probably given the era
it
> was an octave based model of the human ear, so this sould probably
be
> set to 1.
>
> Cheers
>
> Al
>
> void ifft(double freq)
> {
> double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
> char c;
> for(indx = 0;indx < 512;indx++)
> {
> temp = 0;
> for(index = 0;index < 512;index++)
> {
> G = wave * indx * index / N;
> temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
* sin(G);
> }
> reduce[6][indx] = (int)temp/ N;
> c = 0;
> }
> }
>
> void fft(double freq)
> {
> double real = 0,two = 2,imag = 0,point,rfreq = (double)
freq,sam =
> 512,ing;
> int indx;
> for(ing = 0;ing < 512;ing++)
> {
> real = imag = 0;
> for(indx = 0;indx < 512;indx++)
> {
> point = wave * ing * (double)indx/sam;
> real += (double)(reduce[0][indx]) * cos(point);
> imag -= (double)(reduce[0][indx]) * sin(point);
> }
> dfft[0][ing] = sqrt(imag*imag + real*real);
> dfft[1][ing] = atan(imag/real);
> dfft[2][ing] = real;
> dfft[3][ing] = imag;
> }
> }
>
> keller.lima wrote:
>
> >Hi friend, Hi Onestone ...
> >
> > Can you help again?
> >
> > I understand the Onestone explanation about FFT output. Now I
> >would like to understand more about the input. I know that the
input
> >of the FFT algorithm is a complex signal with the real values (R)
and
> >imaginary values (Q).
> > The signal that I want to apply the FFT is a AD output and
has
> >only the real values.
> > How I transform this signal in complex number for aplly in
FFT?
> >
> > Onestone: can you help me?
> >
> >Thank you,
> >
> >KAL
> >
> >
> >------------------------------------
> >
> >> egroups.com
> >
> >



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: Re: More about FFT - Onestone - Sep 11 3:58:08 2008

There is really almost nothing to be gained from running from such a
slow crystal, your CPU will simply not handle things. What MOST people,
incluidng my self do, is use a 32.768kHz watch crystal. this is very low
current. Then you can schedule sampling based on this. use the built in
ADC oscillator, but you can turn this on and off at such low sample
rates. You will alsmost certainly find problems running the ADC12 that
slowly. It relies on an internal sample and hold circuit which stores
the sample ina capacitor. if not sampled quickly enough the chage on
this will 'bleed away'.

if you are concenred about power consumption, most people here will tel
you that low power is all about duty cycle. If you have a long duty
cycle, like 1000:1 or more then your peak current has a very slight
effect on your mean curren.

to sample as you wish you would typically set up a timer to trigger the
sample, so every 33msecs (about) your timer would cause the miro to take
a sample. this is such a slow rate that you can quite possibly disable
the ADC12 while waiting. 33msecs is about 1100 ticks of the watch crystal
Then your timer starts a sample which takes around 13 clock IIRC, plus
any settle time if it was turned off, plus your allowed sample peiord,
which I would typically set to 4 or 8 clock ticks (set with SHT0 and
SHt1), so basically 21 clock cycles, at say 5Mhz of the ADC12 basic
clock. The 2616 for example has an internal reference settling time of
just 17msecs, and an ADC12 turn on to settle time of 100nS, and a quoted
sample time of 1220 nsecs, or jusy 1.22usecs. This differs slightly form
the older spec for sampling, so conversion is 13 clocks plus 17 msecs
turn on, plus 100nsecs settle, plus 1.22usecs sample, in total, at 5MHz
the entire sample requires just 17.5msecs. or less than 1 watch crystal
clock tick. so at 1081 clocks between samples, and 1 required to take th
sample and convert it, you have a 1080:1 active/sleep ratio, pretty
damned fast! now kets say you draw 5uA in sleep mode, the ADC draws
1.3mA at 5MHz, and using the CPu on the calibrated DCO frequencies draws
is given as 515uA. so adding that up we get about 1.8mA for 1 clock
tick, lets call that 2mA to be generous. then we get 5uA for 1080 clock
ticks, so our mena current is given by ((1080 x 5) + 2000)/1081 = 6.8uA.
as you can see the AD convrsion contributes a small amount at this
sample rate.

Cheers

Al

keller.lima wrote:

> Thank you very much
>
>You always helped me as much.
>
>Sorry but I have another question. There is a problem if I work with
>ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
>between 450KHz and 6MHZ. It is true?
>
>I need sampled 2 seconds of a signal with a sampling rate very low,
>approximately 30Hz. It's possible? Can I put a cristral often very
>low, like 1KHz in LFXT1CLK?
>
>Thanks, thanks, thanks....
>
>KAL
>
>--- In m...@yahoogroups.com, Onestone wrote:
>
>
>>As pascal points out the input to the FFt contains complex data,
>>
>>
>whose
>
>
>>imaginary part is 0. Similarly, and i tried to avoid getting overly
>>complex in my last post, the output contans real and imaginary
>>components to both the phase and amplitude data, but for most
>>
>>
>simple FFt
>
>
>>purposes the imaginary part can simply be ignored in both the input
>>
>>
>and
>
>
>>the output data. Run the FFT in reverse on the REAl amplitude and
>>
>>
>phase
>
>
>>data and you will see the REAL input data, or VERy close to it.
>>
>>Now the simple brute force form of an FFT is very simple to
>>
>>
>implement,
>
>
>>and very simple to understand. it is a pair of nested loops each as
>>
>>
>long
>
>
>>as the number of FFT 'taps'. Of course there are optimised
>>
>>
>variations,
>
>
>>of which the RADIX 2 is perhaps the most commonly used, but for
>>
>>
>simple
>
>
>>understanding the brute fore method works very well indeed, and
>>
>>
>allows
>
>
>>you to experiment quite freely with the variables.
>>
>>INput data is a real sampled analog signal of any complexity. Tha
>>
>>
>data
>
>
>>must be sampled at a pre-determined time interval. The sample rate
>>should be at least twice the required bandwidth of the incoming
>>
>>
>data
>
>
>>(for the reasons you will need to study Nyquist). below is some
>>extremely crude brute force FFT code with standard and inverse FFT.
>>
>>
>This
>
>
>>is just the two base functions there are glaringly obvious places
>>
>>
>where
>
>
>>this code could be streamlined, but it is over 20 years old, and
>>
>>
>the
>
>
>>code I used to learn and understand the way the FFT worked, so you
>>
>>
>get
>
>
>>it as is. as you can see the code is deceptively simple. Surround
>>
>>
>this
>
>
>>with a quick and dirty graphing routine and you can asily
>>
>>
>experiment
>
>
>>with sign al analysis. deconstryuct the signal and display the
>>
>>
>phase and
>
>
>>amplitude array results as a bar graph, try different graphs,
>>
>>
>display
>
>
>>the original signal as a raw waveform, then reconstruct it and
>>
>>
>view the
>
>
>>results. Then play with just reconstructing using a few
>>
>>
>selected 'tap'
>
>
>>results. Hint do NOT use 0 for unselected taps, just skip them.
>>
>>using this I developed many analysers including various forms of
>>logarithmic analysis. The variable 'gap'ooks like it may have been
>>
>>
>used
>
>
>>as a chordic analyser of some kind, or most probably given the era
>>
>>
>it
>
>
>>was an octave based model of the human ear, so this sould probably
>>
>>
>be
>
>
>>set to 1.
>>
>>Cheers
>>
>>Al
>>
>>void ifft(double freq)
>>{
>> double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
>> char c;
>> for(indx = 0;indx < 512;indx++)
>> {
>> temp = 0;
>> for(index = 0;index < 512;index++)
>> {
>> G = wave * indx * index / N;
>> temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
>>
>>
>* sin(G);
>
>
>> }
>> reduce[6][indx] = (int)temp/ N;
>> c = 0;
>> }
>>}
>>
>>void fft(double freq)
>>{
>> double real = 0,two = 2,imag = 0,point,rfreq = (double)
>>
>>
>freq,sam =
>
>
>>512,ing;
>> int indx;
>> for(ing = 0;ing < 512;ing++)
>> {
>> real = imag = 0;
>> for(indx = 0;indx < 512;indx++)
>> {
>> point = wave * ing * (double)indx/sam;
>> real += (double)(reduce[0][indx]) * cos(point);
>> imag -= (double)(reduce[0][indx]) * sin(point);
>> }
>> dfft[0][ing] = sqrt(imag*imag + real*real);
>> dfft[1][ing] = atan(imag/real);
>> dfft[2][ing] = real;
>> dfft[3][ing] = imag;
>> }
>>}
>>
>>keller.lima wrote:
>>
>>
>>
>>>Hi friend, Hi Onestone ...
>>>
>>> Can you help again?
>>>
>>> I understand the Onestone explanation about FFT output. Now I
>>>would like to understand more about the input. I know that the
>>>
>>>
>input
>
>
>>>of the FFT algorithm is a complex signal with the real values (R)
>>>
>>>
>and
>
>
>>>imaginary values (Q).
>>> The signal that I want to apply the FFT is a AD output and
>>>
>>>
>has
>
>
>>>only the real values.
>>> How I transform this signal in complex number for aplly in
>>>
>>>
>FFT?
>
>
>>> Onestone: can you help me?
>>>
>>>Thank you,
>>>
>>>KAL
>>>
>>>
>>>------------------------------------
>>>
>>>
>>>
>>>



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RES: Re: More about FFT - Augusto Einsfeldt - Sep 11 9:36:35 2008

Al, I guess Keller would like to measure harmonics in audio (typically
should be 8KHz sample instead of 4KHz) and/or in public power rail (in
Brasil it is 60Hz, so the minimum sample rate should be 120Hz, not 30Hz).
Otherwise he wants to detect harmonics in a vibrating system (like in a slow
machine) but this 30Hz he mentioned seems more like he inverted the notion
of Niquist requirements.

At 120Hz sample rate the best low power solution for most of MSPs would be
to keep the reference voltage on between sleep phases. Another possibility
(I never tried) would use the external refV capacitor (usually 10uF) to help
speedup the reference generator. I guess it is directly tied to the
reference OpAmp output and if it has already some charge the settling time
could be reduced.

But I don't think Keller is already in the phase to build a low power
engine. It seems he just needs to implement the FFT with slow sampling time.
This he can get letting the ADC sample at any high speed and read it only
when a slow interrupt occurs.

-Augusto

-----Mensagem original-----
De: m...@yahoogroups.com [mailto:m...@yahoogroups.com] Em nome de
Onestone
Enviada em: quinta-feira, 11 de setembro de 2008 04:58
Para: m...@yahoogroups.com
Assunto: Re: [msp430] Re: More about FFT

There is really almost nothing to be gained from running from such a
slow crystal, your CPU will simply not handle things. What MOST people,
incluidng my self do, is use a 32.768kHz watch crystal. this is very low
current. Then you can schedule sampling based on this. use the built in
ADC oscillator, but you can turn this on and off at such low sample
rates. You will alsmost certainly find problems running the ADC12 that
slowly. It relies on an internal sample and hold circuit which stores
the sample ina capacitor. if not sampled quickly enough the chage on
this will 'bleed away'.

if you are concenred about power consumption, most people here will tel
you that low power is all about duty cycle. If you have a long duty
cycle, like 1000:1 or more then your peak current has a very slight
effect on your mean curren.

to sample as you wish you would typically set up a timer to trigger the
sample, so every 33msecs (about) your timer would cause the miro to take
a sample. this is such a slow rate that you can quite possibly disable
the ADC12 while waiting. 33msecs is about 1100 ticks of the watch crystal
Then your timer starts a sample which takes around 13 clock IIRC, plus
any settle time if it was turned off, plus your allowed sample peiord,
which I would typically set to 4 or 8 clock ticks (set with SHT0 and
SHt1), so basically 21 clock cycles, at say 5Mhz of the ADC12 basic
clock. The 2616 for example has an internal reference settling time of
just 17msecs, and an ADC12 turn on to settle time of 100nS, and a quoted
sample time of 1220 nsecs, or jusy 1.22usecs. This differs slightly form
the older spec for sampling, so conversion is 13 clocks plus 17 msecs
turn on, plus 100nsecs settle, plus 1.22usecs sample, in total, at 5MHz
the entire sample requires just 17.5msecs. or less than 1 watch crystal
clock tick. so at 1081 clocks between samples, and 1 required to take th
sample and convert it, you have a 1080:1 active/sleep ratio, pretty
damned fast! now kets say you draw 5uA in sleep mode, the ADC draws
1.3mA at 5MHz, and using the CPu on the calibrated DCO frequencies draws
is given as 515uA. so adding that up we get about 1.8mA for 1 clock
tick, lets call that 2mA to be generous. then we get 5uA for 1080 clock
ticks, so our mena current is given by ((1080 x 5) + 2000)/1081 = 6.8uA.
as you can see the AD convrsion contributes a small amount at this
sample rate.

Cheers

Al

keller.lima wrote:

> Thank you very much
>
>You always helped me as much.
>
>Sorry but I have another question. There is a problem if I work with
>ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
>between 450KHz and 6MHZ. It is true?
>
>I need sampled 2 seconds of a signal with a sampling rate very low,
>approximately 30Hz. It's possible? Can I put a cristral often very
>low, like 1KHz in LFXT1CLK?
>
>Thanks, thanks, thanks....
>
>KAL
>
>--- In msp430@yahoogroups. com, Onestone
wrote:
>>As pascal points out the input to the FFt contains complex data,
>whose
>>imaginary part is 0. Similarly, and i tried to avoid getting overly
>>complex in my last post, the output contans real and imaginary
>>components to both the phase and amplitude data, but for most
>simple FFt
>>purposes the imaginary part can simply be ignored in both the input
>and
>>the output data. Run the FFT in reverse on the REAl amplitude and
>phase
>>data and you will see the REAL input data, or VERy close to it.
>>
>>Now the simple brute force form of an FFT is very simple to
>implement,
>>and very simple to understand. it is a pair of nested loops each as
>long
>>as the number of FFT 'taps'. Of course there are optimised
>variations,
>>of which the RADIX 2 is perhaps the most commonly used, but for
>simple
>>understanding the brute fore method works very well indeed, and
>allows
>>you to experiment quite freely with the variables.
>>
>>INput data is a real sampled analog signal of any complexity. Tha
>data
>>must be sampled at a pre-determined time interval. The sample rate
>>should be at least twice the required bandwidth of the incoming
>data
>>(for the reasons you will need to study Nyquist). below is some
>>extremely crude brute force FFT code with standard and inverse FFT.
>This
>>is just the two base functions there are glaringly obvious places
>where
>>this code could be streamlined, but it is over 20 years old, and
>the
>>code I used to learn and understand the way the FFT worked, so you
>get
>>it as is. as you can see the code is deceptively simple. Surround
>this
>>with a quick and dirty graphing routine and you can asily
>experiment
>>with sign al analysis. deconstryuct the signal and display the
>phase and
>>amplitude array results as a bar graph, try different graphs,
>display
>>the original signal as a raw waveform, then reconstruct it and
>view the
>>results. Then play with just reconstructing using a few
>selected 'tap'
>>results. Hint do NOT use 0 for unselected taps, just skip them.
>>
>>using this I developed many analysers including various forms of
>>logarithmic analysis. The variable 'gap'ooks like it may have been
>used
>>as a chordic analyser of some kind, or most probably given the era
>it
>>was an octave based model of the human ear, so this sould probably
>be
>>set to 1.
>>
>>Cheers
>>
>>Al
>>
>>void ifft(double freq)
>>{
>> double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
>> char c;
>> for(indx = 0;indx < 512;indx++)
>> {
>> temp = 0;
>> for(index = 0;index < 512;index++)
>> {
>> G = wave * indx * index / N;
>> temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
>* sin(G);
>> }
>> reduce[6][indx] = (int)temp/ N;
>> c = 0;
>> }
>>}
>>
>>void fft(double freq)
>>{
>> double real = 0,two = 2,imag = 0,point,rfreq = (double)
>freq,sam =
>>512,ing;
>> int indx;
>> for(ing = 0;ing < 512;ing++)
>> {
>> real = imag = 0;
>> for(indx = 0;indx < 512;indx++)
>> {
>> point = wave * ing * (double)indx/sam;
>> real += (double)(reduce[0][indx]) * cos(point);
>> imag -= (double)(reduce[0][indx]) * sin(point);
>> }
>> dfft[0][ing] = sqrt(imag*imag + real*real);
>> dfft[1][ing] = atan(imag/real);
>> dfft[2][ing] = real;
>> dfft[3][ing] = imag;
>> }
>>}
>>
>>keller.lima wrote:
>>
>>>Hi friend, Hi Onestone ...
>>>
>>> Can you help again?
>>>
>>> I understand the Onestone explanation about FFT output. Now I
>>>would like to understand more about the input. I know that the
>>>
>>>
>input
>>>of the FFT algorithm is a complex signal with the real values (R)
>>>
>>>
>and
>>>imaginary values (Q).
>>> The signal that I want to apply the FFT is a AD output and
>>>
>>>
>has
>>>only the real values.
>>> How I transform this signal in complex number for aplly in
>>>
>>>
>FFT?
>>> Onestone: can you help me?
>>>
>>>Thank you,
>>>
>>>KAL
>>>
>>>
>>>------------------------------------
>>>
>>>> egroups.com
>>>
>>>



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: RES: Re: More about FFT - Onestone - Sep 11 9:50:00 2008

Hi Augusto, I have no idea what he might be trying to sample.
unfortunately he seems to be tackling a reasonably complex task without
any understanding of the fundamentals, and therein lies disaster. YOu
can only help within their bounds to understand that help. Only thing I
disagree on is the 120Hz sample. It is still more power efficient to
turn the ADC12 on and off at each sample. Also, depending upon the micro
he is using, he should provide 10Uf/100Nf decoupling for the internal
reference on on its relevant external pin if he wants any kind of decent
system, other wsie the reference noise will appear all over his sampled
results.

Al

Augusto Einsfeldt wrote:

>Al, I guess Keller would like to measure harmonics in audio (typically
>should be 8KHz sample instead of 4KHz) and/or in public power rail (in
>Brasil it is 60Hz, so the minimum sample rate should be 120Hz, not 30Hz).
>Otherwise he wants to detect harmonics in a vibrating system (like in a slow
>machine) but this 30Hz he mentioned seems more like he inverted the notion
>of Niquist requirements.
>
>At 120Hz sample rate the best low power solution for most of MSPs would be
>to keep the reference voltage on between sleep phases. Another possibility
>(I never tried) would use the external refV capacitor (usually 10uF) to help
>speedup the reference generator. I guess it is directly tied to the
>reference OpAmp output and if it has already some charge the settling time
>could be reduced.
>
>But I don't think Keller is already in the phase to build a low power
>engine. It seems he just needs to implement the FFT with slow sampling time.
>This he can get letting the ADC sample at any high speed and read it only
>when a slow interrupt occurs.
>
>-Augusto
>
>-----Mensagem original-----
>De: m...@yahoogroups.com [mailto:m...@yahoogroups.com] Em nome de
>Onestone
>Enviada em: quinta-feira, 11 de setembro de 2008 04:58
>Para: m...@yahoogroups.com
>Assunto: Re: [msp430] Re: More about FFT
>
>There is really almost nothing to be gained from running from such a
>slow crystal, your CPU will simply not handle things. What MOST people,
>incluidng my self do, is use a 32.768kHz watch crystal. this is very low
>current. Then you can schedule sampling based on this. use the built in
>ADC oscillator, but you can turn this on and off at such low sample
>rates. You will alsmost certainly find problems running the ADC12 that
>slowly. It relies on an internal sample and hold circuit which stores
>the sample ina capacitor. if not sampled quickly enough the chage on
>this will 'bleed away'.
>
>if you are concenred about power consumption, most people here will tel
>you that low power is all about duty cycle. If you have a long duty
>cycle, like 1000:1 or more then your peak current has a very slight
>effect on your mean curren.
>
>to sample as you wish you would typically set up a timer to trigger the
>sample, so every 33msecs (about) your timer would cause the miro to take
>a sample. this is such a slow rate that you can quite possibly disable
>the ADC12 while waiting. 33msecs is about 1100 ticks of the watch crystal
>Then your timer starts a sample which takes around 13 clock IIRC, plus
>any settle time if it was turned off, plus your allowed sample peiord,
>which I would typically set to 4 or 8 clock ticks (set with SHT0 and
>SHt1), so basically 21 clock cycles, at say 5Mhz of the ADC12 basic
>clock. The 2616 for example has an internal reference settling time of
>just 17msecs, and an ADC12 turn on to settle time of 100nS, and a quoted
>sample time of 1220 nsecs, or jusy 1.22usecs. This differs slightly form
>the older spec for sampling, so conversion is 13 clocks plus 17 msecs
>turn on, plus 100nsecs settle, plus 1.22usecs sample, in total, at 5MHz
>the entire sample requires just 17.5msecs. or less than 1 watch crystal
>clock tick. so at 1081 clocks between samples, and 1 required to take th
>sample and convert it, you have a 1080:1 active/sleep ratio, pretty
>damned fast! now kets say you draw 5uA in sleep mode, the ADC draws
>1.3mA at 5MHz, and using the CPu on the calibrated DCO frequencies draws
>is given as 515uA. so adding that up we get about 1.8mA for 1 clock
>tick, lets call that 2mA to be generous. then we get 5uA for 1080 clock
>ticks, so our mena current is given by ((1080 x 5) + 2000)/1081 = 6.8uA.
>as you can see the AD convrsion contributes a small amount at this
>sample rate.
>
>Cheers
>
>Al
>
>keller.lima wrote:
>
>
>
>>Thank you very much
>>
>>You always helped me as much.
>>
>>Sorry but I have another question. There is a problem if I work with
>>ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
>>between 450KHz and 6MHZ. It is true?
>>
>>I need sampled 2 seconds of a signal with a sampling rate very low,
>>approximately 30Hz. It's possible? Can I put a cristral often very
>>low, like 1KHz in LFXT1CLK?
>>
>>Thanks, thanks, thanks....
>>
>>KAL
>>
>>--- In msp430@yahoogroups. com, Onestone
>>
>>
> wrote:
>
>
>>
>>
>>>As pascal points out the input to the FFt contains complex data,
>>>
>>>
>>>
>>>
>>whose
>>
>>
>>>imaginary part is 0. Similarly, and i tried to avoid getting overly
>>>complex in my last post, the output contans real and imaginary
>>>components to both the phase and amplitude data, but for most
>>>
>>>
>>>
>>>
>>simple FFt
>>
>>
>>>purposes the imaginary part can simply be ignored in both the input
>>>
>>>
>>>
>>>
>>and
>>
>>
>>>the output data. Run the FFT in reverse on the REAl amplitude and
>>>
>>>
>>>
>>>
>>phase
>>
>>
>>>data and you will see the REAL input data, or VERy close to it.
>>>
>>>Now the simple brute force form of an FFT is very simple to
>>>
>>>
>>>
>>>
>>implement,
>>
>>
>>>and very simple to understand. it is a pair of nested loops each as
>>>
>>>
>>>
>>>
>>long
>>
>>
>>>as the number of FFT 'taps'. Of course there are optimised
>>>
>>>
>>>
>>>
>>variations,
>>
>>
>>>of which the RADIX 2 is perhaps the most commonly used, but for
>>>
>>>
>>>
>>>
>>simple
>>
>>
>>>understanding the brute fore method works very well indeed, and
>>>
>>>
>>>
>>>
>>allows
>>
>>
>>>you to experiment quite freely with the variables.
>>>
>>>INput data is a real sampled analog signal of any complexity. Tha
>>>
>>>
>>>
>>>
>>data
>>
>>
>>>must be sampled at a pre-determined time interval. The sample rate
>>>should be at least twice the required bandwidth of the incoming
>>>
>>>
>>>
>>>
>>data
>>
>>
>>>(for the reasons you will need to study Nyquist). below is some
>>>extremely crude brute force FFT code with standard and inverse FFT.
>>>
>>>
>>>
>>>
>>This
>>
>>
>>>is just the two base functions there are glaringly obvious places
>>>
>>>
>>>
>>>
>>where
>>
>>
>>>this code could be streamlined, but it is over 20 years old, and
>>>
>>>
>>>
>>>
>>the
>>
>>
>>>code I used to learn and understand the way the FFT worked, so you
>>>
>>>
>>>
>>>
>>get
>>
>>
>>>it as is. as you can see the code is deceptively simple. Surround
>>>
>>>
>>>
>>>
>>this
>>
>>
>>>with a quick and dirty graphing routine and you can asily
>>>
>>>
>>>
>>>
>>experiment
>>
>>
>>>with sign al analysis. deconstryuct the signal and display the
>>>
>>>
>>>
>>>
>>phase and
>>
>>
>>>amplitude array results as a bar graph, try different graphs,
>>>
>>>
>>>
>>>
>>display
>>
>>
>>>the original signal as a raw waveform, then reconstruct it and
>>>
>>>
>>>
>>>
>>view the
>>
>>
>>>results. Then play with just reconstructing using a few
>>>
>>>
>>>
>>>
>>selected 'tap'
>>
>>
>>>results. Hint do NOT use 0 for unselected taps, just skip them.
>>>
>>>using this I developed many analysers including various forms of
>>>logarithmic analysis. The variable 'gap'ooks like it may have been
>>>
>>>
>>>
>>>
>>used
>>
>>
>>>as a chordic analyser of some kind, or most probably given the era
>>>
>>>
>>>
>>>
>>it
>>
>>
>>>was an octave based model of the human ear, so this sould probably
>>>
>>>
>>>
>>>
>>be
>>
>>
>>>set to 1.
>>>
>>>Cheers
>>>
>>>Al
>>>
>>>void ifft(double freq)
>>>{
>>>double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
>>>char c;
>>>for(indx = 0;indx < 512;indx++)
>>>{
>>>temp = 0;
>>>for(index = 0;index < 512;index++)
>>>{
>>>G = wave * indx * index / N;
>>>temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
>>>
>>>
>>>
>>>
>>* sin(G);
>>
>>
>>>}
>>>reduce[6][indx] = (int)temp/ N;
>>>c = 0;
>>>}
>>>}
>>>
>>>void fft(double freq)
>>>{
>>>double real = 0,two = 2,imag = 0,point,rfreq = (double)
>>>
>>>
>>>
>>>
>>freq,sam =
>>
>>
>>>512,ing;
>>>int indx;
>>>for(ing = 0;ing < 512;ing++)
>>>{
>>>real = imag = 0;
>>>for(indx = 0;indx < 512;indx++)
>>>{
>>>point = wave * ing * (double)indx/sam;
>>>real += (double)(reduce[0][indx]) * cos(point);
>>>imag -= (double)(reduce[0][indx]) * sin(point);
>>>}
>>>dfft[0][ing] = sqrt(imag*imag + real*real);
>>>dfft[1][ing] = atan(imag/real);
>>>dfft[2][ing] = real;
>>>dfft[3][ing] = imag;
>>>}
>>>}
>>>
>>>keller.lima wrote:
>>>
>>>
>>>
>>>
>>>
>>>>Hi friend, Hi Onestone ...
>>>>
>>>>Can you help again?
>>>>
>>>>I understand the Onestone explanation about FFT output. Now I
>>>>would like to understand more about the input. I know that the
>>>>
>>>>
>>>>
>>>>
>>input
>>
>>
>>>>of the FFT algorithm is a complex signal with the real values (R)
>>>>
>>>>
>>>>
>>>>
>>and
>>
>>
>>>>imaginary values (Q).
>>>>The signal that I want to apply the FFT is a AD output and
>>>>
>>>>
>>>>
>>>>
>>has
>>
>>
>>>>only the real values.
>>>>How I transform this signal in complex number for aplly in
>>>>
>>>>
>>>>
>>>>
>>FFT?
>>
>>
>>>>Onestone: can you help me?
>>>>
>>>>Thank you,
>>>>
>>>>KAL
>>>>
>>>>
>>>>------------------------------------
>>>>
>>>>> egroups.com
>>>>
>>>>



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

RES: RES: Re: More about FFT - Augusto Einsfeldt - Sep 11 10:07:22 2008

Indeed. But 17ms to wake-up and make a sample does not fit the 4ms
requirement for 120Hz sample. So, maybe, the 10uF in the Vref could,
perhaps, hold its charge between samples in this rate and the wake-up for
Vref could be shortened. I never tried myself this approach to find out the
lowest settling time. I am normally in the opposite side of the ADC sample
rate and for low power systems usually wake the ADC once every second or
even longer. In this time span the mean current consumption waking Vref
doesn't matter much. (Actually find a battery with lower leakage is harder,
to me, than make a very low power system).

Regarding noise in the Vref it is one of the worst nightmares I have seen.

-Augusto

-----Mensagem original-----
De: m...@yahoogroups.com [mailto:m...@yahoogroups.com] Em nome de
Onestone
Enviada em: quinta-feira, 11 de setembro de 2008 10:50
Para: m...@yahoogroups.com
Assunto: Re: RES: [msp430] Re: More about FFT

Hi Augusto, I have no idea what he might be trying to sample.
unfortunately he seems to be tackling a reasonably complex task without
any understanding of the fundamentals, and therein lies disaster. YOu
can only help within their bounds to understand that help. Only thing I
disagree on is the 120Hz sample. It is still more power efficient to
turn the ADC12 on and off at each sample. Also, depending upon the micro
he is using, he should provide 10Uf/100Nf decoupling for the internal
reference on on its relevant external pin if he wants any kind of decent
system, other wsie the reference noise will appear all over his sampled
results.

Al

Augusto Einsfeldt wrote:

>Al, I guess Keller would like to measure harmonics in audio (typically
>should be 8KHz sample instead of 4KHz) and/or in public power rail (in
>Brasil it is 60Hz, so the minimum sample rate should be 120Hz, not 30Hz).
>Otherwise he wants to detect harmonics in a vibrating system (like in a
slow
>machine) but this 30Hz he mentioned seems more like he inverted the notion
>of Niquist requirements.
>
>At 120Hz sample rate the best low power solution for most of MSPs would be
>to keep the reference voltage on between sleep phases. Another possibility
>(I never tried) would use the external refV capacitor (usually 10uF) to
help
>speedup the reference generator. I guess it is directly tied to the
>reference OpAmp output and if it has already some charge the settling time
>could be reduced.
>
>But I don't think Keller is already in the phase to build a low power
>engine. It seems he just needs to implement the FFT with slow sampling
time.
>This he can get letting the ADC sample at any high speed and read it only
>when a slow interrupt occurs.
>
>-Augusto
>
>-----Mensagem original-----
>De: msp430@yahoogroups. com
[mailto:msp430@yahoogroups. com] Em nome
de
>Onestone
>Enviada em: quinta-feira, 11 de setembro de 2008 04:58
>Para: msp430@yahoogroups. com
>Assunto: Re: [msp430] Re: More about FFT
>
>There is really almost nothing to be gained from running from such a
>slow crystal, your CPU will simply not handle things. What MOST people,
>incluidng my self do, is use a 32.768kHz watch crystal. this is very low
>current. Then you can schedule sampling based on this. use the built in
>ADC oscillator, but you can turn this on and off at such low sample
>rates. You will alsmost certainly find problems running the ADC12 that
>slowly. It relies on an internal sample and hold circuit which stores
>the sample ina capacitor. if not sampled quickly enough the chage on
>this will 'bleed away'.
>
>if you are concenred about power consumption, most people here will tel
>you that low power is all about duty cycle. If you have a long duty
>cycle, like 1000:1 or more then your peak current has a very slight
>effect on your mean curren.
>
>to sample as you wish you would typically set up a timer to trigger the
>sample, so every 33msecs (about) your timer would cause the miro to take
>a sample. this is such a slow rate that you can quite possibly disable
>the ADC12 while waiting. 33msecs is about 1100 ticks of the watch crystal
>Then your timer starts a sample which takes around 13 clock IIRC, plus
>any settle time if it was turned off, plus your allowed sample peiord,
>which I would typically set to 4 or 8 clock ticks (set with SHT0 and
>SHt1), so basically 21 clock cycles, at say 5Mhz of the ADC12 basic
>clock. The 2616 for example has an internal reference settling time of
>just 17msecs, and an ADC12 turn on to settle time of 100nS, and a quoted
>sample time of 1220 nsecs, or jusy 1.22usecs. This differs slightly form
>the older spec for sampling, so conversion is 13 clocks plus 17 msecs
>turn on, plus 100nsecs settle, plus 1.22usecs sample, in total, at 5MHz
>the entire sample requires just 17.5msecs. or less than 1 watch crystal
>clock tick. so at 1081 clocks between samples, and 1 required to take th
>sample and convert it, you have a 1080:1 active/sleep ratio, pretty
>damned fast! now kets say you draw 5uA in sleep mode, the ADC draws
>1.3mA at 5MHz, and using the CPu on the calibrated DCO frequencies draws
>is given as 515uA. so adding that up we get about 1.8mA for 1 clock
>tick, lets call that 2mA to be generous. then we get 5uA for 1080 clock
>ticks, so our mena current is given by ((1080 x 5) + 2000)/1081 = 6.8uA.
>as you can see the AD convrsion contributes a small amount at this
>sample rate.
>
>Cheers
>
>Al
>
>keller.lima wrote:
>
>>Thank you very much
>>
>>You always helped me as much.
>>
>>Sorry but I have another question. There is a problem if I work with
>>ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
>>between 450KHz and 6MHZ. It is true?
>>
>>I need sampled 2 seconds of a signal with a sampling rate very low,
>>approximately 30Hz. It's possible? Can I put a cristral often very
>>low, like 1KHz in LFXT1CLK?
>>
>>Thanks, thanks, thanks....
>>
>>KAL
>>
>>--- In msp430@yahoogroups. com, Onestone
> wrote:
>>>As pascal points out the input to the FFt contains complex data,
>>>
>>>
>>>
>>>
>>whose
>>>imaginary part is 0. Similarly, and i tried to avoid getting overly
>>>complex in my last post, the output contans real and imaginary
>>>components to both the phase and amplitude data, but for most
>>>
>>>
>>>
>>>
>>simple FFt
>>>purposes the imaginary part can simply be ignored in both the input
>>>
>>>
>>>
>>>
>>and
>>>the output data. Run the FFT in reverse on the REAl amplitude and
>>>
>>>
>>>
>>>
>>phase
>>>data and you will see the REAL input data, or VERy close to it.
>>>
>>>Now the simple brute force form of an FFT is very simple to
>>>
>>>
>>>
>>>
>>implement,
>>>and very simple to understand. it is a pair of nested loops each as
>>>
>>>
>>>
>>>
>>long
>>>as the number of FFT 'taps'. Of course there are optimised
>>>
>>>
>>>
>>>
>>variations,
>>>of which the RADIX 2 is perhaps the most commonly used, but for
>>>
>>>
>>>
>>>
>>simple
>>>understanding the brute fore method works very well indeed, and
>>>
>>>
>>>
>>>
>>allows
>>>you to experiment quite freely with the variables.
>>>
>>>INput data is a real sampled analog signal of any complexity. Tha
>>>
>>>
>>>
>>>
>>data
>>>must be sampled at a pre-determined time interval. The sample rate
>>>should be at least twice the required bandwidth of the incoming
>>>
>>>
>>>
>>>
>>data
>>>(for the reasons you will need to study Nyquist). below is some
>>>extremely crude brute force FFT code with standard and inverse FFT.
>>>
>>>
>>>
>>>
>>This
>>>is just the two base functions there are glaringly obvious places
>>>
>>>
>>>
>>>
>>where
>>>this code could be streamlined, but it is over 20 years old, and
>>>
>>>
>>>
>>>
>>the
>>>code I used to learn and understand the way the FFT worked, so you
>>>
>>>
>>>
>>>
>>get
>>>it as is. as you can see the code is deceptively simple. Surround
>>>
>>>
>>>
>>>
>>this
>>>with a quick and dirty graphing routine and you can asily
>>>
>>>
>>>
>>>
>>experiment
>>>with sign al analysis. deconstryuct the signal and display the
>>>
>>>
>>>
>>>
>>phase and
>>>amplitude array results as a bar graph, try different graphs,
>>>
>>>
>>>
>>>
>>display
>>>the original signal as a raw waveform, then reconstruct it and
>>>
>>>
>>>
>>>
>>view the
>>>results. Then play with just reconstructing using a few
>>>
>>>
>>>
>>>
>>selected 'tap'
>>>results. Hint do NOT use 0 for unselected taps, just skip them.
>>>
>>>using this I developed many analysers including various forms of
>>>logarithmic analysis. The variable 'gap'ooks like it may have been
>>>
>>>
>>>
>>>
>>used
>>>as a chordic analyser of some kind, or most probably given the era
>>>
>>>
>>>
>>>
>>it
>>>was an octave based model of the human ear, so this sould probably
>>>
>>>
>>>
>>>
>>be
>>>set to 1.
>>>
>>>Cheers
>>>
>>>Al
>>>
>>>void ifft(double freq)
>>>{
>>>double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
>>>char c;
>>>for(indx = 0;indx < 512;indx++)
>>>{
>>>temp = 0;
>>>for(index = 0;index < 512;index++)
>>>{
>>>G = wave * indx * index / N;
>>>temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
>>>
>>>
>>>
>>>
>>* sin(G);
>>>}
>>>reduce[6][indx] = (int)temp/ N;
>>>c = 0;
>>>}
>>>}
>>>
>>>void fft(double freq)
>>>{
>>>double real = 0,two = 2,imag = 0,point,rfreq = (double)
>>>
>>>
>>>
>>>
>>freq,sam =
>>>512,ing;
>>>int indx;
>>>for(ing = 0;ing < 512;ing++)
>>>{
>>>real = imag = 0;
>>>for(indx = 0;indx < 512;indx++)
>>>{
>>>point = wave * ing * (double)indx/sam;
>>>real += (double)(reduce[0][indx]) * cos(point);
>>>imag -= (double)(reduce[0][indx]) * sin(point);
>>>}
>>>dfft[0][ing] = sqrt(imag*imag + real*real);
>>>dfft[1][ing] = atan(imag/real);
>>>dfft[2][ing] = real;
>>>dfft[3][ing] = imag;
>>>}
>>>}
>>>
>>>keller.lima wrote:
>>>
>>>
>>>
>>>
>>>
>>>>Hi friend, Hi Onestone ...
>>>>
>>>>Can you help again?
>>>>
>>>>I understand the Onestone explanation about FFT output. Now I
>>>>would like to understand more about the input. I know that the
>>>>
>>>>
>>>>
>>>>
>>input
>>>>of the FFT algorithm is a complex signal with the real values (R)
>>>>
>>>>
>>>>
>>>>
>>and
>>>>imaginary values (Q).
>>>>The signal that I want to apply the FFT is a AD output and
>>>>
>>>>
>>>>
>>>>
>>has
>>>>only the real values.
>>>>How I transform this signal in complex number for aplly in
>>>>
>>>>
>>>>
>>>>
>>FFT?
>>>>Onestone: can you help me?
>>>>
>>>>Thank you,
>>>>
>>>>KAL
>>>>
>>>>
>>>>------------------------------------
>>>>
>>>>>
egroups.com
>>>>
>>>>



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )

Re: RES: RES: Re: More about FFT - Onestone - Sep 11 10:35:18 2008

This is also one reason why I prefer PWM or duty cycle based sensors,
then it almost doesn't matter about the A/D, no noise or reference drift
to mess around with, and you can pick your resolution based on the
clock, plus no skew issues as you get with A/D or even worse serial sensors.

Al

Augusto Einsfeldt wrote:

>Indeed. But 17ms to wake-up and make a sample does not fit the 4ms
>requirement for 120Hz sample. So, maybe, the 10uF in the Vref could,
>perhaps, hold its charge between samples in this rate and the wake-up for
>Vref could be shortened. I never tried myself this approach to find out the
>lowest settling time. I am normally in the opposite side of the ADC sample
>rate and for low power systems usually wake the ADC once every second or
>even longer. In this time span the mean current consumption waking Vref
>doesn't matter much. (Actually find a battery with lower leakage is harder,
>to me, than make a very low power system).
>
>Regarding noise in the Vref it is one of the worst nightmares I have seen.
>
>-Augusto
>
>-----Mensagem original-----
>De: m...@yahoogroups.com [mailto:m...@yahoogroups.com] Em nome de
>Onestone
>Enviada em: quinta-feira, 11 de setembro de 2008 10:50
>Para: m...@yahoogroups.com
>Assunto: Re: RES: [msp430] Re: More about FFT
>
>Hi Augusto, I have no idea what he might be trying to sample.
>unfortunately he seems to be tackling a reasonably complex task without
>any understanding of the fundamentals, and therein lies disaster. YOu
>can only help within their bounds to understand that help. Only thing I
>disagree on is the 120Hz sample. It is still more power efficient to
>turn the ADC12 on and off at each sample. Also, depending upon the micro
>he is using, he should provide 10Uf/100Nf decoupling for the internal
>reference on on its relevant external pin if he wants any kind of decent
>system, other wsie the reference noise will appear all over his sampled
>results.
>
>Al
>
>Augusto Einsfeldt wrote:
>
>
>
>>Al, I guess Keller would like to measure harmonics in audio (typically
>>should be 8KHz sample instead of 4KHz) and/or in public power rail (in
>>Brasil it is 60Hz, so the minimum sample rate should be 120Hz, not 30Hz).
>>Otherwise he wants to detect harmonics in a vibrating system (like in a
>>
>>
>slow
>
>
>>machine) but this 30Hz he mentioned seems more like he inverted the notion
>>of Niquist requirements.
>>
>>At 120Hz sample rate the best low power solution for most of MSPs would be
>>to keep the reference voltage on between sleep phases. Another possibility
>>(I never tried) would use the external refV capacitor (usually 10uF) to
>>
>>
>help
>
>
>>speedup the reference generator. I guess it is directly tied to the
>>reference OpAmp output and if it has already some charge the settling time
>>could be reduced.
>>
>>But I don't think Keller is already in the phase to build a low power
>>engine. It seems he just needs to implement the FFT with slow sampling
>>
>>
>time.
>
>
>>This he can get letting the ADC sample at any high speed and read it only
>>when a slow interrupt occurs.
>>
>>-Augusto
>>
>>-----Mensagem original-----
>>De: msp430@yahoogroups. com
>>
>>
>[mailto:msp430@yahoogroups. com] Em nome
>de
>
>
>>Onestone
>>Enviada em: quinta-feira, 11 de setembro de 2008 04:58
>>Para: msp430@yahoogroups. com
>>Assunto: Re: [msp430] Re: More about FFT
>>
>>There is really almost nothing to be gained from running from such a
>>slow crystal, your CPU will simply not handle things. What MOST people,
>>incluidng my self do, is use a 32.768kHz watch crystal. this is very low
>>current. Then you can schedule sampling based on this. use the built in
>>ADC oscillator, but you can turn this on and off at such low sample
>>rates. You will alsmost certainly find problems running the ADC12 that
>>slowly. It relies on an internal sample and hold circuit which stores
>>the sample ina capacitor. if not sampled quickly enough the chage on
>>this will 'bleed away'.
>>
>>if you are concenred about power consumption, most people here will tel
>>you that low power is all about duty cycle. If you have a long duty
>>cycle, like 1000:1 or more then your peak current has a very slight
>>effect on your mean curren.
>>
>>to sample as you wish you would typically set up a timer to trigger the
>>sample, so every 33msecs (about) your timer would cause the miro to take
>>a sample. this is such a slow rate that you can quite possibly disable
>>the ADC12 while waiting. 33msecs is about 1100 ticks of the watch crystal
>>Then your timer starts a sample which takes around 13 clock IIRC, plus
>>any settle time if it was turned off, plus your allowed sample peiord,
>>which I would typically set to 4 or 8 clock ticks (set with SHT0 and
>>SHt1), so basically 21 clock cycles, at say 5Mhz of the ADC12 basic
>>clock. The 2616 for example has an internal reference settling time of
>>just 17msecs, and an ADC12 turn on to settle time of 100nS, and a quoted
>>sample time of 1220 nsecs, or jusy 1.22usecs. This differs slightly form
>>the older spec for sampling, so conversion is 13 clocks plus 17 msecs
>>turn on, plus 100nsecs settle, plus 1.22usecs sample, in total, at 5MHz
>>the entire sample requires just 17.5msecs. or less than 1 watch crystal
>>clock tick. so at 1081 clocks between samples, and 1 required to take th
>>sample and convert it, you have a 1080:1 active/sleep ratio, pretty
>>damned fast! now kets say you draw 5uA in sleep mode, the ADC draws
>>1.3mA at 5MHz, and using the CPu on the calibrated DCO frequencies draws
>>is given as 515uA. so adding that up we get about 1.8mA for 1 clock
>>tick, lets call that 2mA to be generous. then we get 5uA for 1080 clock
>>ticks, so our mena current is given by ((1080 x 5) + 2000)/1081 = 6.8uA.
>>as you can see the AD convrsion contributes a small amount at this
>>sample rate.
>>
>>Cheers
>>
>>Al
>>
>>keller.lima wrote:
>>
>>
>>
>>>Thank you very much
>>>
>>>You always helped me as much.
>>>
>>>Sorry but I have another question. There is a problem if I work with
>>>ADC12CLK in 4KHz? In the Fabio Pereira book's sad that I need to work
>>>between 450KHz and 6MHZ. It is true?
>>>
>>>I need sampled 2 seconds of a signal with a sampling rate very low,
>>>approximately 30Hz. It's possible? Can I put a cristral often very
>>>low, like 1KHz in LFXT1CLK?
>>>
>>>Thanks, thanks, thanks....
>>>
>>>KAL
>>>
>>>
>>>
>>>--- In msp430@yahoogroups. com, Onestone
>>>
>>>
>>>
>>>
>> wrote:
>>
>>
>>>
>>>
>>>>As pascal points out the input to the FFt contains complex data,
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>whose
>>>
>>>
>>>
>>>
>>>
>>>
>>>>imaginary part is 0. Similarly, and i tried to avoid getting overly
>>>>complex in my last post, the output contans real and imaginary
>>>>components to both the phase and amplitude data, but for most
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>simple FFt
>>>
>>>
>>>
>>>
>>>
>>>
>>>>purposes the imaginary part can simply be ignored in both the input
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>and
>>>
>>>
>>>
>>>
>>>
>>>
>>>>the output data. Run the FFT in reverse on the REAl amplitude and
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>phase
>>>
>>>
>>>
>>>
>>>
>>>
>>>>data and you will see the REAL input data, or VERy close to it.
>>>>
>>>>Now the simple brute force form of an FFT is very simple to
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>implement,
>>>
>>>
>>>
>>>
>>>
>>>
>>>>and very simple to understand. it is a pair of nested loops each as
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>long
>>>
>>>
>>>
>>>
>>>
>>>
>>>>as the number of FFT 'taps'. Of course there are optimised
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>variations,
>>>
>>>
>>>
>>>
>>>
>>>
>>>>of which the RADIX 2 is perhaps the most commonly used, but for
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>simple
>>>
>>>
>>>
>>>
>>>
>>>
>>>>understanding the brute fore method works very well indeed, and
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>allows
>>>
>>>
>>>
>>>
>>>
>>>
>>>>you to experiment quite freely with the variables.
>>>>
>>>>INput data is a real sampled analog signal of any complexity. Tha
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>data
>>>
>>>
>>>
>>>
>>>
>>>
>>>>must be sampled at a pre-determined time interval. The sample rate
>>>>should be at least twice the required bandwidth of the incoming
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>data
>>>
>>>
>>>
>>>
>>>
>>>
>>>>(for the reasons you will need to study Nyquist). below is some
>>>>extremely crude brute force FFT code with standard and inverse FFT.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>This
>>>
>>>
>>>
>>>
>>>
>>>
>>>>is just the two base functions there are glaringly obvious places
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>where
>>>
>>>
>>>
>>>
>>>
>>>
>>>>this code could be streamlined, but it is over 20 years old, and
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>the
>>>
>>>
>>>
>>>
>>>
>>>
>>>>code I used to learn and understand the way the FFT worked, so you
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>get
>>>
>>>
>>>
>>>
>>>
>>>
>>>>it as is. as you can see the code is deceptively simple. Surround
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>this
>>>
>>>
>>>
>>>
>>>
>>>
>>>>with a quick and dirty graphing routine and you can asily
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>experiment
>>>
>>>
>>>
>>>
>>>
>>>
>>>>with sign al analysis. deconstryuct the signal and display the
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>phase and
>>>
>>>
>>>
>>>
>>>
>>>
>>>>amplitude array results as a bar graph, try different graphs,
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>display
>>>
>>>
>>>
>>>
>>>
>>>
>>>>the original signal as a raw waveform, then reconstruct it and
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>view the
>>>
>>>
>>>
>>>
>>>
>>>
>>>>results. Then play with just reconstructing using a few
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>selected 'tap'
>>>
>>>
>>>
>>>
>>>
>>>
>>>>results. Hint do NOT use 0 for unselected taps, just skip them.
>>>>
>>>>using this I developed many analysers including various forms of
>>>>logarithmic analysis. The variable 'gap'ooks like it may have been
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>used
>>>
>>>
>>>
>>>
>>>
>>>
>>>>as a chordic analyser of some kind, or most probably given the era
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>it
>>>
>>>
>>>
>>>
>>>
>>>
>>>>was an octave based model of the human ear, so this sould probably
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>be
>>>
>>>
>>>
>>>
>>>
>>>
>>>>set to 1.
>>>>
>>>>Cheers
>>>>
>>>>Al
>>>>
>>>>void ifft(double freq)
>>>>{
>>>>double indx,index,freqs,gap = 1.3333333,N = 512,G,temp;
>>>>char c;
>>>>for(indx = 0;indx < 512;indx++)
>>>>{
>>>>temp = 0;
>>>>for(index = 0;index < 512;index++)
>>>>{
>>>>G = wave * indx * index / N;
>>>>temp = temp + dfft[2][index] * cos(G) - dfft[3][index]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>* sin(G);
>>>
>>>
>>>
>>>
>>>
>>>
>>>>}
>>>>reduce[6][indx] = (int)temp/ N;
>>>>c = 0;
>>>>}
>>>>}
>>>>
>>>>void fft(double freq)
>>>>{
>>>>double real = 0,two = 2,imag = 0,point,rfreq = (double)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>freq,sam =
>>>
>>>
>>>
>>>
>>>
>>>
>>>>512,ing;
>>>>int indx;
>>>>for(ing = 0;ing < 512;ing++)
>>>>{
>>>>real = imag = 0;
>>>>for(indx = 0;indx < 512;indx++)
>>>>{
>>>>point = wave * ing * (double)indx/sam;
>>>>real += (double)(reduce[0][indx]) * cos(point);
>>>>imag -= (double)(reduce[0][indx]) * sin(point);
>>>>}
>>>>dfft[0][ing] = sqrt(imag*imag + real*real);
>>>>dfft[1][ing] = atan(imag/real);
>>>>dfft[2][ing] = real;
>>>>dfft[3][ing] = imag;
>>>>}
>>>>}
>>>>
>>>>keller.lima wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Hi friend, Hi Onestone ...
>>>>>
>>>>>Can you help again?
>>>>>
>>>>>I understand the Onestone explanation about FFT output. Now I
>>>>>would like to understand more about the input. I know that the
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>input
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>of the FFT algorithm is a complex signal with the real values (R)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>and
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>imaginary values (Q).
>>>>>The signal that I want to apply the FFT is a AD output and
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>has
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>only the real values.
>>>>>How I transform this signal in complex number for aplly in
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>FFT?
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>Onestone: can you help me?
>>>>>
>>>>>Thank you,
>>>>>
>>>>>KAL
>>>>>
>>>>>
>>>>>------------------------------------
>>>>>
>>>>>>
>>>>>
>>>>>
>egroups.com
>
>
>>>>>



(You need to be a member of msp430 -- send a blank email to msp430-subscribe@yahoogroups.com )