Same interrupt vektor name in two librarys

I want to control an electronic speed controller using the Servo library. If I just do this it works perfectly fine. The problem is I want to control the motors on the ESC with radios. For that I am using the RadioHead library with on its one also works perfectly fine. As soon as I combine those two this error pops up when compiling:

C:\Users\finnk\AppData\Local\Temp\arduino\sketches\B8377D9F02F93FB3E92431AE5C71C0E6\libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin): In function `RH_ASK::maxMessageLength()':
(.text+0x0): multiple definition of `__vector_11'
C:\Users\finnk\AppData\Local\Temp\arduino\sketches\B8377D9F02F93FB3E92431AE5C71C0E6\libraries\Servo\avr\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here

What is the best way to fix this?

Best is subjective. I have no idea what you may consider to be "best".

One way is to use a different library for one function that does not use the same timer. The servoTimer2 library may be the ticket.

1 Like

I tried this the problem is because it's brushless motors I need to change the maximum and minimum angle. in the normal Servo you can use this function while attaching the Motors: servo.attach(int pin, int minAngle, int maxAngle); if I use the ServoTimer2 library I get this error message: undefined reference to ServoTimer2::attach(int, int, int)';` it seems I can only use the normal attach function which has 0 and 180 as it's angles. Do you maybe know how to do this with the ServoTimer2 library?

Sorry, I just found the function in the header file so it is in the library but what is the reason for the error message?

For informed help, please read and follow the directions in the "How to get the best out of this forum" post.

Post ALL the code, using code tags, and full text of error messages, also in code tags.

This is the code using the ServoTimer2:

//#include <Servo.h>
#include <ServoTimer2.h>

#define value 70

ServoTimer2 m1;
ServoTimer2 m2;
ServoTimer2 m3;
ServoTimer2 m4;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("setup");
  delay(2000);
  m1.attach(10,1000,2000);
  Serial.println("attached Motor 1");
  m2.attach(9,1000,2000);
  Serial.println("attached Motor 2");
  m3.attach(6,1000,2000);
  Serial.println("attached Motor 3");
  m4.attach(5,1000,2000);
  Serial.println("attached Motor 4");
  Serial.println("start calibration");
  for(int powM = 0; powM <= 180 ; powM++){
    m1.write(powM);
    m2.write(powM);
    delay(10);
  }
  Serial.println("max value reached -- phase 1 completed");
  delay(2000);
  for(int powM = 180; powM >= 0; powM--){
    m1.write(powM);
    m2.write(powM);
    m3.write(powM);
    m4.write(powM);
    delay(10);
  }
  Serial.println("min value reached -- phase 2 completed");
  delay(2000);
  Serial.println("setup/calibration completed");
  Serial.println("start m1");
  m1.write(value);
  Serial.println("start m2");
  m2.write(value);
  Serial.println("start m3");
  m3.write(value);
  Serial.println("start m4");
  m4.write(value);
}

void loop() {
  // put your main code here, to run repeatedly:
  /*m1.write(val);
  Serial.println(val, DEC);
  if (val > 10)
    val -= 5; 
  delay(5000);
  m1.write(0);
  delay(3000);*/
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

And this is the full error message to that code:

C:\Users\finnk\AppData\Local\Temp\ccNuufqB.ltrans0.ltrans.o: In function `setup':
D:\Dokumente\Arduino\Komponente\esc\escKalibration/escKalibration.ino:16: undefined reference to `ServoTimer2::attach(int, int, int)'
D:\Dokumente\Arduino\Komponente\esc\escKalibration/escKalibration.ino:18: undefined reference to `ServoTimer2::attach(int, int, int)'
D:\Dokumente\Arduino\Komponente\esc\escKalibration/escKalibration.ino:20: undefined reference to `ServoTimer2::attach(int, int, int)'
D:\Dokumente\Arduino\Komponente\esc\escKalibration/escKalibration.ino:22: undefined reference to `ServoTimer2::attach(int, int, int)'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

now to my original problem...

the code:

#include <Servo.h>
#include <RH_ASK.h>

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

the error:

C:\Users\finnk\AppData\Local\Temp\arduino\sketches\B8377D9F02F93FB3E92431AE5C71C0E6\libraries\RadioHead\RH_ASK.cpp.o (symbol from plugin): In function `RH_ASK::maxMessageLength()':
(.text+0x0): multiple definition of `__vector_11'
C:\Users\finnk\AppData\Local\Temp\arduino\sketches\B8377D9F02F93FB3E92431AE5C71C0E6\libraries\Servo\avr\Servo.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

This fork of the ServoTimer2 library implements the overloaded constructor.

https://github.com/ld21/ServoTimer2

See this uncompleted pull request for the nabontra ServoTimer2 library.
https://github.com/nabontra/ServoTimer2/pull/5

Looks like you are using the wrong ServoTimer2 library. See above.

This version claims to support the attach call with three arguments: Arduino-Libraries/ServoTimer2 at master · Haven-Lau/Arduino-Libraries · GitHub

I think the Haven-Lau library has the same defect as the nabontra version.

The .h file show two functions for .attach()

attach(pin )  - Attaches a servo motor to an i/o pin.
attach(pin, min, max  ) - Attaches to a pin setting min and max values in microseconds

But the .cpp file only contains the function for

uint8_t ServoTimer2::attach(int pin)
{

It's very unfortunate that there is no version of ServoTimer2 available through the library manager, and not all the versions found on GitHub are drop in compatible with the original Margolis
Servo.h library

With this library I get no errors. But the problem is the motors don't turn on. Here is my code:

#include <ServoTimer2.h>
//#include <Servo.h>   

#define value 100

ServoTimer2 m1;
ServoTimer2 m2;
ServoTimer2 m3;
ServoTimer2 m4;

/*Servo m1;
Servo m2;
Servo m3;
Servo m4;*/

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("setup");
  delay(2000);
  m1.attach(10);
  Serial.println("attached Motor 1");
  m2.attach(9);
  Serial.println("attached Motor 2");
  m3.attach(6);
  Serial.println("attached Motor 3");
  m4.attach(5);
  Serial.println("attached Motor 4");
  Serial.println("start calibration");
  for(int powM = 0; powM <= 180 ; powM++){
    m1.write(powM);
    m2.write(powM);
    delay(10);
  }
  Serial.println("max value reached -- phase 1 completed");
  delay(2000);
  for(int powM = 180; powM >= 0; powM--){
    m1.write(powM);
    m2.write(powM);
    m3.write(powM);
    m4.write(powM);
    delay(10);
  }
  Serial.println("min value reached -- phase 2 completed");
  delay(2000);
  Serial.println("setup/calibration completed");
  Serial.println("start m1");
  m1.write(value);
  Serial.println("start m2");
  m2.write(value);
  Serial.println("start m3");
  m3.write(value);
  Serial.println("start m4");
  m4.write(value);
}

void loop() {
  // put your main code here, to run repeatedly:
  /*m1.write(val);
  Serial.println(val, DEC);
  if (val > 10)
    val -= 5; 
  delay(5000);
  m1.write(0);
  delay(3000);*/
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

If I use the same code but with the normal Servo.h the motors turn on as planned.

If you can't get the ServoTimer2 library working as desired, avoid the conflict by using a different radio and/or radio library.

Which radio module are you using?

Try writing a pulse width in microseconds and not in degrees.

void ServoTimer2::write(int pulsewidth)
{	
   writeChan(this->chanIndex, pulsewidth); // call the static function to store the data for this servo	    
}

I am using the Debo 433MHz RX/TX Modul https://www.reichelt.de/entwicklerboards-433-mhz-rx-tx-modul-debo-433-rx-tx-p224219.html

There are plenty of other radio choices. That one requires RadioHead to use Timer1 on AVR based Arduinos, as does the Servo library.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.