hallo ehenkes,

mal eine Frage an den Fachmann:

Ich habe deinen Code geflasht:

Code:
/*****************ultrasonic********************************/
/**
 * being used insted TIMER2_OVF_vect during ultrasonic polling
 */
ISR(TIMER2_COMP_vect)
{
   //TCNT2 += 0x25; //Wichtig!! Die Zeile muss entfernt werden, damit es funktioniert. 
   count36kHz++;
   if(!count36kHz) timebase++;
}

/**
 * initialises the Ultrasonic module
 * this function is automaticly called by Chirp
 */
void InitUltrasonics(void)
{
   // Change Oscillator-frequency of Timer 2
   // to 40kHz, no toggling of IO-pin:
   TCCR2  = (1 << WGM21) | (1 << CS20);
   OCR2   = 100;              // 40kHz @8MHz crystal
   TIMSK |= (1 << OCIE2);     // OCIE2:  Timer/Counter2 Output Compare Match Interrupt Enable

   ADCSRA = (0 << ADEN);      // deactivate ADC
   ACSR  |= (1 << ACIS1);     // Comparator Interrupt on Falling Output Edge

   ADMUX  = 0x03;             // connect ADC3-input with comparator
   SFIOR |= (1 << ACME);      // connect ADC multiplexer to comparator
   DDRD  &= ~(1 << 6);        // use Port D Pin 6 as input (AIN0)
}

/**
 * restores the hardware after using the Ultrasonic module
 * this function is called automaticly after a Chirp
 */
void RestoreAsuro(void)
{
   TCCR2 = (1 << WGM20) | (1 << WGM21) | (1 << COM20) | (1 << COM21) | (1 << CS20);
   OCR2  = 0x91;              // duty cycle for 36kHz
   TIMSK |= (0 << OCIE2);     // OCIE2:  Timer/Counter2 Output Compare Match Interrupt Enable

   ADCSRA = (1 << ADEN) | (1 << ADPS2) | (1 << ADPS1); // clk/64
   ACSR  |= (0 << ACIS1);

   if(autoencode) 
   {
      EncoderInit();
   }

   Sleep(1);
}

/**
 * @return distance in cm
 */
int Chirp(void)
{
   unsigned int sleeptime = 0, dist = 0;

   InitUltrasonics();

   // chirpen:
   count36kHz = 0;

   while(count36kHz != 20) 
   {
      OCR2 = 100 + 20 / 2 - count36kHz;
   }

   TCCR2   = (1 << WGM21) | (1 << CS20);
   OCR2   = 100;

   // analyse echoes:
   while(TRUE) 
   {
      Sleep(1);
      sleeptime++;

      if((ACSR & (1 << ACI))) 
      {
         // Hinweis: 344 m/s Schallgeschwindigkeit in Luft bei ca. 20°C       
         dist = (unsigned int) ((long) ((344L * ((sleeptime * 1000L) / 72L) / 10000L) / 2L)); 
         ACSR |= (1 << ACI);
         break;
      }

      ACSR |= (1 << ACI);

      if(sleeptime > 3500) 
      {
         return -1;
      }
   }

   RestoreAsuro();
   return dist;
}
Wenn ich nun den Asuro einschalte fährt er nur Ruckartig rückwärts, wenn ich meine Hand davorhalte fährt er gleichmässig rückwärts. Leider nie vorwärts

Die US-Sensoren scheinen zu funktionieren, oder nicht?