Shop OBEX P1 Docs P2 Docs Learn Events
GPS_Basic_spin question — Parallax Forums

GPS_Basic_spin question

w4fejw4fej Posts: 264
edited 2016-03-19 15:12 in Propeller 1
I am trying to use GPS_Basic_spin and can't seem to get the results I though I would get. My super simple application is just a test app to figure out how to use the object by Jonny Mac..

This is the method from GPS_Basic I'm trying to use:

pub n_secs (this is running in the GPS object)

'' Seconds as decimal value, 0..59
'' -- returns -1 if gps string is invalid 

  if (strncmp(@RMC_HDR, @rmcwork, 6) == 0)                      ' have gps data?
    return str2dec(@rmcwork[11], 2)                             ' yes, convert seconds
  else
    return -1                                                   ' no, error

In my app I am trying to recover only the numeric version of UTC time seconds. This is how I have been trying to use it.

value := GPS.n_secs (this is in my app

I get on my display ONLY the units digits of the seconds. 0..9 and repeats. I never get the tens digits.

If I run a little test program where I manually assign a value to "value" without the GPS the digits work fine...

If I run the GPS_Basic_demo all works great with the string versions of the methods but I require the numeric version of the method. I originally thought that maybe by using two different instances of FullDuplexSerial that perhaps that was messing with my data but looking through the forum I see that multiple copies of FDS is OK.. FDS is running in the GPS object and also in the VesiGenie object to write to my display..

Do I need to provide more info here??

Comments

  • I have been learning c and starting a gps from scratch. I took some aspects of the gps_basic_demo and used them. I have attached my code.
    My problems is getting it to run properly with two cogs. Still working on it. This url helped me to parse the data the way I want it.
    http://www.boondog.com/tutorials/gps/gps.html
    checking your work: http://www.sunearthtools.com/dp/tools/conversion.php
    coordinate conversion methods and types: http://www.earthpoint.us/Convert.aspx

    Let me know if this helps.
  • Also are you using Spin or C. I have some spin code that could help also.
  • w4fejw4fej Posts: 264
    edited 2016-03-20 11:38
    OK thanks for the reply.

    Using Spin for all this. (see the attached code in my original post). My only issue is whether or not I am using that method correctly.

    My app has a variable "value" defined as long and I am assigning "value" like this:

    value := GPS.n_secs (UTC seconds field in numeric form, not as a string)

    I get in return "value" only having the seconds digit 0..9 instead of 0..59 like I should.. In addition to my very, very simple app there are 2 objects listed, "GPS_basic.spin" and "VisiGenie.spin" both of which invoke "FullDuplexSerial" but to different pins..

    I was hoping Jonny Mac would chime in here as he is the author of GPS_basic.spin..

    Mike B.
  • Chiming in.... I haven't used that in a long time and I'm in the middle of a big road trip without a GPS module. Let me look at the code tonight. That was written some time ago and I'm probably going to have to resist the urge to do a re-write! :)
  • Thanks Jon.

    I'm using the Parallax PAM-7Q GPS Module if that makes any difference. (at 9600 baud by the way) I THINK the issue might be in the "str2dec" method as I am only seeing 0..9 for the "n_secs" method if, and only if I am using that method correctly which has a high probability of me using it incorrectly due to my noob status...

    Mike B.
  • Without wishing to in any way denigrate Jonny Mac's object, I have always had good results with the GPS_Float_Lite object in the Obex; it might be worth a visit whilst Jon is on his road trip.
  • kwinnkwinn Posts: 8,697
    Can you post all your code, including GPS_Basic_spin. Without that it is hard to determine what the problem is.
  • w4fej wrote: »
    Thanks Jon.

    I'm using the Parallax PAM-7Q GPS Module if that makes any difference. (at 9600 baud by the way) I THINK the issue might be in the "str2dec" method as I am only seeing 0..9 for the "n_secs" method if, and only if I am using that method correctly which has a high probability of me using it incorrectly due to my noob status...

    Mike B.

    Noob, schmoob -- I don't care about that; if there's a problem in the code I'll do what I can to sort it out. I have a reason to re-address GPS which is coming up, so I may rewrite the whole thing. I have a lot more experience with parsing the last year so I can put that experience to use.

  • Hi Jon:

    I don't know if there is a problem in the code or not. (Knowing your work, I doubt it). I was initially asking if I was trying to get the decimal seconds into a byte variable the correct way. Like this:

    value := GPS.n_secs (this line is in my test app I then send the contents of "value" to my display which results in 0..9 with no 10's digits.)

    Do I simply assign n_secs to my variable??
  • JonnyMacJonnyMac Posts: 9,105
    edited 2016-03-23 00:10
    How are you sending the value to the display? The "n_" methods return a numeric value, so your output routine has to handle the formatting. Here's a simple method that will print a 2-digit value (no error checking, so be careful).
    pub dec2(value)
    
      serial.tx("0" + value / 10)
      serial.tx("0" + value // 10)
    

    If you're not doing anything with the numeric value (except printing), you could use the "s_" method:
      serial.str(gps.s_secs)
    

  • w4fejw4fej Posts: 264
    edited 2016-03-24 09:38
    Hi Jon:

    Back in town and will be leaving again in a few hours.

    OK. I am using the 4DSystems 3 /12" touch screen display driven by the 4DVisiGenie.spin object. It sends "messages" to the various objects on the screen like buttons, switches numeric displays etc. This page (or form as they referrer to them) has an airline arrival/departure type display. All the GPS info is displayed in 2 digit "chunks" that require 2 digit numeric data. I can't use string data.

    Using your GPS object (GPS.n_secs) I have been trying to assign my variable "value" (long) like this:

    Value := GPS.n_secs

    Then send it to the display like this:

    LCD.WriteObjValue($09,3,value)

    $09 is the object type in this case a "customDigit

    3 is the object number in this case it is the 4th custom digit on the screen (secs)

    "value" is supposed to be the current number of seconds from the GPS object. All I am getting this way is the right most seconds, never see the tens digits. It does repeat 0..9 at the one second interval.

    If I assign "value" manually with a loop limiting the value to 0..59 that works fine, just not from the GPS object.

    What am missing here?? Could having "value" defined as long be tripping me up here??

    Thanks for looking into this....

    Mike B.
  • I don't know. Until I get home and to a GPS module I cannot re-test the code. I am usually very thorough with testing things before making them public, but I am human and could have made a mistake.
  • OK Jon. thanks..

    You out working on some killer animation?? (Love the pictures of some of the stuff you do, amazing)

    Mike B.
  • I'm in Dallas at the moment doing Propeller programming for a client.

    On Monday (back in Los Angeles) I will be voicing an animation. Does that count? I actually had to record myself on the road last trip and send the audio to the director. It worked.
  • Sounds good Jon. Can I ask what kind of animation it is ??

    Just had a hunch on the GPS thing. If I preload the result of the "str2dec" method where it returns "dec" I preloaded "dec" with 29 and sure enough I got both digits in my display so it looks like the str2dec method has an issue or perhaps the parse routine is off by a digit...

    Talk to you Monday and have a great weekend..

    Mike B.
  • All,

    The "s_" and "n_" functions weren't working as expected for me on the PAM-7Q GPS. I was using the start method, not the startx method.

    It all starting working fine when I used the startx method and set the baud to 9600.

    As the documentation clearly states, the module runs at 9600. :-p

  • w4fejw4fej Posts: 264
    edited 2016-03-27 11:06
    OK.

    I'm running the device at 9600 with the "start" method but wasn't using the "statrx" version, I'll go check that and see if it makes any difference for the issue I am having...

    Thanks..

    P.S. There is an error in the AN002 GPS_Basic.spin method in the "n_altf" (altitude in feet) with the conversion from meters to feet, just change the order in which you do the division and it will compute correctly. Here is the discussion:


    The method "pub n_altf" has the conversion as follows:

    Return (n_altm * 3048 / 10_000)

    The computation should be :

    Return (n_altm * 10_000 / 3048)

    To check this use this test:

    10668 meters SHOULD yield exactly 35_000 feet but instead yields 3,251.6 feet

    Using the other computation does indeed yield 35,000 feet.
  • Sadly, switching to the "startx" method made no difference at all, still the same issue, no tens of seconds displaying. I have the UTC clock displayed on another computer and the seconds digits match the GMT time exactly with the right most digit in my app but no tens digits showing. Also the number of satellites is correct but again no tens digit, just the right most digit so I know the GPS is working..

    Using the "GPS_Basic_Demo and the PST for display it works great using all the string methods. I need the numeric methods to work for my app..

    As far as I can tell the issue appears to be with the "str2dec" method only returning the right most digit and I can't see what the problem is with that method.

    Jonny Mac said he would take a look at it when he gets back in town...

    Mike B.
  • Well... I am home and nearly rested, and cannot find a problem with str2dec() -- at least not the one in my library. I did this quick test and it works fine.
      result := gps.str2dec(string("59"), 2)
      term.dec(result)
    
    That is to say the problem does not appear to be with str2dec().

    I've attached the code in my personal library. Give it a try.

    Do me a favor and attach an archive of what you have so I can look at it if my updated object doesn't make a difference.


  • Darn it. I hate that the new forums doesn't allow me to attach code to a existing post. Here's the object.
  • I'm about to try your object dated 27 Sep 2014. The one I have been trying to use is dated 19 Feb 2011 !! That might make a difference. Back in a few

    Mike B.
  • CON
      _clkmode = xtal1 + pll16x    'Standard clock mode * crystal frequency = 80 MHz
      _xinfreq = 5_000_000
      
      CmdReadValue = $00
      CmdWriteValue = $01
      CmdWriteString = $02
      CmdSetContrast = $04
      CmdObjEvent = $05
      CmdRaisedEvent = $07
      Dipswitch = $00
      Knob = $01
      RockerSwitch = $02
      RotarySwitch = $03
      Slider = $04                                   
      TrackBar = $05
      WinButton = $06
      Angularmeter = $07
      Coolgauge = $08
      Customdigits = $09
      Form = $0A
      Gauge    = $0B
      Image = $0C
      Keyboard = $0D
      Led = $0E
      Leddigits =$0F
      Meter = $10
      Strings = $11
      Thermometer  = $12
      Userled = $13
      Video  = $14
      ''ObjStatictext = $15
      Sound = $16
      Timer = $17
      Spectrum = $18
      Scope = $19
      UserImage = $1B
      UserButton = $21
    
    CON 'Ack Nak response codes
    
      AckResp = $06
      NakResp = $15
      
    VAR
      byte  value
       
    OBJ
      GPS   : "jm_GPS_BASIC.SPIN"
      lcd   : "4d_visiGenie.spin"
        
      
    PUB start
     
       GPS.start(23,-5)
       waitcnt(2500 + cnt)
       LCD.init(0,1)
       waitcnt(2500 + cnt)
       LCD.WriteObjValue($0A,4,0)   
    
     repeat
       
       LCD.WriteObjValue($0E,0,1)
       LCD.WriteObjValue($09,3,29)
       LCD.WriteObjValue($09,6,GPS.n_secs)
       LCD.WriteObjValue($09,0,GPS.n_satellites)
       waitcnt(2500 +cnt)
       LCD.WriteObjValue($09,1,GPS.n_UTC_hrs)
       
    

    Well still the same thing, no tens digits so now I'm sure I'm doing something wrong in my app.
    for a sanity check I load "29" into one instance of the n_sec and the other from the GPS object..

    You see anything obvious I am doing wrong??

    By the way I see the str2dec method has changed in the current version of jm_GPS_Basic

    Mike B
  • JonnyMacJonnyMac Posts: 9,105
    edited 2016-03-28 15:37
    Well still the same thing, no tens digits so now I'm sure I'm doing something wrong in my app.

    That may be the case. The attached image shows str2dec() in my latest object works as is is supposed to work.

    Since you don't have the courtesy to post an archive of your project -- as I requested -- I am bowing out of this discussion and will ignore future posts by you.
    1920 x 1080 - 272K
  • Wow.....

    I thought I did post my project. Guess I don't know what you mean by "archive of your project"

    You may assume everyone speaks your language...

    Sorry if I offended you somehow but have a nice day anyway..

    Mike B.
  • In Propeller Tool, go to File/Archive "Name of Program". This will create a zip file of ALL files in your project.
  • Thanks Andy but the horses are already out of the barn. Nice to know if I ever have to "archive" again... There are a lot of assumptions made in these forums about what a person may or may not know...

    Live and learn again.... At 71 years of age I get angry at myself if I don't learn something every day. And today I'm not angry after learning something about the Prop IDE AND people..

    Mike B.
  • "In Propeller Tool, go to File/Archive "Name of Program". This will create a zip file of ALL files in your project"

    Thanks Andy, I went and tried that and it works great. Too bad I learned about so late in life... :)

    Mike B.
Sign In or Register to comment.