Community discussions

MikroTik App
 
User avatar
mramos
Member Candidate
Member Candidate
Topic Author
Posts: 231
Joined: Sun Nov 23, 2008 1:05 am
Location: S. B do Campo - SP - Brazil

Switching between NTP Client and GPS.

Mon Dec 15, 2008 4:33 pm

Hi:

May be usefull for someone.

I'm using an OEM GPS module on WRAP RS232 serial port (ROS 4.01beta1). But GPS antenna is not at the right place yet and sometimes GPS data is not "valid".

So there is a small routine to check if board clock must be tied to GPS or to a NTP-Server anywhere, according to GPS state. Since I run a NTP-Server to LAN/WLAN machines on such board, at least each 10 minutes I run this routine (scheduler) once to check if GPS is ok. If it's not, NTP-Client is enabled. As soon as GPS is back, set-system-time via NTP-Client is disabled and set-system-time via GPS is enabled back.
{/system gps monitor once do={
:if ($"valid" = no) do={
:log info "GPS down, enabling NTP-client";
/system gps set set-system-time=no;
/system ntp client set enabled=yes}
:if ($"valid" = yes) do={
:log info "GPS up, disabling NTP-client";
/system ntp client set enabled=no;
/system gps set set-system-time=yes}
}
}
Regards;
 
w0lt
Long time Member
Long time Member
Posts: 537
Joined: Wed Apr 02, 2008 2:12 pm
Location: Minnesota USA

Re: Switching between NTP Client and GPS.

Thu Dec 18, 2008 1:46 pm

Nice script. No everyone uses a GPS for time code, but I do and appreciate the post.
Thanks...
 
User avatar
eben
Member
Member
Posts: 479
Joined: Mon Feb 16, 2009 8:37 pm
Location: Somerset West, South Africa
Contact:

Re: Switching between NTP Client and GPS.

Sat Mar 21, 2009 11:44 pm

Hello Marcus,

What GPS hardware solution are you using?
 
User avatar
mramos
Member Candidate
Member Candidate
Topic Author
Posts: 231
Joined: Sun Nov 23, 2008 1:05 am
Location: S. B do Campo - SP - Brazil

Re: Switching between NTP Client and GPS.

Sun Mar 22, 2009 1:00 am

Hi Eben:

Actually an old Furuno GN74 module (1993 or so). But any GPS that have RMC sentence enabled and a serial RS232 port is ok.

My module does not have an enclosure. It's just the module itself on a 1 x 3 x 5 cm metal shiled and a 10 pin fence connector somewhere (besides the SMA antenna input). No brands, no labels, uses to be part of an vehicle tracking system module (was soldered to a PCB).

For some time I used one Magelan that was built in on a PCB I recovered from a meteorological sounder (baloon). Still a serial port but TTL levels, it was necessary to add a small PCB with a ckt to convert TTL levels to RS232.

Anyway, any off the shelf GPS works if it have RS232 & RMC sentence. Take a look at some pictures at http://py.qsl.br/wrap_album_42.html. The module is inside the aluminum box.

Regards
 
User avatar
eben
Member
Member
Posts: 479
Joined: Mon Feb 16, 2009 8:37 pm
Location: Somerset West, South Africa
Contact:

Re: Switching between NTP Client and GPS.

Sun Mar 22, 2009 1:16 am

Some interesting stuff there Marcus.

In theory, therefore, this will work?
http://cgi.ebay.co.uk/GPS901-RS232-GPS- ... .m63.l1177

I tried plugging a Garmin GPS V with an external antenna (that I know works) onto the RS232 port of an Intel based test RB but I failed to get any comms between RouterOS and Garmin.
 
User avatar
mramos
Member Candidate
Member Candidate
Topic Author
Posts: 231
Joined: Sun Nov 23, 2008 1:05 am
Location: S. B do Campo - SP - Brazil

Re: Switching between NTP Client and GPS.

Sun Mar 22, 2009 2:45 am

In theory, therefore, this will work?
http://cgi.ebay.co.uk/GPS901-RS232-GPS- ... .m63.l1177

I tried plugging a Garmin GPS V with an external antenna (that I know works) onto the RS232 port of an Intel based test RB but I failed to get any comms between RouterOS and Garmin.
I think so ...

The say that support NMEA0183, this is ok. I guess MT handle any speed on serial port (e.g. for GPS it's not locked to 4800 8 N 1). This module is locked to 9600. And you'll need to build some power inserter using one DB9 male <> DB9 female and feed the pin 7 of the GPS side only (the male connector) with +5Vdc.

I have one module here that's SiRF based too. It's nice, matchbox size.

Abt Garmin ... you know that it works ... where? On a PC with some navigation software? Garmin does not have some proprietary serial protocol? Most of the GPS software for PC I see has on config: GPS type ... ( )Garmin ... ( )NMEA. Try to run any terminal program (hyperterm etc) with this Garmin conectet do serial to see how the sentences looks like (they are text files on most GPS but Garmin I don't know) or on MT itself.

On MT with GPS connected to serial but keeping GPS routine disable (/system/gps set enable=no) you can see the same sentences from serial port. Open a new terminal (e.g. Winbox) and "sys serial-terminal serial0" and so there is ... you don't need an antenna connected to see the sentences, GPS send them all the time.
$GPGSV,2,2,08,18,53,155,53,21,35,119,54,22,73,232,5
[Q - quit connection]      [B - send break]
[A - send Ctrl-A prefix]   [R - autoconfigure rate]


3,29,18,042,43
$GPVTG,215.1,T,235.9,M,000.1,N,0000.1,K
$GPRMC,003252,A,2345.9112,S,04633.2272,W,000.1,215.1,220309,020.8,W*67
$GPGGA,003253,2345.9109,S,04633.2273,W,1,08,02.55,000750.7,M,-004.1,M,,
$GPZDA,003253,22,03,2009,+00,00
$GPGSV
Welcome back!
[mramos@WRAP-3G] > sys serial-terminal serial0
Regards;
 
User avatar
eben
Member
Member
Posts: 479
Joined: Mon Feb 16, 2009 8:37 pm
Location: Somerset West, South Africa
Contact:

Re: Switching between NTP Client and GPS.

Sun Mar 22, 2009 9:48 am

I'm not too keen on the whole "power injector" thing for the GPS. There are others out there...

The Garmin is normally used with Garmin's Mapsource software, but it does have an option to send data in "non Garmin" mode. Thing is, there's just nothing coming from the GPS, whether I run Hyperterminal or MT. I've tried changing the baudrate, data bits, stop bits, parity, flow control, etc but I suspect the Garmin hardware (seven years old) doesn't do a very good job of talking to anything other than Garmin software.

I'll continue my search for an RS232 GPS that works.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26381
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Switching between NTP Client and GPS.

Tue Mar 24, 2009 3:45 pm

should be no problem to set GARMIN to NMEA mode:
http://www.pocketgpsworld.com/garminetrex.php (search NMEA)

Who is online

Users browsing this forum: No registered users and 34 guests