I am having trouble with IR control, im first time in arduino building, but for arduino DUE only working IR library is IRremote2.h and with standard servo.h i got error, but separate they both work, IRLib doesn't work for me, can someone help me get right servo and IR libraries? We have project to complete in 7 days, our studies depends on that, so it does matter. Thanks
for arduino DUE only working IR library is IRremote2.h and with standard servo.h i got error
And the error is ????
And the code is ????
collect2.exe: error: ld returned 1 exit status
Using library Servo at version 1.1.1 in folder: C:\Program Files (x86)\Arduino\libraries\Servo
Using library IRremote in folder: C:\Program Files (x86)\Arduino\libraries\IRremote (legacy)
exit status 1
Error compiling.
Code is IRrecvDemo from examples with servo library included
I am little stupid for this, UPDATE:
libraries\IRremote\IRremote2.cpp.o: In function `TC3_Handler':
C:\Program Files (x86)\Arduino\libraries\IRremote/IRremote2.cpp:386: multiple definition of `TC3_Handler'
libraries\Servo\sam\Servo.cpp.o:C:\Program Files (x86)\Arduino\libraries\Servo\src\sam/Servo.cpp:52: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling.
If i am right, there are 2 Timing controls, 2 of TC3, how to fix?
I see the same Problem.
If I Compile a Sketch for the Arduino DUE using both SERVO and IRREMOTE/2 ,
- I get the same TC3_Handler Error.
The ridiculous thing is that the same Sketch compiles OK for an Arduino UNO / MiniPro ... !
Is there a Solution to work around this ?
- Such as Changing the Timer for SERVO or IRREMOTE/2 ?
-- This still seems like an Open and UnSolved Problem.
It seems that both IIR and the SERVO libraries use the same TC Handler. A workaround would be to look over these Libraries and use another TC Handler in one of them.
I was checking if someone had already solved this problem.
It seems that the problem has been around for more than a year now.
I have worked on the Arduino Uno/Mini for years - and have modified some of the Libraries.
But, I just started with the Due, and find the Sam Timers on it a little overwhelming to try fixing yet.
I am sure that I am not the only person,
- interested in using an IFR Remote with Servo Motors on the Arduino Due ...
A simple method would be to spot the lines where a timer counter is used in one of the libraries, and modify Timer Counter 1 Channel 0 (i.e. TC3) by, for example, Timer Counter 0 Channel 0 (i.e. TC0) if this timer is not used elsewhere.
I figured that, but I am looking for working solutions ... considering the DUE is more complicated with Timers.
Actually, below is from the IRremote Lib:
// Arduino Due
#elif defined(__SAM3X8E__) || defined(__SAM3X8H__)
//#define IR_USE_PWM0 // tx = pin 34
//#define IR_USE_PWM1 // tx = pin 36
//#define IR_USE_PWM2 // tx = pin 38
//#define IR_USE_PWM3 // tx = pin 40
//#define IR_USE_PWM4 // tx = pin 9
//#define IR_USE_PWM5 // tx = pin 8
#define IR_USE_PWM6 // tx = pin 7
//#define IR_USE_PWM7 // tx = pin 6
#define IR_USE_TC3 // Use timer clock 3.
//#define IR_USE_TC4 // Use timer clock 4.
//#define IR_USE_TC5 // Use timer clock 5.
#define IR_USE_SAM // Used to correct code where needed to be compatible with the Due.
#define IR_USE_DUE // Used to correctly map pins. (The idea being there might be more than one Arduino model based on SAM cores.)
- Which in itself does not match pin3 for the IRsend standard pin.
Anyway, I changed the LIB - to test TC3 / TC4 / TC5 - they all conflict with SERVO.
- ???
It seems pretty annoying, that the Servo uses all of the spare Timers TC3 & TC4 & TC5.
- Does anyone know a solution to this ?
Tried to solved it.
Try to disable both Timer3 and Timer1 in the Lib file.
In the libraries/servo-src/sam/ServoTimers.h :
I changed this :
// For SAM3X:
#define _useTimer1
#define _useTimer2
#define _useTimer3
#define _useTimer4
#define _useTimer5
To this :
// For SAM3X:
/// Added - JLC - 20180125 : ///
#define DISE_TIMER3 1
#ifndef DISE_TIMER3
/// if Disable Timer3 then Disable Timer1 that uses Timer3 : ///
#define _useTimer1
#endif
#define _useTimer2
/// Removed for IFR usage - JLC 20180125 : ///
#ifndef DISE_TIMER3
#define _useTimer3
#endif
#define _useTimer4
#define _useTimer5
UPDATE:
TESTED - eveything Works EXCEPT for the SERVO MOTOR(s)
All this does is DISABLE the SERVO MOTOR(s) capability.
-- Conclusion: Can Not use the SERVO and IRremote at the same time on Arduino DUE.
I found a solution.
In servo ,disable _useTimer3.(because _useTimer3 use TC5_Handler)
In the libraries/Servo/src/sam/ServoTimers.h
#define _useTimer1
#define _useTimer2
//#define _useTimer3
#define _useTimer4
#define _useTimer5
#if defined (_useTimer3)
#define TC_FOR_TIMER3 TC1
#define CHANNEL_FOR_TIMER3 2
#define ID_TC_FOR_TIMER3 ID_TC5
#define IRQn_FOR_TIMER3 TC5_IRQn
#define HANDLER_FOR_TIMER3 TC5_Handler
And in IRremote , use time clock 5.
In the libraries/IRremote/IRremoteInt2.h
#elif defined(SAM3X8E) || defined(SAM3X8H)
//#define IR_USE_TC3 // Use timer clock 3.
//#define IR_USE_TC4 // Use timer clock 4.
#define IR_USE_TC5 // Use timer clock 5.
Everything works fine!
Will try it out.
- Thanks YunNuoChen !