GPS module + PIC


Results 1 to 13 of 13

Threaded View

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


    Did you find this post helpful? Yes | No

    Default Check Sum

    Here is one check sum solution for gps:

    Code:
    gpsdata         var byte[82]       ' Max length of a GPS sentence is 82 bytes.
    
    DoCS:
        i = 0                             ' Initialize the position counter
                    
        WHILE gpsdata[i] != "*"           ' Count everthing until the *
            cs = cs ^gpsdata[i]           ' XOR for checksum
            i = i + 1                     ' Increment position counter
        WEND
    
        ' A quick and easy atoh function
        ' Make it a seperate label if we add more atoh conversions in the future
        LOOKDOWN gpsdata[i+1],["0123456789ABCDEF"],tempbyte
        gpscs = tempbyte * 16        
        LOOKDOWN gpsdata[i+2],["0123456789ABCDEF"],tempbyte                
        gpscs = gpscs + tempbyte
            
        ' Flag bad data "V" if checksum doesn't add up. 
        ' Or if the sentence is less then 20 chars long
        ' Which means there is no active waypoint to go to.
        ' Should be "A" otherwise.
        IF (cs != gpscs) OR (i < 20 )THEN 
              gpsvalid = 0
        ELSE 
              gpsvalid = 1
        ENDIF   
    RETURN
    Last edited by ScaleRobotics; - 10th April 2010 at 14:26.

Members who have read this thread : 2

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