Issues with using GPS & servo together


i working on autonomous car.  i using arduino uno sparkfun's gps shield (http://www.sparkfun.com/products/10709).  i trying control front servo of traxxas slash rc car (http://www3.towerhobbies.com/cgi-bin/wti0001p?q=1&i=lxuvy4).  

when code activating gps commented out (see below), servo works expected.   example, in video, instructed point straight ahead, does.
http://www.youtube.com/watch?v=oblqg-lcnxq

however, when servo , gps both activated in code, every time gps updates, servo turns extreme position.  in video, while want servo stay pointed straight ahead, can see alternates between being straight ahead , hard right:
http://www.youtube.com/watch?v=2oz0vhsytpc

here i've tried far:
•   i tried plugging servo variety of digital pins, each of either had same effect or broke gps (e.g., digital pin 2 broke it).
•   i tried variety of different servos--the servo under ultrasonic sensor , rc car's esc (which receives servo-like signal)

how can fix such gps data without compromising steering?

wiring


program
code: [select]

// gps code adapted http://www.sparkfun.com/tutorials/173
// servo code adapted http://arduino.cc/it/tutorial/sweep

boolean debug = true;

// setup gps
#include <softwareserial.h>
#include <tinygps.h>
#define rxpin 2
#define txpin 3
#define gpsbaud 4800
tinygps gps;
softwareserial uart_gps(rxpin, txpin);
float latitude, longitude;

// setup steering servo
#include <servo.h>
servo steeringservo;  // 1000 < input < 2000 us

void setup() {
 serial.begin(115200);
 
/*
 // start gps
 uart_gps.begin(gpsbaud);
*/
   
 // start steering servo
 steeringservo.attach(8);
}

void loop() {
/*
 // read gps
 while(uart_gps.available())
 {
     int c = uart_gps.read();
     if(gps.encode(c))
     {
       gps.f_get_position(&latitude, &longitude);
     }
 }
*/
 
 // send steering angle
 steeringservo.writemicroseconds(1500);
}

servos appear use interrupts. softwareserial. if switch hardwareserial (pins 0 , 1) may or may not help.

if not, i'll have suggestion. :)

or else may know answer.


Arduino Forum > Using Arduino > Project Guidance > Issues with using GPS & servo together


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial