Servo Interference - Playmobil Drone Project 95% complete

Hello! This is my first post - I need some advice for my project...

My project is a GPS controlled model glider which steers to a specific location using a rudder Servo.

I am using the following methods of control and will happily publish my sketch if it helps;

  1. SoftwareSerial for GPS communication using TinyGPS.
  2. I am using the USB serial connection to monitor the code on my PC with Serial Monitor. This will not be required after development.
  3. Wire Library fro I2C communication with a compass (HMC5883L) and Barometer (BMP085).
  4. The Servo library for the servo

Everything works except for the servo, which twitches or does not move.

I have tried running it from a separate power source, small and large capacitors to smooth out power draw or interference with no luck. I have a theory that the problem lies with the software serial and servo. The timer used to create the PWM for the servo is somehow confused whilst communicating with the GPS with SoftwareSerial. Other posts mention this possibility, but I have not found a solution.

I am considering the following solutions; A. Hardware/Software: To avoid using SoftwareSerial I could use the main Serial port for the GPS using the TX/RX pins. Would this solve the problem? Does it have a seperate timer? I do not need to monitor the program with my computer. B. Hardware: Add a capacitor/resistor or something somewhere? I have tried across the Servo power terminals but this did not help. C. Software: Introduce delays between GPS reading and servo writing to let the clock/timer/thing focus on one thing at a time. GPS could be read only every 5 seconds whilst compass and servo are controlled in between. (I have tried Servo.disconnect and reconnect within my loop, but this did not help). Does anyone know if this would help or how this could be accomplished?

Any advice would be gratefully appreciated. If anyone wants any more information to help or to copy what I am doing, feel free to ask!

Thanks :)

Robin

I have a theory that the problem lies with the software serial and servo. The timer used to create the PWM for the servo is somehow confused whilst communicating with the GPS with SoftwareSerial.

You might, if the necessary pins are available (or could be made available) try AltSoftSerial.

The problem is that receiving characters using SoftwareSerial is interrupt driven, and the interrupt handler takes time to get a byte. During that time, the servo class can't be doing it's thing.

A. Hardware/Software: To avoid using SoftwareSerial I could use the main Serial port for the GPS using the TX/RX pins. Would this solve the problem?

Yes. If that is the ONLY problem.

Does it have a seperate timer?

Hardware serial does not use a timer.

Thank you Paul - fanstastic - it worked!

For the record, I installed AltSoftServo but recieved the error that, according to further research, was due to the Servo and AltSoftSerial now cerating a conflict.

Servo\Servo.cpp.o: In function `__vector_11':
    C:\Program Files (x86)\Arduino\libraries\Servo/Servo.cpp:103: multiple definition of `__vector_11'
    AltSoftSerial\AltSoftSerial.cpp.o:C:\Users\Robin\Documents\Arduino\libraries\AltSoftSerial/AltSoftSerial.cpp:127: first defined here

I changed from the Arduino default server library to ServoTimer2 (also had to map my degrees to millisecond values which are used in the new libray) and we are now in testing and calibration phase? :))

Best regards and have a great week!

Robin

Robin hi I'm having the same problem about using servo&software serial libraries u solved it by using altsoftserial&ServoTimer2 u saying ?