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;
- SoftwareSerial for GPS communication using TinyGPS.
- I am using the USB serial connection to monitor the code on my PC with Serial Monitor. This will not be required after development.
- Wire Library fro I2C communication with a compass (HMC5883L) and Barometer (BMP085).
- 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!