Shop OBEX P1 Docs P2 Docs Learn Events
need help in converting time — Parallax Forums

need help in converting time

ArchiverArchiver Posts: 46,084
edited 2003-12-03 13:31 in General Discussion
hi people , i live in singapore. i am grabbing data from a gps
antenna which is showing me UTC time. i need some help to change the
time from UTC to singapore time which is faster by 8 hours. thanks
for the help.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-02 13:19
    just get the time and subtract 8 from it. For example, 1800 hrs (6 pm)
    becomes 1000 or 10 am
    jim
    http://www.geocities.com/jimforkin2003/

    Original Message
    From: SkYbOL [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=rpsxLH2P2MCBr8hifT4W1PFtWhqYC1BLr5j_y3vxiCgQaREXzH1H7VCCDPYvUkD3Lk6J68zTh-N_LNTejuk]skybol1@y...[/url
    Sent: Tuesday, December 02, 2003 2:58 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] need help in converting time


    hi people , i live in singapore. i am grabbing data from a gps
    antenna which is showing me UTC time. i need some help to change the
    time from UTC to singapore time which is faster by 8 hours. thanks
    for the help.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-02 14:13
    If the date is not an issue, it's simply a matter of adding your offset
    to the UTC time an using the modulus operator to handle the wrap:

    hours = utcHr + TzOfs // 24

    Where hours is your local time, utcHr is the hours value from the GPS
    system, and TzOfs is a constant that specifies your time zone offset
    (assuming ahead of UTC). If you're behind the UTC (as I am in Dallas),
    you can do the math like this:

    hours = utcHr + (24 - TzOfs) // 24

    I've written about GPS interfacing a couple times in my Nuts & Volts
    column -- these articles may be useful to you:

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/83.pdf
    http://www.parallax.com/dl/docs/cols/nv/vol4/col/103.pdf

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: SkYbOL [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=wSgGJEv-knKVgeIxI1vU10jX_SshYvN_0ZG9EY6nmg6uj6E-cuM1Olx4CxdtuK_j8d97ICfzOhGeFJQbRsQ]skybol1@y...[/url
    Sent: Tuesday, December 02, 2003 1:58 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] need help in converting time


    hi people , i live in singapore. i am grabbing data from a gps
    antenna which is showing me UTC time. i need some help to change the
    time from UTC to singapore time which is faster by 8 hours. thanks
    for the help.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-03 04:10
    hi William,
    i read your 83.pdf file and tried to write out the
    program but was unsucessful in getting the time right.
    can u take a look at my program and advise me on where
    the mistake is? attached below is my program.

    '{$STAMP BS2}
    '{$PORT COM2}
    time var byte(6)
    v var byte(1) 'NORTH,SOUTH
    n var byte(1) 'east west
    clock var byte(6)
    hrs var byte (2)
    mins var byte(2)
    secs var byte(2)
    oie var word

    dir11=1
    dir9=1

    main:
    serout 0,188,[noparse][[/noparse]" LOGGING IN , PlEASE HOLD
    .................."]
    Pause 5000

    serout 0,188,[noparse][[/noparse]" PLEASE PRESS THE RED BUTTON TO
    CONTINUE"]

    critical:
    IF(IN9=1) then nono

    yesyes:
    goto critical
    nono:
    serout 0,188,[noparse][[/noparse]" ENTERING TO TEST IF IT IS WORKING TO
    OUR EXPECTATIONS"]
    pause 3000
    goto top



    top:
    IF (IN11=0) THEN waiting

    get_data:
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPGGA,"),str
    time\6,skip 15,str v\1,skip 12,str n\1]
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPRMC,"),str clock\6]
    serout 0,188, [noparse][[/noparse] " The time is ",time(0),time(1),
    ":",time(2),time(3), ":",time(4),time(5),",latitude","
    ",v(0)," ",",longtidute ",n(0)," clock
    ",clock(0),clock(1),"|",clock(2),clock(3),"|",clock(4),clock(5)]

    pause 2000
    goto top
    goto get_data

    no_data:
    serout 0,188,[noparse][[/noparse]" NO SERIAL DATA"]
    goto top
    goto get_data


    waiting:
    serout 0,188,[noparse][[/noparse]" PRESS THE BLACK BUTTON NOW "]


    top1:
    IF (IN11=0) THEN waiting1

    get_data1:
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPGGA,"),str
    hrs\2,str mins\2, str secs\2,wait(","),wait(","),str
    v\1,wait(","),wait(","),str n\1]
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPRMC,"),str clock\6]
    oie=hrs+8
    serout 0,188, [noparse][[/noparse] " The time is ",oie(0),oie(1),
    ":",mins(0),mins(1), ":",secs(0),secs(1),",latitude","
    ",v(0)," ",",longtidute ",n(0)," clock
    ",clock(0),clock(1),"|",clock(2),clock(3),"|",clock(4),clock(5)]

    pause 4000
    serout 0,188,[noparse][[/noparse]" PRESS THE BLACK BUTTON TO REFRESH THE
    DATA "]
    goto top1
    goto get_data


    waiting1:
    goto top1


    adjust:
    hrs=hrs +(24+8) //24
    return







    --- Jon Williams <jwilliams@p...> wrote: > If
    the date is not an issue, it's simply a matter of
    > adding your offset
    > to the UTC time an using the modulus operator to
    > handle the wrap:
    >
    > hours = utcHr + TzOfs // 24
    >
    > Where hours is your local time, utcHr is the hours
    > value from the GPS
    > system, and TzOfs is a constant that specifies your
    > time zone offset
    > (assuming ahead of UTC). If you're behind the UTC
    > (as I am in Dallas),
    > you can do the math like this:
    >
    > hours = utcHr + (24 - TzOfs) // 24
    >
    > I've written about GPS interfacing a couple times in
    > my Nuts & Volts
    > column -- these articles may be useful to you:
    >
    >
    http://www.parallax.com/dl/docs/cols/nv/vol3/col/83.pdf
    >
    http://www.parallax.com/dl/docs/cols/nv/vol4/col/103.pdf
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: SkYbOL [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=52M491A_oXTyGbjtbkwKGouODLXsR0PbEx3g8nQpbiq1idxalneG3y5Oio1VBONS0mTlyTDLN_W9k9oL]skybol1@y...[/url
    > Sent: Tuesday, December 02, 2003 1:58 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] need help in converting time
    >
    >
    > hi people , i live in singapore. i am grabbing data
    > from a gps
    > antenna which is showing me UTC time. i need some
    > help to change the
    > time from UTC to singapore time which is faster by 8
    > hours. thanks
    > for the help.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed.
    > Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please
    > report SPAM to
    > abuse@p....
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed.
    > Text in the Subject and Body of the message will be
    > ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >

    __________________________________________________
    Do You Yahoo!?
    Faster. Easier. Search Contest.
    http://sg.yahoo.com/search
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-03 13:31
    The problem, I think, is that you're trying to do math on ASCII
    characters. The data from the GPS unit is no numeric, it is a string
    representation and therefore must be converted before you can make any
    adjustments. Another note, your variables for hours, minutes and
    seconds are consuming two bytes and this is not necessary -- yes, there
    are two digits in those fields but their numeric value is never greater
    than 59 so only one byte is required.

    Here's a little demo that you can run to see how string data (using your
    variable names) gets converted to numeric values for modification:


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    clock VAR Byte(6)
    hrs VAR Byte
    mins VAR Byte
    secs VAR Byte

    Test:
    DEBUG CLS
    DEBUGIN STR clock\6

    ' convert text time to numbers

    hrs = ((clock(0) - 48) * 10) + (clock(1) - 48)
    mins = ((clock(2) - 48) * 10) + (clock(3) - 48)
    secs = ((clock(4) - 48) * 10) + (clock(5) - 48)

    DEBUG "UTC: ", DEC2 hrs, ":", DEC2 mins, ":", DEC2 secs, CR

    hrs = hrs + 8 // 24

    DEBUG "Adj: ", DEC2 hrs, ":", DEC2 mins, ":", DEC2 secs, CR

    END


    If you go back and review the article you find there is a subroutines I
    use called String_To_Value and Mixed_To_Tenths for converting GPS text
    fields to numbers.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office




    Original Message
    From: Boon Keong [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=r5hWajxaa-V05NpyvH-a6E8aECoCPY1fbI5IxQ63Gq_nTeTbgHKUtDc2IQBeNFTx4aw7SQ6EOnG06iePCUQ]skybol1@y...[/url
    Sent: Tuesday, December 02, 2003 10:11 PM
    To: basicstamps@yahoogroups.com
    Subject: RE: [noparse][[/noparse]basicstamps] need help in converting time


    hi William,
    i read your 83.pdf file and tried to write out the
    program but was unsucessful in getting the time right.
    can u take a look at my program and advise me on where
    the mistake is? attached below is my program.

    '{$STAMP BS2}
    '{$PORT COM2}
    time var byte(6)
    v var byte(1) 'NORTH,SOUTH
    n var byte(1) 'east west
    clock var byte(6)
    hrs var byte (2)
    mins var byte(2)
    secs var byte(2)
    oie var word

    dir11=1
    dir9=1

    main:
    serout 0,188,[noparse][[/noparse]" LOGGING IN , PlEASE HOLD
    .................."]
    Pause 5000

    serout 0,188,[noparse][[/noparse]" PLEASE PRESS THE RED BUTTON TO
    CONTINUE"]

    critical:
    IF(IN9=1) then nono

    yesyes:
    goto critical
    nono:
    serout 0,188,[noparse][[/noparse]" ENTERING TO TEST IF IT IS WORKING TO
    OUR EXPECTATIONS"]
    pause 3000
    goto top



    top:
    IF (IN11=0) THEN waiting

    get_data:
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPGGA,"),str
    time\6,skip 15,str v\1,skip 12,str n\1]
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPRMC,"),str clock\6]
    serout 0,188, [noparse][[/noparse] " The time is ",time(0),time(1),
    ":",time(2),time(3), ":",time(4),time(5),",latitude"," ",v(0),"
    ",",longtidute ",n(0)," clock
    ",clock(0),clock(1),"|",clock(2),clock(3),"|",clock(4),clock(5)]

    pause 2000
    goto top
    goto get_data

    no_data:
    serout 0,188,[noparse][[/noparse]" NO SERIAL DATA"]
    goto top
    goto get_data


    waiting:
    serout 0,188,[noparse][[/noparse]" PRESS THE BLACK BUTTON NOW "]


    top1:
    IF (IN11=0) THEN waiting1

    get_data1:
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPGGA,"),str
    hrs\2,str mins\2, str secs\2,wait(","),wait(","),str
    v\1,wait(","),wait(","),str n\1]
    serin 1,188,2000,no_data,[noparse][[/noparse]wait("GPRMC,"),str clock\6]
    oie=hrs+8
    serout 0,188, [noparse][[/noparse] " The time is ",oie(0),oie(1),
    ":",mins(0),mins(1), ":",secs(0),secs(1),",latitude"," ",v(0),"
    ",",longtidute ",n(0)," clock
    ",clock(0),clock(1),"|",clock(2),clock(3),"|",clock(4),clock(5)]

    pause 4000
    serout 0,188,[noparse][[/noparse]" PRESS THE BLACK BUTTON TO REFRESH THE
    DATA "]
    goto top1
    goto get_data


    waiting1:
    goto top1


    adjust:
    hrs=hrs +(24+8) //24
    return







    --- Jon Williams <jwilliams@p...> wrote: > If
    the date is not an issue, it's simply a matter of
    > adding your offset
    > to the UTC time an using the modulus operator to
    > handle the wrap:
    >
    > hours = utcHr + TzOfs // 24
    >
    > Where hours is your local time, utcHr is the hours
    > value from the GPS
    > system, and TzOfs is a constant that specifies your
    > time zone offset
    > (assuming ahead of UTC). If you're behind the UTC
    > (as I am in Dallas),
    > you can do the math like this:
    >
    > hours = utcHr + (24 - TzOfs) // 24
    >
    > I've written about GPS interfacing a couple times in
    > my Nuts & Volts
    > column -- these articles may be useful to you:
    >
    >
    http://www.parallax.com/dl/docs/cols/nv/vol3/col/83.pdf
    >
    http://www.parallax.com/dl/docs/cols/nv/vol4/col/103.pdf
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office
    >
    >
    >
    Original Message
    > From: SkYbOL [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=r5hWajxaa-V05NpyvH-a6E8aECoCPY1fbI5IxQ63Gq_nTeTbgHKUtDc2IQBeNFTx4aw7SQ6EOnG06iePCUQ]skybol1@y...[/url
    > Sent: Tuesday, December 02, 2003 1:58 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] need help in converting time
    >
    >
    > hi people , i live in singapore. i am grabbing data
    > from a gps
    > antenna which is showing me UTC time. i need some
    > help to change the
    > time from UTC to singapore time which is faster by 8
    > hours. thanks
    > for the help.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed.
    > Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
    > This message has been scanned by WebShield. Please
    > report SPAM to
    > abuse@p....
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed.
    > Text in the Subject and Body of the message will be
    > ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >

    __________________________________________________
    Do You Yahoo!?
    Faster. Easier. Search Contest.
    http://sg.yahoo.com/search

    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.