LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices



Reply
 
Search this Thread
Old 08-30-2012, 09:26 AM   #1
scrabble
LQ Newbie
 
Registered: Jul 2011
Posts: 14

Rep: Reputation: Disabled
How to syncronize GPS-time with CPU clock?


Hello all,

I'm currently working with a seismic acquisition system containing an accelerometer, a TS-7260 single board computer with an embedded UNIX OS, a Sara SADC-20 AD converter and a FV-M7 GPS engine.

The thing is, that I got this system as a present which means I don't have wether readme files nor manuals on it. it was quite a struggle to find out the IP in order to connect via ssh or ftp aswell.

nevertheless, the acquisition starts automaticalls after booting and the digitizer receives the correct time stamp from the gps clock. nevertheless, the cpu clock always resets to 1st january 1970 00:00 which is pretty anoying.



Is it possible to embed a script that boots with the system and syncronizes the cpu clock with the GPS clock? And how do I check the GPS status?



Thanks a lot for your help guys!


Saludos desde Chile!
 
Old 08-30-2012, 09:57 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
You say UNIX but I'm wondering if you mean Linux?

What do you get from "uname -a" output?

Are you saying the "date" command gives you the correct time because it is synced to GPS? Is this done with ntp?

Does the hwclock command exist? It can be used to put the system time on the hardware clock. Most Linux systems have an init (boot script) that does this automatically during shutdown then they set the system time based on hardware clock during the boot.

Some systems have BIOS settings that tell the clock what to use so you might want to interrupt the boot and go into BIOS to see what, if any settings it offers.

Also the fact that the clock is reverting each time suggests your CMOS battery is defunct. Opening the system and locating this you may be able to find a replacement. (Many of these look like big watch batteries.)

As far as documentation goes. Web searches often help. I found several hits for your system board including this hardware manual:
http://www.embeddedarm.com/documenta...260-manual.pdf
 
Old 08-30-2012, 10:33 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,175

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
BTW that is a heck of a present. Be sure to read the manuals from the link I posted in your other thread.

This should be doable with a shell script but I have not tried it yet. In a nutshell the GPS receiver outputs its data via a serial connection to the SBC. The format of the data is called NEMA V3 with time is embedded in the messages. I would assume that all the start up scripts are in the /etc/init.d with a link to the /etc/rc.d/rc3.d directory. Basically scripts are started in numerical order i.e. S00xxx - S99xxx. You would want your script to run before the logging software starts.

The receiver continuously outputs data so you would need to have a read statement in a loop to capture just the RMC and decode the message. You should be able to set the clock to the nearest second.

http://www.m-indya.com/tutorial.php?tutorialid=6

PS. MensaWater this is a SBC so no BIOS and no battery backed clock that I am aware of.

Last edited by michaelk; 08-30-2012 at 10:38 AM.
 
Old 08-31-2012, 09:58 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,175

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
So I put together a simple script to set time.
Code:
#!/bin/bash
sleep 2m
stty -F /dev/ttyAM1 raw ispeed 4800 ospeed 4800 cs8 -ignpar cstopb eol 10 eof 10
mess=""
until [ "$mess" = "GPRMC" ]; do
  read instr < /dev/ttyAM1
  echo $instr
  mess=${instr:1:5}
done
hrmin=${instr:7:4}
sec=${instr:11:2}
day={instr:53:2}
mon={instr:55:2}
yr={instr:57:2}
date $mon$day$hrmin"20"$yr"."$sec
The SBC has 3 serial ports ttyAM0-3, labeled on the board as com1-3 the console is ttyAM0 so I assume the receiver is connected to one of the other ports. Change the stty line to match how the receiver is actually wired. I also didn't put any checks in the loop to see if the receiver was locked on. The receiver should be locked on to at least one satellite in about 30 seconds and worst case a couple of minutes which is why there is the sleep statement. This is all based on your receiver outputting NEMA 0183 data at 4800 BPS.
 
2 members found this post helpful.
Old 08-31-2012, 12:20 PM   #5
scrabble
LQ Newbie
 
Registered: Jul 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hey guys,
thanks a lot for your help I appreciate it a lot!!!!
@MensaWater:
The Sara SADC-20 AD digitizer gets the time information from a FV-M7 GPS engine with a hooked up antenna.
The "date" command gives me the cpu clock which is reset after each rebbot to 01-01-1970-00:00. This doesn t affect the correct time and date from the GPS in labeling the acquired files. nevertheless it would be nice to have the cpu clock synced with the gps.
If I type in the uname and hwclock command I get this:

Quote:
$ uname -a
Linux ts7200 2.4.26-ts11 #22 Tue Jun 6 12:23:09 MST 2006 armv4l unknown

$ hwclock
hwclock: Could not access RTC: No such file or directory
@michaelk:
Thanks for the code! But the stty command is not supported by the BusyBox v1.0 Linux version. Can I use the tty command instead?


cheers!
 
Old 08-31-2012, 12:35 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,175

Rep: Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784Reputation: 784
Sorry about that I was working from the development side which is a full up debian.
I will have to see what else I can do.

In the mean time you can manually set the time via the date command.

Last edited by michaelk; 08-31-2012 at 12:39 PM.
 
Old 09-07-2012, 02:09 PM   #7
scrabble
LQ Newbie
 
Registered: Jul 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hey everybody,
thanks for the advice and help. Nevertheless I gave it up, since it costs me too much time, I don't have the knowledge and is not that necessary. So I don't have a solution for it....

Thanks a lot folks.
 
  


Reply

Tags
cpu, gps, syncronization


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
clock-adjustment time is offseet from clock-display time bezdomny Linux - Desktop 2 11-19-2008 03:48 PM
Time clock resetting with more than 2 cpu's boozer_2 Linux - Hardware 4 01-20-2008 01:04 PM
GPS or Atomic Clock for NTPD slacky Linux - Networking 3 12-15-2006 07:13 AM
Various clock issues: Clock shows wrong time only in Knoppmyth, & CMOS time change ? davidbix General 1 04-05-2006 10:58 PM
How to syncronize my system time by public time server? hakansun Linux - Networking 1 09-10-2004 06:10 AM


All times are GMT -5. The time now is 11:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration