Autor Tema: Fin de carrera  (Leído 2074 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado arcadi

  • PIC12
  • **
  • Mensajes: 74
Fin de carrera
« en: 21 de Enero de 2009, 12:07:23 »
Buenas...

es que me he quedado sin ideas... ¿alguien sabe algun tema para proyecto de fin de carrera?

Queria hacer un robot rastreador, con implementacion PID y encoders, pero me digeron que era un poco dificil y con mucha dedicacion... y para hacerlo en todo o nada  :? tenia que hacer algo nuevo (ademas, era muy facil XD)

Me gustaria algo atractivo y un poco facil XD... Ahora mismo estoy repasando todo los libros tipo Sales-Kit haver que se me ocurre...

muchas gracias maestros
Anglès (Girona)

Desconectado arcadi

  • PIC12
  • **
  • Mensajes: 74
Re: Fin de carrera
« Respuesta #1 en: 21 de Enero de 2009, 15:10:31 »
Tengo una idea  :-/... Pero necesito implementar unas FFT.

Cogeria una señal de audio, la entraria en el ADC de un PIC (o DsPIC). Escanearia la señal de audio y llenaria una matriz de 512 por ejemplo
con sus valores de audio. Finalmente, aplicaria la FFT para saber las frecuencias dominantes.

Pido si alguien me puede explicar un poco la libreria fft.h, ya que no la se interpretar mucho.


------------------------EJEMPLO DE PROGRAMA-----------------------------------------------------------------


#include <p30Fxxxx.h>
#include "dsp.h"
#include "fft.h"

/* Device configuration register macros for building the hex file */
_FOSC(CSW_FSCM_OFF & XT_PLL8);          /* XT with 8xPLL oscillator, Failsafe clock off */
_FWDT(WDT_OFF);                         /* Watchdog timer disabled */
_FBORPOR(PBOR_OFF & MCLR_EN);           /* Brown-out reset disabled, MCLR reset enabled */
_FGS(CODE_PROT_OFF);                    /* Code protect disabled */


/* Extern definitions */
extern fractcomplex sigCmpx[FFT_BLOCK_LENGTH]                    /* Typically, the input signal to an FFT  */
__attribute__ ((section (".ydata, data, ymemory"),                      /* routine is a complex array containing samples */
aligned (FFT_BLOCK_LENGTH * 2 *2)));                                     /* of an input signal. For this example, */
                                                                                              /* we will provide the input signal in an */
                                                                                              /* array declared in Y-data space. */
/* Global Definitions */

#ifndef FFTTWIDCOEFFS_IN_PROGMEM
fractcomplex twiddleFactors[FFT_BLOCK_LENGTH/2]                                                              /* Declare Twiddle Factor array in X-space*/
__attribute__ ((section (".xbss, bss, xmemory"), aligned (FFT_BLOCK_LENGTH*2)));

#else

extern const fractcomplex twiddleFactors[FFT_BLOCK_LENGTH/2]                                            /* Twiddle Factor array in Program memory */
__attribute__ ((space(auto_psv), aligned (FFT_BLOCK_LENGTH*2)));
#endif

float salida;
int   peakFrequencyBin = 0;                                                                                                 /* Declare post-FFT variables to compute the */
unsigned long peakFrequency = 0;                                                                                       /* frequency of the largest spectral component */

int main(void)
{
   int i = 0;
   fractional *p_real = &sigCmpx[0].real ;
   fractcomplex *p_cmpx = &sigCmpx[0] ;


#ifndef FFTTWIDCOEFFS_IN_PROGMEM               /* Generate TwiddleFactor Coefficients */
   TwidFactorInit (LOG2_BLOCK_LENGTH, &twiddleFactors[0], 0);   /* We need to do this only once at start-up */
#endif

   for ( i = 0; i < FFT_BLOCK_LENGTH; i++ )/* The FFT function requires input data */
   {               /* to be in the fractional fixed-point range [-0.5, +0.5]*/
      *p_real = *p_real >>1 ;      /* So, we shift all data samples by 1 bit to the right. */
      *p_real++;         /* Should you desire to optimize this process, perform */
   }               /* data scaling when first obtaining the time samples */
                  /* Or within the BitReverseComplex function source code */

   p_real = &sigCmpx[(FFT_BLOCK_LENGTH/2)-1].real ;   /* Set up pointers to convert real array */
   p_cmpx = &sigCmpx[FFT_BLOCK_LENGTH-1] ; /* to a complex array. The input array initially has all */
                  /* the real input samples followed by a series of zeros */


   for ( i = FFT_BLOCK_LENGTH; i > 0; i-- ) /* Convert the Real input sample array */
   {               /* to a Complex input sample array  */
      (*p_cmpx).real = (*p_real--);   /* We will simpy zero out the imaginary  */
      (*p_cmpx--).imag = 0x0000;   /* part of each data sample */
   }

   /* Perform FFT operation */
#ifndef FFTTWIDCOEFFS_IN_PROGMEM
   FFTComplexIP (LOG2_BLOCK_LENGTH, &sigCmpx[0], &twiddleFactors[0], COEFFS_IN_DATA);
#else
   FFTComplexIP (LOG2_BLOCK_LENGTH, &sigCmpx[0], (fractcomplex *) __builtin_psvoffset(&twiddleFactors[0]), (int) __builtin_psvpage(&twiddleFactors[0]));
#endif

   /* Store output samples in bit-reversed order of their addresses */
   BitReverseComplex (LOG2_BLOCK_LENGTH, &sigCmpx[0]);

   /* Compute the square magnitude of the complex FFT output array so we have a Real output vetor */
   SquareMagnitudeCplx(FFT_BLOCK_LENGTH, &sigCmpx[0], &sigCmpx[0].real);//  <---- segun yo eso ya te lo convertia y te lo arrojaba en 0x1C00 por lo que indica el   
       puntero
   

        while (1);   /* Place a breakpoint here and observe the watch window variables */
}
Anglès (Girona)

Desconectado Slalen

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1079
    • Página web personal de Guillermo Herrero González
Re: Fin de carrera
« Respuesta #2 en: 22 de Enero de 2009, 06:17:23 »
Hola!!

Yo creo que el rastreador no es tan complicado. Además, te puedes ayudar de los PID que cede microchip.

Yo te animo a que lo hagas (ya que me gusta la idea  :mrgreen:)

Un saludo y mucha suerte!!!

Desconectado arcadi

  • PIC12
  • **
  • Mensajes: 74
Re: Fin de carrera
« Respuesta #3 en: 22 de Enero de 2009, 07:06:16 »
Ya hare un rastreador velocista o un hexapodo este verano con un amigo  :-/ ya habiamos quedado en esto XD

He encontrado informacion de las FFT y DFT:

Transformada Discreta de fourier DFT   :  http://www.dspguide.com/ch8.htm
Transformada rápida de Fourier FFT      :  http://www.dspguide.com/ch12.htm

La DFT es mas fácil de implementar pero tiene en desventaja que utiliza N^2 operaciones complejas.

La FFT es un algoritmo y como tal existen varios metodos de los cuales se destacan decimación en el Tiempo y decimación en Frecuencia. El primero es el que hace referencia el capitulo 12 de la pagina Dspguide y del cual hay un algoritmo en Basic fácil de entender para transcribirlo a C. Tiene en ventaja que utiliza menos operaciones complejas que la DFT con N*Log(N)/Log(2) ----> que es lo mismo N*Log(N) en base 2 operaciones.



Muchas gracias a todos y salud!!!!!!!
Anglès (Girona)


 

anything