Page 1 of 47 1 2 3 11 ... LastLast
Results 1 to 10 of 468

Thread: PICAXE handling GPS for robot boat

  1. #1
    Senior Member
    Join Date
    Aug 2009
    Location
    Sunninghill UK
    Posts
    263

    Default PICAXE handling GPS for robot boat

    Hi Folks. Yes, I'm afraid it's me again, after the BBC bottles in the sea on www.gpss.co.uk/bbcbot.htm (causing that rare earthquake), I'm back onto the robot boat stuff - checkout the "Snoopy Sails!" video on www.gpss.co.uk/autop.htm - and give yourself time to stop laughing :-)

    This thread is about using ONLY a PICAXE and GPS to control a robot boat to sail the Atlantic, from UK to America - north or south is OK.

    The existing prototypes are all similar in principle, using an iPAQ to take data from the GPS, do all the navigation logic, and just using a PICAXE servo driver to drive the vane-rudder to steer the boat.

    I'm thinking of a radically simpler solution: just a GPS-PICAXE-Servo to keep the boat sailing roughly west all the time.
    Result would be a much smaller and lower cost boat, maybe only 1 foot to 2 foot long.

    Key to it is the required logic to extract GPS heading from the NMEA $GPRMC sentence.
    All the other fields of data, like latitude and longitude can be skipped.
    I've pasted in the code below from the little program you guys helped me with a year or two back.

    An example NMEA sentence from the GPS is:
    $GPRMC,114801,A,5129.8944,N,00041.0771,W,3.53,358. 23,280608,,*18

    The program needs to look for the $GPRMC because there will be other sentences like $GPGGA etc.
    The characters it needs are the heading in 358.23

    It would be good if the logic could do something like look for the commas (,)
    to cover different types of GPS, which may have different field sizes. e.g. 358 instead of 358.23

    It does not need to work east of the Greenwich meridian, so we might look for ,W, after the $GPRMC

    After extracting the characters, such as 358.23 I then need this as a value.
    It does not need to be accurate - a simple integer 0 to 359 will be OK (degrees clockwise from north).
    So I need the three bytes 3 5 and 9 to be converted into a number value 359.

    I'll then do some simple logic to drive the steering servo.

    It seems that example code below, that I did with your help, might get me started.
    But - as always - you guys might save me a lot of time.

    Let me guess what might work:
    SERIN 3,N4800_8,("$GPRMC,") 'look for the $GPRMC
    SERIN 3,N4800_8,(",W,") 'now look for ,W,
    SERIN 3,N4800_8,(",") 'skip over the speed

    Now I'm struggling :-)

    Many Thanks in advance
    Robin
    www.gpss.co.uk

    Code:
     
    'SC2.BAS iPAQ switch for robot boat
    'v1a 13 Sep 2009 (c) Robin Lovelock www.gpss.co.uk/autop.htm 
    'Thanks to LBenson, Eclectic and Hippy on www.picaxeforum.co.uk
    'input is serial RS232 GPS data - to see when GPS is ready
    'the GPS outputs text strings and includes ",A," after $GPRMC when ready
    'e.g. $GPRMC,114801,A,5129.8944,N,00041.0771,W,3.53,358.23,280608,,*18
    'e.g. $GPRMC,114801.123,A,5129.8944,N,00041.0771,W,3.53,358.23,280608,,*18
    'output is servo controlling switching of iPAQ power ON
    'note that no need to use or hold servo until just before exit
    
     #Picaxe 08M
     SETFREQ M8 '8MHz for SERIN 
    
     'wait until GPS ready $GPRMC,114801,A,5129.8944,N, etc,etc
    waitgps: '
     SERIN 3,N4800_8,("$GPRMC,"),b0,b0,b0,b0,b0,b0,b0,b1 'Eclectic
     'SERIN 3,N4800_8,("$GPRMC,")
     'SERIN 3,N4800_8,(","),b1 'idea from lbenson on picaxe forum
     if b1 <> "A" then 'this idea from eclectic on picaxe forum
       goto waitgps
     endif
     
     SETFREQ M4 'standard 4MHz
     PAUSE 1000
     
     SERVO 1,91
     PAUSE 1000
     SERVOPOS 1,126 'toggle servo to switch on iPAQ power
     PAUSE 1000
     SERVOPOS 1,91
     PAUSE 3000 'give servo time to travel then exit

  2. #2
    Member
    Join Date
    Feb 2010
    Location
    North Wales
    Posts
    60

    Default

    With the sample code you've posted, i.e. reading GPS data into b0, b1 etc, it gets a bit messy when the position of the value you want is changing because a previous value has gone from 1 to 3 digit for example. The method I'm using for a high altitude balloon is to identify the string you want, (in this case $GPMRC) and then count through the commas to get to the field you want. Extract the values and then process accordingly.

  3. #3
    Senior Member
    Join Date
    Aug 2010
    Location
    Behind your TV...
    Posts
    784
    Blog Entries
    6

    Default

    http://www.picaxeforum.co.uk/showthr...pdate-not-good
    The idea looks like it never got off the drawing board due to the numerous problems: Choppy seas, waterproofing, power, laws, etc.

    You will need to test the boat (the atlantic is roughly 106,400,000,000 times bigger than your boat) and may want to sail by the side of the boat to make sure it doesn't do anything stupid.

    I will be very interested as to where this goes, I thought about designing an autonomous boat that could sail down a river at least.

    Best of luck,
    Jamster
    20X2 Games pointlessly white text
    Non Hid compliant mice

  4. #4
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    19,943

    Default

    It seems to me that the following should work ...

    SERIN 3, N4800_8, ( "$GPRMC," )
    SERIN 3, N4800_8, ( "," ), b1
    SERIN 3, N4800_8, ( ",W," )
    SERIN 3, N4800_8, ( "," )
    SERIN 3, N4800_8, #w2

    You'll then have the "A" in 'b1' and your 0 to 359 reading in 'w2'.

  5. #5
    Senior Member
    Join Date
    Aug 2009
    Location
    Sunninghill UK
    Posts
    263

    Default

    Brilliant Hippy - as always you come up quickly with the answer.
    Many Thanks. I'll check this out tomorrow.
    Robin
    www.gpss.co.uk

  6. #6
    Senior Member
    Join Date
    Jan 1970
    Location
    Rangiora, New Zealand
    Posts
    1,501

    Default

    Hippy,
    I tried your idea a few years ago. But it didn't work.
    Given the current range of PICAXE chips and their very fast operating clocks (EM32 etc), there should now be enough time to get to the next SERIN and wait for the next ",".

    Robin,
    Would love to read your progress on this project.
    To aid navigation, may I also suggest using a fluxgate sensor (magnetic compass) to give direction information. A few have been discussed on the forum in the past.
    Remember that a GPS only knows its direction when the vessel is underway.

    MPep.
    In theory, there is no difference between theory and practice. In practice, there is...


  7. #7
    Senior Member
    Join Date
    Feb 2011
    Location
    Cardiff,UK
    Posts
    3,517

    Default

    I would suggest an alternative approcah is needed.

    Within the limits of the GPS refresh, the boat might appear to be moving West for instance, but could be creeping North or South, so how much of the East Coast of America can be searched for the boat ?

    And the obvious point, the prevailing winds in the Atlantic are generally West to East, so to go the 'wrong' way you need to tack all the time. Even if you could keep the boat pointing West, its going to be going backwards most of the time.

  8. #8
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    19,943

    Default

    Quote Originally Posted by MPep View Post
    I tried your idea a few years ago. But it didn't work.
    Given the current range of PICAXE chips and their very fast operating clocks (EM32 etc), there should now be enough time to get to the next SERIN and wait for the next ",".
    I wasn't sure about it working but seeing the code example assumed it would - but looking more closely that similar code is commented out.

    You're probably right about speed of execution, too slow to have read one qualifier and/or data to get back and be ready for the next. As you say 32MHz on the M2 and 64MHz on the X2 may overcome that.

    On the X2 there's also the HSERIN background receive; grab a packet then disable receive until processed. A 28X2 may be preferable to a 20X2 for the larger buffer size. The advantage of that is that all the data is available and can use any of it to determine heading and there's probably plenty of time to do any complicated maths.

    Added : Suggested code works okay on 08M2 at 32MHz.
    Last edited by hippy; 27-07-2011 at 20:46.

  9. #9
    Senior Member
    Join Date
    Feb 2011
    Location
    Cardiff,UK
    Posts
    3,517

    Default

    What you probably need is a GPS that can can be pre-programed with a waypoint (NY for instance) and will output the $GPBWC - Bearing and distance to waypoint sentance.

    In this way you stand a chance of being able to correct the 'direction' to allow for current drift, wind, temporary loss of GPS signal etc.

    Other systems can do this sort of calculation within the Micros code, but it really needs floating point maths and trigonometry capability.

  10. #10
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    19,943

    Default

    Code:
    #Picaxe 08M2
    
    ' Test data to send ... $GPRMC,,A,W,,123,
    
    SetFreq M32
    Pause 16000
    SerOut 4, N4800_32, ( "Ready", CR, LF )
    Do
      SerIn  3, N4800_32, ( "$GPRMC," )
      SerIn  3, N4800_32, ( "," ), b1
      SerIn  3, N4800_32, ( ",W," )
      SerIn  3, N4800_32, ( "," ), #w2
      SerOut 4, N4800_32, ( #b1, " ", #w2, CR, LF )
    Loop

Bookmarks

Posting Permissions

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