Shop OBEX P1 Docs P2 Docs Learn Events
GPS NMEA Parser written in assembly posted to OBEX, need help with Binary Coded — Parallax Forums

GPS NMEA Parser written in assembly posted to OBEX, need help with Binary Coded

ry.davidry.david Posts: 63
edited 2010-04-07 03:10 in Propeller 1
I uploaded a GPS parser to OBEX, which I wrote for my Prop contest entry. It is the serial receive and parsing all in one cog, written in assembly. I started out with Chip's FullDuplexSerial object and stripped all the transmit functions out of it. Then I started adding parsing functionality to it. Currently it parses GGA and RMC messages, which should have enough information for most people's needs. I tested it at 115,200 baud and position updates at 10Hz.

Now, since NMEA sentences are in ASCII, the output of the driver in the HUB is stored in binary coded decimals. I would like to convert this into standard integers (with a imaginary fixed decimal point) since it would take a lot less space in the HUB, and be far more convenient. I have been racking my brain for tricks to do this without subtracting $30, and then multiplying by the appropriate power of ten. Anyone have any ideas on how to do this?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-02 01:42
    If you want integers, you need the multiplication by 10, but that can be done easily in a few instructions. Remember that 10 = 2 x 5 and 5 = 4 + 1. If your original value is in X, you need:
       mov   temp,X   ' start with original value
       shl   temp,#2   ' multiply by 4
       add   temp,X   ' add one more to get 5
       shl   temp,#1   ' multiply the result by 2
    

    The result is in temp.· If you want to accumulate the result using ASCII digits, you'd add:
       add   temp,ascii   ' add the new character
       sub   temp,#"0"   ' compensate for ASCII
       mov   X,temp   ' this becomes new original value
       jmp   #getNewDigit
    
    

    Post Edited (Mike Green) : 3/2/2010 1:49:02 AM GMT
  • ry.davidry.david Posts: 63
    edited 2010-03-03 00:44
    I knew there was a trick to doing it... I'll re-write and update OBEX. Thanks Mike!
  • rhuggrhugg Posts: 14
    edited 2010-04-04 02:58
    David, i read your obx post with interest and took it for a test drive. I am an ASM newb, and would like to understand this better. Do you have any further documentation?

    -Rob
  • AleAle Posts: 2,363
    edited 2010-04-04 12:57
    david: Did you already look here ? propeller.wikispaces.org/MATH

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit some of my articles at Propeller Wiki:
    MATH on the propeller propeller.wikispaces.com/MATH
    pPropQL: propeller.wikispaces.com/pPropQL
    pPropQL020: propeller.wikispaces.com/pPropQL020
    OMU for the pPropQL/020 propeller.wikispaces.com/OMU
    pPropellerSim - A propeller simulator for ASM development sourceforge.net/projects/ppropellersim
  • rhuggrhugg Posts: 14
    edited 2010-04-04 13:20
    Very nice, this is a good start.
  • ry.davidry.david Posts: 63
    edited 2010-04-04 17:32
    Rob,· I can see what I can put together for documentation.· Honestly, I haven't had much time to work on this ( I haven't even had a chance to implement Mike's math trick above).· I am moving tomorrow but in a few days hopefully I can write something up
  • rhuggrhugg Posts: 14
    edited 2010-04-04 21:36
    Thanks Ryan. Sorry i'm not close, i could help you move!
  • SRLMSRLM Posts: 5,045
    edited 2010-04-07 03:10
    Funny how efforts can be duplicated. I wrote something last summer that did almost the exact same thing (located here), but I didn't post it in the obex for lack of documentation and exhaustive testing. I suppose I should do that, but then it would make duplicates...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Powered by enthusiasm
Sign In or Register to comment.