Array and ASCII


Closed Thread
Results 1 to 19 of 19

Thread: Array and ASCII

  1. #1
    Join Date
    Sep 2011
    Posts
    20

    Default Array and ASCII

    Hi Need some help please.

    The problem....I have an OSD and it won't dipslay without a GPS data sentence. So thought no big deal I will creat my own, which I have done. The display does work now, but I want to use CMS10 (compass) to provide some heading information. I can not get the OSD to display the heading information even though I have filled the GPS sentance array with the data. I know it works with ASCII charaters ....so "a" would be displayed is placed in an array location. I have tried using # modifier, adding 48 to the heading result.....nothing seems to work...help! below is an extract of the code....part of one of the arrays the bold letters are the bit I am struggling with, and the main body is below (there is more to the code but stripped it out to get this bit working).



    RMC_array[39]=Dec_lat2 Dig 1+"0"
    RMC_array[40]=Dec_lat2 Dig 0+"0"
    RMC_array[41]=","
    RMC_array[42]="W"
    RMC_array[43]=","
    RMC_array[44]=Dec_off Dig 1+"0"
    RMC_array[45]=Dec_off Dig 0+"0"
    RMC_array[46]="."
    RMC_array[47]=Dec_off Dig 0+"0"
    RMC_array[48]=","
    RMC_array[49]= Heading
    RMC_array[50]="."
    RMC_array[51]=Course Dig 0+"0"
    RMC_array[52]=","
    RMC_array[53]=date_stamp Dig 1+"0"
    RMC_array[54]=date_stamp Dig 0+"0"
    RMC_array[55]=","
    RMC_array[56]=variation Dig 1+"0"
    Main
    I2CREAD DPIN,CPIN,$C0,$C1,[B2] ' Read 2 locations in a row
    B0=B2*14
    Heading=B0/10

    cksum=0
    p=0
    for p = 1 to 60
    cksum = cksum^(RMC_array[p])
    Next P
    Serout2 bob, baud, [Str RMC_array\60, HEX Cksum,13,10]
    p=0
    cksum1=0
    for p = 1 to 63
    cksum1 = cksum1^(GGA_array[p])
    Next P
    Serout2 bob, baud, [Str GGA_array\60, HEX Cksum1,13,10]
    'Serout2 bob, baud, [Str Text_array\6,13,10]
    Goto Main
    End

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    For starters, The array is sized for bytes, that will only contain a value between 0 and 255 in binary as 1 byte.
    So, the value of RMC_array[49]= Heading will only contain the value of heading between 0 and 255 as 1 byte.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Thanks for the reply. I have set the variable as a word. But also tried creating new array elements

    WPT_array[47]=Dec_off Dig 0+"0"
    WPT_array[48]=","
    WPT_array[49]= course1 +"0"
    WPT_array[50]= course2 +"0"
    WPT_array[51]= course3 +"0"
    WPT_array[52]="."


    and then did this

    C1temp = heading dig 0
    C2Temp = heading dig 1
    C3Temp = heading dig 2
    course1 = C1Temp+48
    course2 = C2Temp+48
    course3 = C3Temp+48

    But nothing seems to work...

  4. #4
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Just a shot in the dark, but have you tried to send the data the exact same way you send the course information?

  5. #5
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Yep tried that....the OSD only seems to respond to stuff if it is in inverted commas.....am I missing something here? ASCII is transmitted as data.....the inverted commas are only there to tell the complier it is to be sent in ASCII format. That is why I tried putting the # modifier infront of the variable.

  6. #6
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Can you give an example of what string of data the OSD expects to see? Is there a datasheet to reference?

  7. #7
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    There is very little in terms of documentation (remzibi 3DR)....but there is a GPS simulator (happykillmore.com) incorporated into the config software which generates standard NMEA GPS sentences, for example

    $GPGGA,000000,4124.8963,N,08151.6838,W,1,05,1.5,28 0.2,M,-34.0,M,,,*59
    $GPRMC,000000,A,4916.45,N,12311.12,W,000.5,253.7,1 91194,020.3,E*68

  8. #8
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Quote Originally Posted by Seahound1 View Post
    There is very little in terms of documentation (remzibi 3DR)....but there is a GPS simulator (happykillmore.com) incorporated into the config software which generates standard NMEA GPS sentences, for example

    $GPGGA,000000,4124.8963,N,08151.6838,W,1,05,1.5,28 0.2,M,-34.0,M,,,*59
    $GPRMC,000000,A,4916.45,N,12311.12,W,000.5,253.7,191194,020.3,E*68
    Looking it over quickly, this is the value you are looking for, and likely what the remzibi 3DR calls "heading". (It would actually be true course if provided by a GPS). The important issue is the format. It looks like a string 5 characters long is required.

    So let's say you have a WORD variable MyHeading that contains a value between 0-359. To output this as it appears in the NMEA sentence use:
    SEROUT bob, baud, [DEC3 MyHeading , ".0"]

    You can see I added the decimal point and zero to fill out the five characters.

    HTH

  9. #9
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Yes you are right.....sorry I maybe didn't make it very clear. The protocol for the OSD is that it must see the other characters in the array (as per below) for it even to respond. According to the firmware notes is must see the preample ($GPRMC for example) from this I guess it gets how many commas to expect so that it knows it has the whole NMEA sentence. That is why I was forced to use the array in the first place. For example I just tried SEROUT2 ("$GPRMC, 00000, etc, etc,")..... is says it has a GPS connection but then stops. Using the array it confirms GPS connection and then goes on to dispay the OSD. So I thought I could fool it into showing the heading using the two methods below....but OH NO...Is there a way to send the first part of an array and then the remainder......if I could that at least I could try using the normal method you mention below.

  10. #10
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    How about this:

    RMC_array[48]=","
    RMC_array[49]= Heading DIG 2 + "0"
    RMC_array[50]= Heading DIG 1 + "0"
    RMC_array[51]= Heading DIG 0 + "0"
    RMC_array[52]= "."
    RMC_array[53]= "0"
    RMC_array[54]=","

  11. #11
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Let me give it a whirl and see.....

    Just tried it and it doesn't work...but great idea though...thanks
    Last edited by Seahound1; - 25th May 2012 at 19:45.

  12. #12
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    I tried to use other modifiers as well...but then saw they can only be used in the send statement ...Serout2 ( #heading) which converts the heading into a set of ASCII characters. Tried this combination too


    WPT_array[47]=Dec_off Dig 0+"0"
    WPT_array[48]=","
    WPT_array[49]= #course1
    WPT_array[50]= Hex2 course2
    WPT_array[51]= Hex course3
    WPT_array[52]="."

    But it won't compile....

  13. #13
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Have you tried to send some test strings? something like:

    SEROUT2 bob, baud, ["$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,1 30694,004.2,W*70"]



    If that works, try this (assuming Heading is the variable that contians your heading data):

    SEROUT2 bob, baud, ["$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,",DEC3 Heading,".0,130694,004.2,W*70"]
    Last edited by SteveB; - 25th May 2012 at 20:36. Reason: corrction

  14. #14
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    Tried that too....just testin to see if I can split the Array....send upto 48 then insert dec3 heading and then send the remainder of the string....see if that works....worth a try....starting to bang my head against the wall here :>)
    Serout2 bob, baud, [Str WPT_array\48,dec3 heading, Str WPT_array_2\13,13,10] just tried this as well and that doesn't work....oh well
    Last edited by Seahound1; - 25th May 2012 at 21:48.

  15. #15
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    starting to bang my head against the wall here :>)

    Well, that's normally when the break through occurs.

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


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    The OSD may be verifying the Checksum in the NMEA sentance.
    When it doesn't match, it'll throw away the whole thing.

    If so, you'll need to recalculate it each time.
    http://www.picbasic.co.uk/forum/showthread.php?t=1469
    http://rietman.wordpress.com/2008/09...nmea-checksum/
    DT

  17. #17
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    The code has the checksum calculation in it....but I have cracked it!

    For some reason I don't understand ....not unusual tho......if the Array is constructed the other way around..
    WPT_array[44]=Dec_off Dig 1+"0"
    WPT_array[45]=Dec_off Dig 0+"0"
    WPT_array[46]="."
    WPT_array[47]=Dec_off Dig 0+"0"
    WPT_array[48]=","
    [B]WPT_array[49]= "0" + heading dig 2
    WPT_array[50]= "0" + heading dig 1 'Course Dig 2+"0"
    WPT_array[51]= "0" + heading dig 0

    so the "0" is in front of the variable it works......then you just add a bit of code to fill the array with the heading and hey presto! It has taken a lot of head banging and scratching.
    Last edited by Seahound1; - 27th May 2012 at 21:07. Reason: bad english

  18. #18
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    I suspect something else is going on. As a test, I constructed my own array and sent the data out to an LCD using the STR variable\6 command. Worked either way I constructed the equation.

    ab_Test[0] = "0" + Heading DIG 2
    ab_Test[1] = "0" + Heading DIG 1
    ab_Test[2] = "0" + Heading DIG 0
    ab_Test[3] = Heading DIG 2 + "0"
    ab_Test[4] = Heading DIG 1 + "0"
    ab_Test[5] = Heading DIG 0 + "0"

  19. #19
    Join Date
    Sep 2011
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Array and ASCII

    You're right there is something else going on....turned the power off and back on and now it's not working again! trying to think of what I did the first time I got it working.

Members who have read this thread : 1

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