Autopilot compass help


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Some interesting possiblities ...

    Math help - rolling average Wind Direction
    http://www.picbasic.co.uk/forum/showthread.php?t=6650
    <br>
    DT

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    This is part of the code that does that for the RCAP autopilot. I think it will help you. If you still have problems, let me know.

    Code:
    'b2dest is bearing to destination ie direction to assigned waypoint
    'cmg course made good, in this case from a gps, current course direction of vehicle
    'offcourse is the difference between b2dest and cmg
    'dir_steer : which direction to steer the servo
    
            IF cmg > b2dest Then    'IF cmg > b2dest Then
                dir_steer = 1
                offcourse = cmg - b2dest        'offcourse = cmg - b2dest
            Else
                dir_steer = 0
                offcourse = b2dest - cmg           'offcourse = b2dest - cmg
            EndIF
                                     
            offcourse = offcourse / 10 ' Get rid of the fraction
    
            'If more than 180 degrees offcourse change direction 
            'to take the shortest turn to our course
            IF offcourse > 180 Then             
                 dir_steer = dir_steer ^ %1    'switch direction to steer servo               
                 offcourse = 360 - offcourse
            EndIF
    Last edited by ScaleRobotics; - 6th May 2009 at 06:45.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Thanks heaps guys just what I needed - a slightly different approach works a treat.

  4. #4
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    I cant believe how simple that is - I must be getting senile dementia!

Similar Threads

  1. I2C Comm with Digital Compass HMC6352
    By jihlein in forum Serial
    Replies: 10
    Last Post: - 9th April 2008, 22:25
  2. Compass module and I2C bus
    By vladimir059@hot in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th December 2006, 20:29
  3. Chipselect Var PORTD,Vecto4X Compass
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th April 2006, 01:50
  4. Digital Compass Project
    By BJSmith in forum Serial
    Replies: 2
    Last Post: - 7th April 2006, 19:32
  5. I2C compass - Philips KMZ51
    By barkerben in forum General
    Replies: 0
    Last Post: - 25th December 2005, 20:10

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts