error in the program


this program senses rpm , actuates servo motor according rpm. im having trouble error message here.

error msg is:



servo\servo.cpp.o: in function `__vector_11':
f:\backup\arduino-1.0.5-windows\arduino-1.0.5\libraries\servo/servo.cpp:103: multiple definition of `__vector_11'
sketch_jun18a.cpp.o:f:\backup\arduino-1.0.5-windows\arduino-1.0.5/sketch_jun18d.ino:64: first defined here


program is:



#include <servo.h>
servo myservo;

 
int ledpin = 13;  // ir led connected digital pin 13
#define ledpin 5
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;

// include library code:
#include <liquidcrystal.h>
// initialize library numbers of interface pins
liquidcrystal lcd(7, 8, 9, 10, 11, 12);

void rpm_fun()
{
   //each rotation, interrupt function run twice, take consideration
   //calculating rpm
   //update count
      rpmcount++;
}

void setup()

   {
  myservo.attach(3);   
  pinmode(ledpin, output);
 
 
  // initialize timer1
  nointerrupts();           // disable interrupts
  tccr1a = 0;
  tccr1b = 0;
  tcnt1  = 0;

  ocr1a = 0.5;            // compare match register 16mhz/256/2hz
  tccr1b |= (1 << wgm12);   // ctc mode
  tccr1b |= (1 << cs12);    // 256 prescaler
  timsk1 |= (1 << ocie1a);  // enable timer compare interrupt
  interrupts();             // enable interrupts





   lcd.begin(16, 2);  // intialise lcd

   //interrupt 0 digital pin 2, ir detector connected
   //triggers on falling (change high low)
   attachinterrupt(0, rpm_fun, falling);

   //turn on ir led
   pinmode(ledpin, output);
   digitalwrite(ledpin, high);

   rpmcount = 0;
   rpm = 0;
   timeold = 0;
}

isr(timer1_compa_vect)          // timer compare interrupt service routine
{
  digitalwrite(ledpin, digitalread(ledpin) ^ 1);   // toggle led pin
}


void loop()
{
   //update rpm every second
   delay(1000);
   //don't process interrupts during calculations
   detachinterrupt(0);
   //note 60*1000/(millis() - timeold)*rpmcount if interrupt
   //happened once per revolution instead of twice. other multiples used
   //for multi-bladed propellers or fans
   rpm = 30*1000/(millis() - timeold)*rpmcount;
   timeold = millis();
   rpmcount = 0;

   //print out result lcd
   lcd.clear();
   lcd.print("rpm=");
   lcd.print(rpm);
   
   if (rpm>1500)
   {
     myservo.write(90);
   }
   else if(rpm>1400)
   {
        myservo.write(80);
   }
    else if(rpm>1200)
   {
        myservo.write(70);
   }
    else if(rpm>1000)
   {
        myservo.write(60);
   }
    else if(rpm>800)
   {
        myservo.write(50);
   }
    else if(rpm>600)
   {
        myservo.write(40);
   }
    else if(rpm>200)
   {
        myservo.write(30);
   }
    else if(rpm>100)
   {
        myservo.write(20);
   }
    else if(rpm>50)
   {
        myservo.write(10);
   }
    else if(rpm<50)
   {
        myservo.write(0);
   }
   
 

   //restart interrupt processing
   attachinterrupt(0, rpm_fun, falling);
  }

the servo library uses same timer interrupt ( __vector_11 ).

code: [select]
isr(timer1_compa_vect)          // timer compare interrupt service routine
{
  digitalwrite(ledpin, digitalread(ledpin) ^ 1);   // toggle led pin
}


what arduino using?


Arduino Forum > Using Arduino > Programming Questions > error in the program


arduino

Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support