Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    Ymir got a reaction from Fmilburn in FFT   
    First, sorry for not answer before, but i was incredibly bussy and couldnt test neither circuits nor the code deep.
    Anyway, I've used a function generator to test the accuracy and range of the code and it runs perfect from 30 Hz to 330Hz, i only tested my working range.
    Moreover i've tested the circuits linearity, and they are incredibly linear.
    So, with this results, i tested the input....when the input is direct from the guitar, the code runs, but when i use a microphone, suddenly appears a problem, the lowest string frequency, at 82Hz, it isnt detected but the code detect it second harmonic, more or less, and calculate 166Hz. So the problem is something with the microphone. Im using an electret microphone.
    I tested the input from the microphone with an oscilloscope and seems not to recognize that lower frequency.
    I'll do more experiments and coment the results.
  2. Like
    Ymir got a reaction from Fmilburn in FFT   
    Yes, i modified the parameters to get a 1Hz resolution, giviing a 511Hz max frequency, it is true this values arent in the table. 
    #define LOG2N 10 //log base 2 of the number of points, e.g. LOG2N = 8 is 256 points #define FREQ_RESOLUTION 1 //Frequency resolution of output in Hz #define ANALOG_IN 27 //analog input pin #define ANALOG_RESOLUTION 12 //CPU specific The problem is that sometimes it works right and suddenly it works wrong, detecting the main frequency or double frec (the second harmonic). I think it is an aliasing problem. 
    Trying to solve this problem i implemented a little LP filter before calling FFT function, it reduces this blinking misfunction, but not solved it completely, but it appears less times and it detects the whole working range (70 - 350 Hz)
    for (i = 1; i < nPts; i++) { int gain = 50; real[i] = (gain * real[i] + real[i-1])/(1+gain); //-----> gain= 10 o 50; } This is the amplifier i use to set the guitar signal before the ADC

  3. Like
    Ymir got a reaction from roadrunner84 in Guitar Tuner   
    Hi everyone!
    im trying to create a guitar tuner with my tm4c1294 but im having some problems. I also would like to use Systick .
    The problem is that it not detect well the frecuency, "tiempo" variable doesnt increment as fast as it should. It should detect frequencies between 80 - 330Hz but doesnt detect anything
    Could any one help me?
    #include <stdint.h> #include "driverlib\systick.h" #include "driverlib\systick.c" #include "driverlib/sysctl.h" #include "driverlib/adc.h" unsigned long start_times[10]; unsigned long stop_times[10]; int long Vin; int datoA; float frecuencia; float pendiente; float tiempo; int contador;                                     #define TickerPeriod 16777215 #define ADCpin1 27 void setup() {   SysTickDisable();                      // Deshabilita SysTick durante la configuracion   SysTickPeriodSet(TickerPeriod);             // Define el periodo del contador. Al llegar a cero genera la intrrupcion   SysTickIntRegister(&Ticker);   // Se vincula a la ISR de la interrupción causada por el SysTick   SysTickIntEnable();                    // Se habilita la interrupción del SysTick   SysTickEnable();                       // Se habilita el SysTick, después de haber sido configurado   IntMasterEnable();                     // Se habilitan todas las interrupciones   Serial.begin(9600);   //ADC configuration   ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); //enables a peripheral                     ROM_ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); // Configures the trigger source and priority of a sample sequence.   ROM_ADCHardwareOversampleConfigure(ADC0_BASE,0); //Configures the hardware oversampling factor of the ADC.   ROM_ADCSequenceEnable(ADC0_BASE, 3); //enables a sample sequence.            ROM_ADCIntClear(ADC0_BASE, 3); //Clears sample sequence interrupt source. } void loop() {   frecuencia = (stop_times[1] - start_times[1])*float(tiempo); if (contador = 20) {   Serial.print("\nADC = ");      Serial.print(Vin);   Serial.print("\tTiempo captura = ");      Serial.print(stop_times[1] - start_times[1]);   Serial.print("\tPendiente = ");      Serial.print(pendiente);   Serial.print("\tFrecuencia = ");      Serial.print(frecuencia);      contador = 0; } } void Ticker()                           {   start_times[1] = micros();   Vin = analogRead1(ADCpin1);   pendiente = Vin - datoA;      datoA = Vin;   if (pendiente > 1 && Vin > 2047)   {     tiempo++;   }   if (Vin < 2047)   {     tiempo = 0;   }   if(pendiente < 0 && Vin > 2047)   {     tiempo = 0;   }   contador++;   stop_times[1] = micros(); } uint16_t analogRead1(uint8_t pin) {   uint16_t value[1];   uint32_t channel = digitalPinToADCIn(pin);   ROM_ADCSequenceStepConfigure(ADC0_BASE, 3, 0, channel | ADC_CTL_IE | ADC_CTL_END); // This function configures the ADC for one step of a sample sequence.   if (channel == NOT_ON_ADC)    { //invalid ADC pin     return 0;   }   ROM_ADCProcessorTrigger(ADC0_BASE, 3); // Causes a processor trigger for a sample sequence.   while(!ROM_ADCIntStatus(ADC0_BASE, 3, false))   { //Gets the current interrupt status.   }   ROM_ADCIntClear(ADC0_BASE, 3); //Clears sample sequence interrupt source.   ROM_ADCSequenceDataGet(ADC0_BASE, 3, (unsigned long*) value); //Gets the captured data for a sample sequence.   return value[0]; }
  • Create New...