Example #1
0
void FilterTwoPole::setAsFilter( OSCILLATOR_TYPE ft, float frequency3db, float initialValue ) {
  // if this is a highpass filter, set to invert the transfer function on the output
  //if( ft == HIGHPASS_BESSEL || ft == HIGHPASS_BUTTERWORTH ) {
  //  IsHighpass = true;
  //}
  //else {
    IsHighpass = false;
  //}

  X = initialValue;
  
  if( ft == LOWPASS_BESSEL ) {
    setFrequency0( frequency3db * 1.28 );
    setQ( 0.5774 );
  }
  //else if( ft == HIGHPASS_BESSEL ) {
  //  setFrequency0( frequency3db * 1.28 );
  //  setQ( 0.5774 );
  //}
  
  else if( ft == LOWPASS_BUTTERWORTH ) {
    // set as butterworth
    setFrequency0( frequency3db );
    setQ( 0.7071 );
  }
  //else if( ft == HIGHPASS_BUTTERWORTH ) {
    // set as butterworth
  //  setFrequency0( frequency3db );
  //  setQ( 0.7071 );
  //}
}
Example #2
0
FilterTwoPole::FilterTwoPole( float frequency0, float qualityFactor, float xInit ) {
  X = xInit;              // start it some arbitrary position
  Vprev = 0;              // initially stopped
  IsHighpass = false;     // by default, a normal oscillator

  setQ( qualityFactor );
  setFrequency0( frequency0 );

  LastTimeUS = micros();
}
Example #3
0
int main()
{
    Counter_1_Start();
    Counter_2_Start();
    
    QuadDec1_Start();
    QuadDec2_Start();
    QuadDec3_Start();
    
    LCD_Char1_Start();
    LCD_Char1_DisplayOn();
    LCD_Char1_Enable();
    LCD_Char1_PrintString("B.E.A.R. Con. v2.0");
    CyDelay(2000);

    PWM_Start();
    
    WaveDAC8_1_Start(); 
    WaveDAC8_2_Start();
    //double baseFreq=500;
    setFrequency0(500.0+offsetFreq); QuadDec1_SetCounter(500.0*10);
    setFrequency1(500.0+offsetFreq); QuadDec2_SetCounter(500.0*10);
    //setFrequency3(1.0);
    
    int16 quadCount1=0;
    int16 oldQCount1=0;
    int16 quadCount2=0;
    int16 oldQCount2=0;
    int16 quadCount3=0;
    int16 oldQCount3=0;

    QuadDec3_SetCounter(43);
    
    
    
    
    updateDisplay();
    
    for (;;)
    {
        quadCount1=QuadDec1_GetCounter();
        if (quadCount1!=oldQCount1)
        {
            if (CoarsePIN_Read()==0) //rapid tune pressed
            {
                int theDifference=quadCount1-oldQCount1;
                if (theDifference<0) quadCount1=quadCount1-10;
                else quadCount1=quadCount1+10;
                QuadDec1_SetCounter(quadCount1);
            }
            
            double newFreq=(((double)(quadCount1))/10);
            setFrequency0(newFreq+offsetFreq);
            oldQCount1=quadCount1;
            leftFreq=newFreq;
            updateDisplay();
            updateLED();    
        }
        quadCount2=QuadDec2_GetCounter();
        if (quadCount2!=oldQCount2)
        {
            if (CoarsePIN_Read()==0) //rapid tune pressed
            {
                int theDifference=quadCount2-oldQCount2;
                if (theDifference<0) quadCount2=quadCount2-10;
                else quadCount2=quadCount2+10;
                QuadDec2_SetCounter(quadCount2);
            }
            
            double newFreq=(((double)(quadCount2))/10);
            setFrequency1(newFreq+offsetFreq);
            oldQCount2=quadCount2;
            rightFreq=newFreq;
            updateDisplay();
            updateLED();
        }
        quadCount3=QuadDec3_GetCounter();
        if (quadCount3!=oldQCount3)
        {
            double newFreq=(((double)(quadCount3))/10);
            offsetFreq=newFreq;
            oldQCount3=quadCount3;

            newFreq= (((double)(oldQCount1))/10);
            setFrequency0(newFreq+offsetFreq);

            newFreq= (((double)(oldQCount2))/10);
            setFrequency1(newFreq+offsetFreq);
            
            updateDisplay();
            updateLED();
        
        }
    }
    
    
}