GPS Refresh Rate Problems

Hi All!

I have been working on creating my first drone. I began this project by testing my own arduino based PID controller. Then I moved on to actually installing the PID and accelerometer/gyroscope into an RC glider to test for level flight (http://www.instructables.com/id/Intro-to-Model-Airplane-Autopilot/). I am moving on to a powered plane(I am starting with an E-flite UltraStick, and moving on to a water plane I have built once I have successful beta testing). I want to use cascading PIDs and a GPS to set the attitude my plane needs to reach desired waypoints. 

The problem is: my accelerometer and gyroscope refresh at about 20Hz while my GPS only refreshes at about 1Hz- I am using a parallax PMB 648, a cheapy, I know. In my loop function I tell the controller to get the accelerometer/gyroscope data (which comes in almost instantly), and then I have to wait a full second for the GPS data. So the plane would be unable to monitor and control its attitude while the GPS is refreshing. Is there a way to solve this problem without buying a faster GPS??

I tried setting up an interrupt function last night, but I couldjnot get it to work. In addition, the GPS communicates with the arduino serially, and from what I have heard this is not ideal for setting up interrupts. 

Any help would be much appreciated!!!

Thanks

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • I timed all of my functions to see how long they would take to run. I was almost ready to set up the duty cycles like you said, when I ran into a new problem!
    I know I am getting a little off topic here, but I need help...
    I tried mounting my sensors to the plane to make sure I would not have issues with electronic interference. As it turns out, I am having mechanical interference. When I hold the sensors above the plane, no problems. As soon as the sensor make contact with the plane with the motor running, my sensor values go all over the place. What should I do!!!
    I am leaving for a trip to Idaho next weekend, where I was planning the maiden flight of my system. If need be I can order new sensors to be delivered to our property...
    I am using some osepp brand sensor I bought from frys. They run an ADXL345 (accelerometer) and MPU 3050(gyroscope).
    I wrote a program to try and filter the values. I filled an array of the 20 previous values and took the median. This worked on an earlier project but is no longer sufficient. In addition, it creates a sizable delay in my sensor values...
    What should I do?
  • Your best bet is to set up a serial interrupt handler but there's a simple, easy way to do this too until you become more familiar with interrupts on the AVR.

    First, you'll use Serial.available() to determine if serial data is available to be read using Serial.read()

    To run specific tasks at specific times, but avoid wasting time using delay(), you set up in your loop() function a series of if-then-else which check the current time to see if it's time to run each task.

    Let's say your gyro updates at 100hz, your compass at 20hz, and your gps at 1hz. It'll look something like this.

    http://pastebin.com/Kxvq5wbG

This reply was deleted.

Activity

David Hori liked Isabella Domi's profile
Jan 12
gotham liked gotham's profile
Dec 3, 2020
More…