Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 11, 2024, 11:23:37 11:23


Login with username, password and session length


Pages: [1]
Print
Author Topic: REQ: How to convert GPS UTC Time to Local time in Assembly for PIC 16FXXX  (Read 3727 times)
0 Members and 1 Guest are viewing this topic.
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« on: December 06, 2007, 03:08:45 03:08 »

Does anyone have a routine that will convert UTC time to Local time according to longitude position given from GPS Nema data. Looking for something in assembly as that is what I have already written my PIC code in. Help is always greatly appreciated. I suppose I would need to create some sort of table of longitude coordinates with the time differences ie... EST = UTC-5 and also convert 24 hour format to 12 hour and correct for the the date if UTC is ahead by a day from EST. Such as UTC is 01:00:00 but EST is 01:00:00 - (minus) 05:00:00, which would put UTC ahead one day.

Thanks,
Alienbeing
Logged
truebit
Newbie
*
Offline Offline

Posts: 7

Thank You
-Given: 4
-Receive: 1


« Reply #1 on: December 12, 2007, 12:12:36 00:12 »

The Motorola GPS receivers I have used with the PIC would do this for you if sent the right command when initialised. If you are interested I could look up the command string to do it.
Logged
ipek
Junior Member
**
Offline Offline

Posts: 95

Thank You
-Given: 59
-Receive: 79


« Reply #2 on: December 12, 2007, 01:25:25 01:25 »

find it sony protokol country TÃœRKİYE +2

http://rapidshare.com/files/75960527/Sony_GPS_Reader.rar.html
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #3 on: December 12, 2007, 02:13:07 02:13 »

I'm using a Juipter GPS Module. Serial (RS232) Interface. It's an older GPS Module but very good. Needed to use this one as it has a 10khz output signal that locks in with the 1 PPS signal from the Sats. The 10khz squarewave is used as a source to phase lock a 10Mhz TCXO. It provides very accurate 10Mhz for calibration of other electronic equipment. I added an LCD display to show Date and Time. Problem is it's in UTC and not local. All done with a 16F877 Pic.

Was thinking maybe using a DS1305 or DS1307 with I2C and have the PIC set it. Then read it and display on LCD. I don't know if I can combine I2C and RS232 routines all in the same code. Would I have to stop the RS232 communications and the RUN the I2C routines then restart RS232 again? Can the 16F877 do both at the same time and keep the LCD updated? Maybe this would be too much for the PIC and I should think about adding a second PIC to the project to take care of the RTC (realtime clock) functions.

Quote
The Motorola GPS receivers I have used with the PIC would do this for you if sent the right command when initialised. If you are interested I could look up the command string to do it.

Isn't that done in Binary mode and not NEMA. I can't change NEMA within the GPS module. But the Juipter GPS has binary mode and can be set to a Local Time (offset). Thing is I would have to rewrite everything to use the GPS in binary mode. Could be done I guess but maybe easier to just use a RTC with another Pic.

Alienbeing
« Last Edit: December 12, 2007, 02:30:42 02:30 by Alienbeing » Logged
truebit
Newbie
*
Offline Offline

Posts: 7

Thank You
-Given: 4
-Receive: 1


« Reply #4 on: December 13, 2007, 12:10:12 00:10 »

Hi,
This is part of the code I used to read the binary data from a motorola Oncore gps timing RX (they do/did a version that can output 10Khz as well). You can switch between binary and nema mode. I have not included the LCD routine as that is prety standard. Hope it might be of help.


; Code to read Oncore Data stream

GetRx
   call   readst      ; read receiver data string
   iorlw   0      ; test W, 0 = checksum good
   btfss   status,z   ; if read error do not update lcd
   return
      ; Call again for second string   
   call   readst      ; read receiver data string
   iorlw   0      ; test W, 0 = checksum good
   btfss   status,z
   return   
      ; if read error do not update lcd         
   MOVLW   0x01       ; Clear LCD
        CALL    cout
   CALL   chkbsy

   movf   day,w      ;Send date
   call   p_bin
   movlw   '-'
   call   dout
   movf   month,w
   call   p_bin
   movlw   '-'
   call   dout
   movf   year_hb,w
   movwf   hbyte
   movf   year_lb,w
   movwf   lbyte
   call   bin2bcd
   call   p_4      ; send 4 lsd from "R" reg to LCD

   movlw   ' '      ; send space
   call   dout

   movf   hour,w      ; send time
   call   p_bin
   movlw   ':'
   call   dout
   movf   min,w
   call   p_bin
   movlw   ':'
   call   dout
   movf   sec,w
   call   p_bin
   movlw   0xA8      ; move cursor to start of Line 2
   call   cout

   movlw   AntO-msg1   ; open msg
   btfsc   ant,7      ;if set antenna = open
   goto   gopn
   btfss   ant,6      ;if set antenna = short
   goto   agood
   movlw   AntS-msg1   ; short msg
gopn   call   p_msg      ; send msg
   movlw   0x01
   movwf   holdflg      ; if antenna faulty enter holdover mode   
   return         ; and exit

agood   movlw   Sats-msg1   ; else print number of sats tracked
   call   p_msg
   movf   track,w
   call   p_hex
   movlw   ' '
   call   dout      ; and lock status

   incf   mode,w      ;get current mode +1   
   sublw   lockval      ;mode number for lock light to be on
   btfsc   status,c
   goto   grx1      ; not locked

   movf   Erstat,f   ;Traim status
   btfss   status,z   ; 0 = good
   goto   grx3      ; hold
   clrf   holdflg      ; clear hold flag
   movlw   Lok-msg1
   goto   p_msg
grx1
   clrf   holdflg
   movlw   Aqu-msg1
   goto   p_msg

grx3
   movf   holdflg,f   ;if holdflg is 0 then set it to 1
   btfsc   status,z   ;if not zero then leave as is
   incf   holdflg,f   ;as flag is incremented by Int service
   movlw   hold-msg1   ;every Ts
   call   p_msg
   movlw   ' '      ;send space
   call   dout
   clrc
   rrf   holdflg,w   ;get hold count divided by 2   
   goto   p_bin      ;send to LCD

Wait@@
   call   sbyte
   sublw   '@'      ;is it ascii @
   btfss   status,z
   goto   wait@@
   call   sbyte
   sublw   '@'      ;is it ascii @
   btfss   status,z
   goto   wait@@
   clrf   cksum      ;checksum all bytes after the @@ start
   return

readst
   call   wait@@
   call   sbyte
   sublw   'E'      ;is it ascii E
   btfss   status,z
   goto   readst
   call   sbyte
   sublw   'a'      ;is it ascii a
   btfsc   status,z
   goto   EaString
   movf   SerialData,w   ;get back data byte
   sublw   'n'      ;is it ascii n
   btfsc   status,z
   goto   EnString
   goto   readst      ;not what we want so keep looking   


EnString
         ;Traim data string
         

   movlw   D'17'      ;skip first 17 bytes
   call   skipn
   call   sbyte
   movwf   Erstat

   movlw   D'3'      ;skip next 3 bytes
   call   skipn

   call   sbyte
   movwf   nsecerr      ;nanoseconds error +-128

   movlw   D'41'      ;skip next 3 bytes
   call   skipn

   movf   cksum,f      ;test checksum
   btfss   status,z   ;checksum must be zero
   retlw   1      ;here if error
   retlw   0      ;done with no error


EaString
         ;main message string
         ;next 69 bytes are data, but we only need to save some

   movlw   D'7'      ;read 7 bytes
   movwf   scount
   movlw   month      ;start of date and time RAM block
   movwf   FSR
rd1   call   sbyte
   movwf   INDF
   incf   FSR,F
   decfsz   scount
   goto   rd1
   movlw   D'26'      ;skip next 26 bytes
   call   skipn
   call   sbyte
   movwf   ant
   call   sbyte
   movwf   vis
   call   sbyte
   movwf   track

   movlw   D'34'      ;skip next 34 bytes
   call   skipn
   movf   cksum,f      ;test checksum
   btfss   status,z   ;checksum must be zero
   retlw   1      ;here if error
   retlw   0      ;done with no error

skipn
   movwf   scount      ;last byte is ckecksum
skp1   call   sbyte
   decfsz   scount
   goto   skp1
   return


; DELAY_TIME should be (ClockSpeed/4/SerialSpeed-14)/3
; 4MHz 9600 baud would be (4000000/4/9600-14)/3 = 30
; 4MHz 2400=134 4800=65 9600=30 19200=13 38400=4 57600=1

; 10Mhz  4800=169
DELAY_TIME      equ     D'30'
TX_DELAY_TIME   equ     D'65'



TXserialDelay
   movlw   TX_DELAY_TIME
   movwf   serialDelayCount        ; Use TX Delay
   goto    serialDelayLoop         ; use routine below

serialDelayThird
   movlw   DELAY_TIME/3           
   movwf   serialDelayCount        ; only count 1/3
   goto    serialDelayLoop         ; use routine below
serialDelay
   movlw   DELAY_TIME             
   movwf   serialDelayCount        ; Count down from DELAY_TIME
   nop                             ; Helps with high speed
serialDelayLoop
   decfsz  serialDelayCount, F     ; Countdown
    goto   serialDelayLoop         ; keep counting
   return                          ; done
srt
serialTransmit
   movwf   serialData              ; save the outgoing byte
   movlw   D'10'
   movwf   serialCount             ; set the bit count
   clrc                            ; prep for start bit
serialTransmitLoop
   bcf     SERIAL_OUT              ; assume send low
   skpc                            ; if sending 0
    bsf    SERIAL_OUT              ; send high
   call    TXserialDelay           ; delay
   setc                            ; prep for stop bit
   rrf     serialData, F           ; roll serialIn bits   
   decfsz  serialCount, F          ; if not complete
    goto   serialTransmitLoop      ; loop back for more
   return                          ; all done


sbyte      ;read next serial byte
   call   serialReceive
   iorlw   0
   skpnz            ;wait for start bit
   goto   sbyte
   movf   serialdata,w   
   xorwf   cksum,f         ;add to checksum
   return         

serialReceive
   btfsc   SERIAL_IN               ; Check for Start bit
        retlw   0                       ; not receiving now
   movlw   D'9'                   
   movwf   serialCount             ; read 9 bits
   call    serialDelayThird        ; skip third a bit
serialReceiveLoop
   setc                            ; assume set carry
   btfss   SERIAL_IN               ; if receiving 0
   clrc                            ; clear carry
   rrf     serialData, F           ; roll serialData bits 
   call    serialDelay             ; delay
   nop                             ; keep timing w/ transmit
   decfsz  serialCount, F          ; if not complete
   goto    serialReceiveLoop       ; loop back for more
; Skip this as the Oncore dose not send parity
;   call    serialDelay             ; Dump the Parity Bit...
   retlw   1

Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #5 on: December 13, 2007, 01:03:31 01:03 »

Hi,
This is part of the code I used to read the binary data from a motorola Oncore gps timing RX (they do/did a version that can output 10Khz as well). You can switch between binary and nema mode. I have not included the LCD routine as that is prety standard. Hope it might be of help.

Greatly appreciated. I'm going to see about switching to binary mode. I think if I switched from NEMA to Binary back to NEMA again it would interrupt the signal from the sats and would lose the phaselock on the Frequency Standard (TCXO). I'll have to go over how the binary output can be decoded and see if that might be an easier choice. I would have rewrite the code I have but maybe won't be too difficult.

Thanks,
Alienbeing
Logged
ipek
Junior Member
**
Offline Offline

Posts: 95

Thank You
-Given: 59
-Receive: 79


« Reply #6 on: December 13, 2007, 03:55:09 03:55 »

Alienbeing
your nice idea projects finished please shared....

my same receiver jupiter 10 khz output net to find it ttl or pll loop i need both projects disciplined time base  and atomic time +2 hour offset.

best reagards...
Logged
truebit
Newbie
*
Offline Offline

Posts: 7

Thank You
-Given: 4
-Receive: 1


« Reply #7 on: December 13, 2007, 02:12:02 14:12 »

Alienbeing,
Glad you found the code usefull. This was part of a disciplined frequency standard using the 1 pulse per second output to control a 10Mhz ovened oscillator. Using the 10Khz makes life a lot simpler but the short term stability is poor. It all depends on what you are going to do with the output.
Regards..
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC