Author Topic: including multiple header = error ???  (Read 4121 times)

0 Members and 1 Guest are viewing this topic.

Offline ishkaTopic starter

  • Jr. Member
  • **
  • Posts: 38
  • Helpful? 0
    • Unifestival
including multiple header = error ???
« on: June 13, 2010, 01:53:02 PM »
Hello,

I'm working on the V2.0 of my ikeabot and thought it would be great to add some sound.
I'm working on an arduino 328, and find RTTTL tone library.
If I include <Tone.h> and try to play some sound, it works ( and it's fun too ;-) )
But if I try to combine this with my code, I got this error :
Code: [Select]
/tmp/build5446.tmp/Tone/Tone.cpp.o: In function `__vector_11':

/Users/oli/Documents/Arduino/libraries/Tone/Tone.cpp:438: multiple definition of `__vector_11'

/tmp/build5446.tmp/Servo/Servo.cpp.o:/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/Servo.cpp:103: first defined here

I even get an error in Servo header, wich is included in the arduino environnement and with wich I never had any problem before.
I looked at arduino forum, seems that other got my problem in 2009 but they never get a soluce. I wonder if it has something to do with my -bad- programmation skills or with the arduino IDE.

Thanks for your help,
May the Achtuche be with you...

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: including multiple header = error ???
« Reply #1 on: June 13, 2010, 07:26:42 PM »
Its not you - its because the Tone library and the Servo library use the same Timer1 interrupt vector. Only solution is to change the code for one of them to use a different (unused) timer - which will be a problem on the 328 as there is only 1 x 16 bit timer.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline ishkaTopic starter

  • Jr. Member
  • **
  • Posts: 38
  • Helpful? 0
    • Unifestival
Re: including multiple header = error ???
« Reply #2 on: June 14, 2010, 01:32:46 AM »
Oh  :-\.

Well, I know there's also 2 8-bit timers on the Atm328 but I'm not sure I want to play with these things. Perhaps I should let down my idea for sound till I know how to manage the timer.
(come on, why not using another timer than the servo's one ??? ::)  ;) )

Thx for the fast reply. I'll concentrate on an other way of making ikeabot more "fun"
May the Achtuche be with you...

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: including multiple header = error ???
« Reply #3 on: June 14, 2010, 05:47:15 AM »
If you don't need the Servo library, just move it out of the Libraries folder in Arduino, compile your sketch, then later, when you will start using it, move it back (and if you still get errors, move out the Tone library). This way the compiler is not confused by stuff that's not used.
Check out the uBotino robot controller!

Offline ishkaTopic starter

  • Jr. Member
  • **
  • Posts: 38
  • Helpful? 0
    • Unifestival
Re: including multiple header = error ???
« Reply #4 on: June 14, 2010, 10:15:05 AM »
Yes, it could be an option ... if only I wasn't using the servo library :-/
What I wanted to do is programming my ikeabot so when it encounter an obstacle, it stops and plays a little song while scanning the object to find a way around. But I leave the sound for now, I don't want to mess everything in the fuse now... ;-)
May the Achtuche be with you...

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: including multiple header = error ???
« Reply #5 on: June 14, 2010, 11:14:56 AM »
Before there was the Tone library I made a simple one that I called Speaker. You can use this one and it will not mess up too much with the servos, but you should know that Servo lib uses Timer1 to generate interrupts and this process will interrupt a melody from playing, so you might hear some unwanted vibrations. I only have one melody in the cpp file, you can edit that one and add more melodies and pass a melody name to the PlayMelody() function. That is what I wanted to do in the first place but never got the time to follow up.
Check out the uBotino robot controller!

Offline ishkaTopic starter

  • Jr. Member
  • **
  • Posts: 38
  • Helpful? 0
    • Unifestival
Re: including multiple header = error ???
« Reply #6 on: June 14, 2010, 02:45:15 PM »
Thanks a lot !
I'll get a look at this when I'll come back from London.
If I stop the robot before playing anything I suppose there won't be any interruption of the melody.

If I manage to use it and add some other melodies I'll repost the zip here.

Thanks again.
May the Achtuche be with you...

 

SMF spam blocked by CleanTalk