Go Down

Topic: Servo library + timer library? (Read 1 time) previous topic - next topic

motomoto

Hi,

I'm trying to operate a few servos simultaneously without using the delay() function. I want to use a timer library to rotate a servo back to its starting positions after a set delay. However I want to operate other servos during that delay.

I've experimented with a couple of timer libraries posted here. However as far as I understand the timer libraries and the servo library use the same hardware timers on the Due. Consequently, the Arduino IDE would not let me compile while using both libraries.

What are some possible workaround for this? I need to operate 11 servos total, maybe 3 of them simultaneously.


ivanseidel

Can you detail the problem? I mean, what happens when you create both Servo and Timer? No one works, the last one works...

And also, have you tried using others timers (0,1,2,3,4,5,6,7,8)?

Did you used my library? github.com/ivanseidel/DueTimer

Ivan

sydian

Hi,
I have the same problem as motomoto. When I include both DueTimer.h and Servo.h, I get:
Code: [Select]
sam\Servo.cpp.o: In function `TC0_Handler':
C:\Program Files (x86)\Arduino-1.0.5\Arduino\libraries\Servo\arch\sam/Servo.cpp:75: multiple definition of `TC0_Handler'
DueTimer_master\DueTimer.cpp.o:C:\Users\sydian\Documents\Arduino\libraries\DueTimer_master/DueTimer.cpp:231: first defined here
sam\Servo.cpp.o: In function `TC2_Handler':
C:\Program Files (x86)\Arduino-1.0.5\Arduino\libraries\Servo\arch\sam/Servo.cpp:70: multiple definition of `TC2_Handler'
DueTimer_master\DueTimer.cpp.o:C:\Users\sydian\Documents\Arduino\libraries\DueTimer_master/DueTimer.cpp:239: first defined here
sam\Servo.cpp.o: In function `TC5_Handler':
C:\Program Files (x86)\Arduino-1.0.5\Arduino\libraries\Servo\arch\sam/Servo.cpp:65: multiple definition of `TC5_Handler'
DueTimer_master\DueTimer.cpp.o:C:\Users\sydian\Documents\Arduino\libraries\DueTimer_master/DueTimer.cpp:251: first defined here
sam\Servo.cpp.o: In function `TC4_Handler':
C:\Program Files (x86)\Arduino-1.0.5\Arduino\libraries\Servo\arch\sam/Servo.cpp:60: multiple definition of `TC4_Handler'
DueTimer_master\DueTimer.cpp.o:C:\Users\sydian\Documents\Arduino\libraries\DueTimer_master/DueTimer.cpp:247: first defined here
sam\Servo.cpp.o: In function `TC3_Handler':
C:\Program Files (x86)\Arduino-1.0.5\Arduino\libraries\Servo\arch\sam/Servo.cpp:55: multiple definition of `TC3_Handler'
DueTimer_master\DueTimer.cpp.o:C:\Users\sydian\Documents\Arduino\libraries\DueTimer_master/DueTimer.cpp:243: first defined here
collect2: ld returned 1 exit status

Has someone any clue how to avoid this ?

ivanseidel

Hello,

Because there are some people with this problem, I made a modification on DueTimer that will allow you to put to work both Servo and DueTimer together.

I didn't have time to test, but I'm pretty sure everything will work just fine.

Here is the documentation on how to make it work: https://github.com/ivanseidel/DueTimer#compatibility-with-servoh

Go Up