<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>navspark Archives - ClickedyClick</title>
	<atom:link href="https://gergely.imreh.net/blog/tag/navspark/feed/" rel="self" type="application/rss+xml" />
	<link>https://gergely.imreh.net/blog/tag/navspark/</link>
	<description>Life in real, complex and digital.</description>
	<lastBuildDate>Mon, 21 May 2018 15:32:42 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Dual Satellite NTP server with Navspark</title>
		<link>https://gergely.imreh.net/blog/2015/11/navspark-beidou-ntp/</link>
					<comments>https://gergely.imreh.net/blog/2015/11/navspark-beidou-ntp/#respond</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Thu, 26 Nov 2015 10:46:14 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Arch Linux]]></category>
		<category><![CDATA[beidou]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[navspark]]></category>
		<category><![CDATA[NTP]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<guid isPermaLink="false">https://gergely.imreh.net/blog/?p=2144</guid>

					<description><![CDATA[<p>A friend from NIST recently told me about a Raspberry Pi Stratum-1 NTP server project, and that reminded me of the experiments I did with the Navspark dual GPS+Beidou receiver module. Navspark is a small, Arduino-compatible module that besides GPS can also receive data from China&#8217;s Beidou 北斗 satellite navigation system , that is currently being built. [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2015/11/navspark-beidou-ntp/">Dual Satellite NTP server with Navspark</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A friend from NIST recently told me about a <a href="http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html">Raspberry Pi Stratum-1 NTP server</a> project, and that reminded me of the <a href="https://gergely.imreh.net/blog/2014/05/navspark-beidou/">experiments I did</a> with the Navspark dual GPS+Beidou receiver module. Navspark is a small, Arduino-compatible module that besides GPS can also receive data from China&#8217;s <a href="https://en.wikipedia.org/wiki/BeiDou_Navigation_Satellite_System">Beidou 北斗 satellite navigation system</a> , that is currently being built. I thought it would be fun to build a Beidou-powered Stratum-1 NTP server to see how does it compare to GPS.</p>
<h2>Hardware</h2>
<p>To have a really good really good, satellite-powered reference clock, I have to have access to a 1-pulse-per-second (1PPS) signal from the receiver. The pure USB-connected receivers don&#8217;t really seem to do that yet (looks like plenty of opportunities there!), instead I have to use separate hardware for it.</p>
<p>The Navspark module has a 1PPS pin (GPO3 below), and the only other pin I&#8217;ll really need is a serial pin to receive the NMEA stream of the satellite lock data (TXD1 below).</p>
<figure id="attachment_1768" aria-describedby="caption-attachment-1768" style="width: 500px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1.jpg"><img fetchpriority="high" decoding="async" class="wp-image-1768 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1.jpg" alt="Detailed Navspark pinout with pin functions" width="500" height="530" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1.jpg 500w, https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1-472x500.jpg 472w" sizes="(max-width: 500px) 100vw, 500px" /></a><figcaption id="caption-attachment-1768" class="wp-caption-text">Navspark pinout from the User Manual</figcaption></figure>
<p><span id="more-2144"></span>These pins have to be connected to a Raspberry Pi 2&#8217;s GPIO pins.</p>
<figure id="attachment_2155" aria-describedby="caption-attachment-2155" style="width: 882px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/raspberry_pi_circuit_note_fig2a-min.jpg"><img decoding="async" class="wp-image-2155 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/raspberry_pi_circuit_note_fig2a-min.jpg" alt="Raspberry Pi 2 pinout diagram" width="882" height="770" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/raspberry_pi_circuit_note_fig2a-min.jpg 882w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/raspberry_pi_circuit_note_fig2a-min-500x437.jpg 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/raspberry_pi_circuit_note_fig2a-min-768x670.jpg 768w" sizes="(max-width: 882px) 100vw, 882px" /></a><figcaption id="caption-attachment-2155" class="wp-caption-text">Raspberry Pi 2 pinout diagram</figcaption></figure>
<p>Based on the pinout above, and some digging around, the connections I needed to make between the Pi (left) and Navspark (right) were:</p>
<ul>
<li>5V <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2194.png" alt="↔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> BATTERY</li>
<li>Ground <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2194.png" alt="↔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> GND</li>
<li>GPIO15 (UART0_RX) <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2194.png" alt="↔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> TXD1</li>
<li>GPIO8 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2194.png" alt="↔" class="wp-smiley" style="height: 1em; max-height: 1em;" /> P1PPS (GPO3)</li>
</ul>
<p>Some things to remember here, that on serial connections one side&#8217;s RX line is connected to the other&#8217;s TX  and vice versa. Also, as much as I gather any other GPIO pins on the Pi could be used to receive the 1PPS signal, I used GPIO8 because it&#8217;s been used by other projects and playing it safe&#8230;</p>
<p>The adapter board was easy enough to put together (though single-side pads are a pain when the components are on both sides, as it is the case here).</p>
<figure id="attachment_2147" aria-describedby="caption-attachment-2147" style="width: 604px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/RPi_Navspark_testrun_home.jpg"><img decoding="async" class="wp-image-2147 size-large" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/RPi_Navspark_testrun_home-1024x715.jpg" alt="Raspberry Pi 2 with Navspark adapter board" width="604" height="422" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/RPi_Navspark_testrun_home-1024x715.jpg 1024w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/RPi_Navspark_testrun_home-500x349.jpg 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/RPi_Navspark_testrun_home-768x536.jpg 768w" sizes="(max-width: 604px) 100vw, 604px" /></a><figcaption id="caption-attachment-2147" class="wp-caption-text">Raspberry Pi 2 with Navspark adapter board</figcaption></figure>
<p>The adapter works well enough, though I&#8217;m sure that it could be done nicer.</p>
<h2>Software</h2>
<p>I found a lot of examples and help from other people&#8217;s similar projects but there were still some differences to be figured along the way. The overall setup was to be as follows:</p>
<ul>
<li><a href="http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2">ArchLinux ARM</a> for base platform</li>
<li><a href="http://www.catb.org/gpsd/">gpsd</a> for interpreting the Navspark NMEA messages</li>
<li>LinuxPPS for 1PPS signal passing from GPIO to the userspace</li>
<li><a href="http://chrony.tuxfamily.org/">chrony</a> as time server (as opposed to the usual ntpd)</li>
</ul>
<p>Installing the system was straightforward enough (well, because I&#8217;ve done it so many times, but I digress), and added a few required basic packages: gpsd, chrony, git, the base-devel group, <a href="https://wiki.archlinux.org/index.php/Avahi">avahi</a> (for easier network discovery).</p>
<h3>GPSD</h3>
<p>UART0 serial communication is done through the /dev/ttyAMA0 device in Pi, though the default settings needed some change for gpsd to be able to receive the data from Navspark.</p>
<p>Most of the changes our <a href="http://logicalgenetics.com/serial-on-raspberry-pi-arch-linux/">outline in a blogpost</a> where I have learned from as well. First remove all config settings from /boot/cmdline.txt, basically these parts:</p>
<pre class="lang:default decode:true">console=ttyAMA0,115200 kgdboc=ttyAMA0,115200</pre>
<p>Next disable the automatic serial console on that device with removing relevant systemd unit with</p>
<pre class="lang:default decode:true">sudo systemctl disable serial-getty@ttyAMA0.service</pre>
<p>Then have to set up the serial channel&#8217;s baud rate to enable communication, and here I&#8217;ve done that with udev: create a new rule file at /etc/udev/rules.d/AMA0_serial.rules with the content of</p>
<pre class="lang:default decode:true ">KERNEL=="ttyAMA0", RUN+="/bin/stty -F /dev/ttyAMA0 115200 raw -echo"</pre>
<p>which will set the 115200 baud rate used by Navspark when the ttyAMA0 device comes up.</p>
<p>Finally have to add gpsd&#8217;s default settings in the /etc/gpsd file:</p>
<pre class="lang:default decode:true "># Default settings for gpsd.
START_DAEMON="true"
GPSD_OPTIONS="-b -n"
DEVICES="/dev/ttyAMA0"
USBAUTO="true"</pre>
<p>Now it&#8217;s ready, and should be able to run gpsd and see some communication.</p>
<pre class="lang:default decode:true">sudo systemctl start gpsd</pre>
<p>and if want to start it on boot, then run the same command with &#8220;enable&#8221; instead &#8220;start&#8221;. Use gpsmon to see what NMEA data Navspark sends, and hopefully it will lock on soon too (mind the sky visibility!). Can also use cgps to monitor which satellites the system is locked onto.</p>
<h3>1PPS</h3>
<p>For 1PPS I had to add an item to /boot/config.txt:</p>
<pre class="lang:default decode:true">dttoverlay=pps-gpio,gpiopin=8</pre>
<p>This adds the relevant device tree overlay to enable the pps-gpio driver on GPIO8. Upon boot there was a /dev/pps0 device that can be poked at e.g. with ppstest from <a href="https://github.com/ago/pps-tools">pps-tools</a>. Since pps-tools did not have a package on ArchLinux, I made one, and the <a href="https://gist.github.com/imrehg/5548370432737a82f58c">PKGBUILD is available on Github</a>. That package also adds the timepps.h header file which is required for the chrony PPS driver to work.</p>
<p>The pps signal can be checked by running ppstest:</p>
<pre class="lang:sh decode:true ">$ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1448436177.999366423, sequence: 199 - clear  0.000000000, sequence: 0
source 0 - assert 1448436178.999373610, sequence: 200 - clear  0.000000000, sequence: 0
...</pre>
<p>but it needs a 3D fix for the signal to show up.</p>
<h3>Chrony</h3>
<p>Next up is the time server itself. The satellite time will be pulled in using two &#8220;reference clock&#8221;: the GPS timestamps provided by gpsd through a memory interface, and the PPS data that locks those timestamps. Unfortunately the PPS driver is not built in by default because it needs the timepps.h header. This means after installing pps-tools chrony needs to be recompiled.</p>
<p>Update the chrony configuration by editing the /etc/chrony.conf file. I usually leave the defaults alone, and add my modifications to the end of the file for clarity. Here&#8217;s my current setup:</p>
<pre class="lang:default decode:true">lock_all

logdir /var/log/chrony
log measurements statistics tracking refclocks

# being a server
allow 192.168/16

server 2.tw.pool.ntp.org iburst
server 3.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server 1.europe.pool.ntp.org iburst

# on-boot time setup, from https://news.ycombinator.com/item?id=9796885
makestep 0.1 1

# from https://www.raspberrypi.org/forums/viewtopic.php?f=41&amp;t=1970&amp;start=275
refclock PPS /dev/pps0 lock GPS prefer refid PPS0
# If Beidou, there is a day offset somehow
refclock SHM 0 offset -86400 delay 0.1 refid GPS noselect

leapsectz right/Asia/Taipei</pre>
<p>It uses <a href="http://www.pool.ntp.org/en/">NTP pool servers</a> for initial time setup and a quick on-boot step (as we don&#8217;t want to be stuck at 1970, do we?). The time service related settings are the &#8220;<a href="http://chrony.tuxfamily.org/manual.html#refclock">refclock</a>&#8221; parts. The first line sets the 1PPS lock-on and I tell chrony to prefer that over other sources so we&#8217;ll switch over to that when there&#8217;s good-enough data. The second refclock section uses gpsd&#8217;s NMEA data. The large offset there is due to some issues where the reference time shows up with 24h offset. That I still need to investigate. The delay time set needs some fine-tuning too (I think), though from comments 0.1-0.3 (that is seconds) seems to be suitable? I also tell chrony not to use that for reference.</p>
<p>I also set leap seconds timezones (with the &#8220;right/&#8230;&#8221;  TAI time zone, see e.g. the <a href="http://support.ntp.org/bin/view/Support/TimeScales">NTP support page</a> and a <a href="https://lists.debian.org/debian-user/2005/12/msg03343.html">discussion on the Debian mailing list</a>). And I enable the server on the local network so other can connect to it and get the time.</p>
<p>I&#8217;ve enabled logging of the tracking data (so there&#8217;s offset and other information available) and refclocks (tailing /var/log/chrony/refclocks.log continuously is a handy way to see when the lock is lost).</p>
<p>Start chrony (or enable if you want to start it on boot)</p>
<pre class="lang:default decode:true">sudo systemctl start chrony</pre>
<p>and the results can be monitored with chronyc.</p>
<h3>All together now</h3>
<p>If everything worked well, gpsmon should show a good locked signal after not too much time, something like this:</p>
<figure id="attachment_2149" aria-describedby="caption-attachment-2149" style="width: 823px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_gpsmon.png"><img loading="lazy" decoding="async" class="wp-image-2149 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_gpsmon.png" alt="Navspark lock in gpsmon" width="823" height="513" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_gpsmon.png 823w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_gpsmon-500x312.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_gpsmon-768x479.png 768w" sizes="auto, (max-width: 823px) 100vw, 823px" /></a><figcaption id="caption-attachment-2149" class="wp-caption-text">Navspark lock in gpsmon</figcaption></figure>
<p>From the interface above I can also see that Navspark has a 3D lock (Mode A3) to satellites number 209, 207, and 206, which are Beidou birds. And that the time offset is 86399.96 seconds (~24h), that is what the chrony configuration compensates for.</p>
<p>Checking the results in chrony I the system time it&#8217;s locked to PPS0 where the last sample had 410ns offset (pretty good).  Also printed the sourcestats.</p>
<figure id="attachment_2150" aria-describedby="caption-attachment-2150" style="width: 823px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_chronyc.png"><img loading="lazy" decoding="async" class="wp-image-2150 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_chronyc.png" alt="Navspark-powered chrony time lock (PPS0 and GPS signal is relevant): sources and sourcestats" width="823" height="513" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_chronyc.png 823w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_chronyc-500x312.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_chronyc-768x479.png 768w" sizes="auto, (max-width: 823px) 100vw, 823px" /></a><figcaption id="caption-attachment-2150" class="wp-caption-text">Navspark-powered chrony time lock (PPS0 and GPS signal is relevant): sources and sourcestats</figcaption></figure>
<p>And this is pretty much all that is needed in general to have a Stratum-1 (atomic clock-locked) NTP server in general.</p>
<p>Some extra references:</p>
<ul>
<li><a href="http://brandon.penglase.net/index.php?title=NavSpark_GPS%2BGLONASS_Stratum-1_NTP_Time_Source_with_a_Raspberry_Pi">NavSpark GPS+GLONASS Stratum-1 NTP Time Source with a Raspberry Pi</a></li>
<li><a href="http://wiki.hackspherelabs.com/index.php?title=NTP_GPS_Time_Server">Hackspherelab: NTP GPS Time Server</a></li>
<li><a href="http://www.catb.org/gpsd/gpsd-time-service-howto.html">GPSD Time Service HOWTO</a></li>
</ul>
<h2>Experience</h2>
<p>Navspark has a GNSS Viewer program (available for download <a href="http://www.navspark.com.tw/downloads/">from their website</a>) which can also set the module&#8217;s parameters, for example forcing it to only listen to the GPS signal or only Beidou signal. There are a lot of settings, and I think most don&#8217;t need any change, but there&#8217;s still a bit to explore, and it&#8217;s definitely a handy tool.</p>
<figure id="attachment_2152" aria-describedby="caption-attachment-2152" style="width: 1012px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/GNSS_Viewer_GPS_BD.png"><img loading="lazy" decoding="async" class="wp-image-2152 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/GNSS_Viewer_GPS_BD.png" alt="GNSS Viewer (and configuration) in Windows" width="1012" height="740" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/GNSS_Viewer_GPS_BD.png 1012w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/GNSS_Viewer_GPS_BD-500x366.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/GNSS_Viewer_GPS_BD-768x562.png 768w" sizes="auto, (max-width: 1012px) 100vw, 1012px" /></a><figcaption id="caption-attachment-2152" class="wp-caption-text">GNSS Viewer (and configuration) in Windows</figcaption></figure>
<p>Running the NTP lock and looking at the tracking lock there are immediately a few lessons in the ~1 day I&#8217;ve been playing with the system:</p>
<p><strong>Environment matters a lot</strong>: having wind blowing over the system and being exposed to temperature changes (e.g. outdoor setting) is quite bad for frequency/time stability. One could say duh! but it&#8217;s good to see. Even a curtain and placing it indoors helps too, though having it in a well air conditioned space is even better. Too bad that in that case the sky visibility and thus the signal strength suffers a lot, but as long as there&#8217;s enough signal to have a lock it is worth it.</p>
<p><strong>PPS is lost when 3D fix is lost</strong>: this took a while to figure out why did I lose lock every now and then, especially because once chrony loses the PPS signal it won&#8217;t pick it up again.</p>
<p><strong>Indoor can work</strong>: indoor lock with the <a href="http://navspark.mybigcommerce.com/internal-gps-beidou-active-antenna/">default antenna</a> can work, but the building structure matters a lot.</p>
<h3>GPS vs Beidou</h3>
<p>Of course the most interesting part is comparing GPS and Beidou. What follows here is not very well qualified yet, just first impressions and need more work.</p>
<p>One of the biggest advantage of GPS is having a lot more satellites than Beidou. I wouldn&#8217;t be surprised if they are transmitting at a higher power too, or some other ways easier to receive. When locked onto GPS I could have rock-solid indoors time lock with 4-9 satellites visible at any one time. The time precision is judged by the offset frequency distribution that chrony reports (and would love to hear if there&#8217;s a better way to do that!), and that had a standard deviation of about 1µs by experience (in an air-conditioned office).</p>
<p>When I&#8217;ve enabled both GPS and Beidou then Navspark seemed to have generally locked onto the Beidou signal. When i was lucky I got 5-6 satellites, but generally it&#8217;s around 3 &#8211; just on the threshold of having a 3D fix, and the source of the PPS-unlock mentioned above. The offset stability on the other hand can be really good, I had runs that had about 5x smaller time offset standard deviation than GPS had (~0.2µs), and that&#8217;s quite a bit of improvement!</p>
<p>The issue is, that when I set the Navspark module GPS+Beidou then when there was a low Beidou satellite count (2-3), even though it still kept a (fragile) 3D fix, the time offset stability was pretty much the same as GPS on its own, though with some intervals of improved readings&#8230;.</p>
<figure id="attachment_2154" aria-describedby="caption-attachment-2154" style="width: 823px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_cgps.png"><img loading="lazy" decoding="async" class="wp-image-2154 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_cgps.png" alt="Locked onto a bunch of Beidou satellites (PRN larger than 200)" width="823" height="513" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_cgps.png 823w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_cgps-500x312.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Navspark_cgps-768x479.png 768w" sizes="auto, (max-width: 823px) 100vw, 823px" /></a><figcaption id="caption-attachment-2154" class="wp-caption-text">Locked onto a bunch of Beidou satellites (PRN larger than 200)</figcaption></figure>
<p>This below is a ~35minutes run of GPS+Beidou setup in an air-conditioned office with limited sky-view and 3 more stories above, using the default 12dB antenna. Using cpgs I could see that in general the lock was provided by 2-3 Beidou satellites, and in some intervals switched over to GPS without losing PPS signal (until it did). Thus it&#8217;s not the best performance that I&#8217;ve seen but still pretty good. Offset is plotted with the reported standard deviation as error bars. The central line is the mean value of the offset readings, and the two bars are the standard deviation calculated from the offsets.</p>
<figure id="attachment_2158" aria-describedby="caption-attachment-2158" style="width: 604px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Beidou_offset_log.png"><img loading="lazy" decoding="async" class="wp-image-2158 size-large" src="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Beidou_offset_log-1024x745.png" alt="Beidou time-lock offset over time (cutting the transients in the beginning, and finishing with signal being lost)" width="604" height="439" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Beidou_offset_log-1024x745.png 1024w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Beidou_offset_log-500x364.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Beidou_offset_log-768x559.png 768w, https://gergely.imreh.net/blog/wp-content/uploads/2015/11/Beidou_offset_log.png 1100w" sizes="auto, (max-width: 604px) 100vw, 604px" /></a><figcaption id="caption-attachment-2158" class="wp-caption-text">Beidou time-lock offset over time (cutting the transients in the beginning, and finishing with signal being lost)</figcaption></figure>
<h2>Future</h2>
<p>The ideal setup would be a well air-conditioned roof-top location (I think it would be possible to reliably see 6-7 satellites that way), and switching to Beidou only measurements to clearly see the difference between the two satellite network.</p>
<p>Improved reception could probably be achieved by <a href="http://navspark.mybigcommerce.com/tri-band-gps-galileo-glonass-bds-active-antenna/">a different Navspark antenna</a>, which provides 25±3dB gain (that&#8217;s an extra ~13dB above the current antenna), and should help indoor reception a lot. It&#8217;s currently on pre-sale and expected by the end of the year, so will keep an eye on it!</p>
<p>For more advanced improvements, the adapter board would be easy enough to redo on PCB (instead of surface mount soldering), add maybe some more voltage stabilization for the module to improve the noise figure, and probably have cleaner 1PPS signal too (compared to flying wires). Will definitely give it a try as it is so easy to get the boards printed these days, e.g. with <a href="http://www.seeedstudio.com/propagate/">Seeed Studio</a>.</p>
<p>Finally some more setting adjustments could improve the final result, such as tweaking the 1PPS pulse length, using the surveying profile for higher precision (though have to figure out what does it mean first, but looks promision), and other little tweaks&#8230;.</p>
<p>It looks to me that if the satellite reception issues are cleaned up, the Navspark + Beidou 1PPS signal should be interesting to try with laboratory frequency references for long term stability (such as a <a href="http://www.thinksrs.com/products/FS725.htm">Rubidium Clock</a>). And of course to run the Pi+Navspark as a local time reference and provide a NTP service, e.g. from the <a href="https://taipeihack.org">Tapei Hackerspace</a>&#8230;. Plenty to do. :)</p>
<p>The post <a href="https://gergely.imreh.net/blog/2015/11/navspark-beidou-ntp/">Dual Satellite NTP server with Navspark</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2015/11/navspark-beidou-ntp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Navspark: Arduino for GPS, GLONASS, and Beidou</title>
		<link>https://gergely.imreh.net/blog/2014/05/navspark-beidou/</link>
					<comments>https://gergely.imreh.net/blog/2014/05/navspark-beidou/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Sun, 18 May 2014 14:21:16 +0000</pubDate>
				<category><![CDATA[Maker]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[beidou]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[indiegogo]]></category>
		<category><![CDATA[navspark]]></category>
		<guid isPermaLink="false">https://gergely.imreh.net/blog/?p=1759</guid>

					<description><![CDATA[<p>Unboxing Navspark, a GPS and Beidou satellite positioning enabled Arduino compatible device, and using it to identify the Beidou satellites visible above.</p>
<p>The post <a href="https://gergely.imreh.net/blog/2014/05/navspark-beidou/">Navspark: Arduino for GPS, GLONASS, and Beidou</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I&#8217;m very much into satellite navigation as previous projects might show (<a title="My IT travel pack" href="https://gergely.imreh.net/blog/2014/04/my-it-travel-pack/">my IT travel pack</a>, <a title="StartupBus rolling again" href="https://gergely.imreh.net/blog/2012/03/startupbus-rolling-again/">StartupBus tracking</a>, <a title="GPS satellite tracks animation " href="https://www.youtube.com/watch?v=kp09W5El52U">GPS satellite tracking</a>). Because of this I was very excited to see an <a title="Navspark Indiegogo page" href="https://www.indiegogo.com/projects/navspark-arduino-compatible-with-gps-gnss-receiver">Indiegogo project for Navspark</a>, an Arduino compatible GPS, GLONASS, and Beidou receiver. I guess everyone knows <a title="GPS Wikipedia page" href="http://en.wikipedia.org/wiki/Global_Positioning_System">GPS</a>, <a title="GLONASS Wikipedia page" href="http://en.wikipedia.org/wiki/GLONASS">GLONASS</a> is the equivalent Russian satellite network, and <a title="Beidou Wikipedia page" href="http://en.wikipedia.org/wiki/Beidou_navigation_satellite_system">Beidou</a> is the same for China.</p>
<p>I have signed up to support it for two main reasons: it&#8217;s a Taiwanese project (<a title="Skytraq homepage" href="http://www.skytraq.com.tw/">Skytraq</a>, the company behind Navspark is in in Hsinchu city in Taiwan), and I haven&#8217;t seen anything about Beidou before.</p>
<p>They barely made the campaign, but it&#8217;s not for the lack of quality. There were a lot of updates during and afterwards as well as the project was developing. Those were good behind the scenes information, got to see what parts of hardware development are more troublesome than others.</p>
<h2>The Navspark board</h2>
<figure id="attachment_1763" aria-describedby="caption-attachment-1763" style="width: 500px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-1763 size-full" src="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/navspark1.jpg" alt="Navspark unboxing: board, antenna, pins" width="500" height="333" /><figcaption id="caption-attachment-1763" class="wp-caption-text">Navspark unboxing: board, antenna, pins</figcaption></figure>
<p>The rewards just shipped this week, and since for this campaign I&#8217;m a &#8220;local&#8221;, I got it pretty early. I got my Navspark GPS/Beidou (BD) version in a big envelope, together with an antenna, some pin and a jumper.</p>
<p><span id="more-1759"></span></p>
<p>The size of the board is about the same as the <a title="Arduino Nano homepage" href="http://arduino.cc/en/Main/arduinoBoardNano">Arduino Nano</a>, but not pin-compatible. Navspark&#8217;s pins are multiplexed, and multifunctional.</p>
<figure id="attachment_1768-2" aria-describedby="caption-attachment-1768-2" style="width: 500px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-1768" src="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1.jpg" alt="Detailed Navspark pinout with pin functions" width="500" height="530" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1.jpg 500w, https://gergely.imreh.net/blog/wp-content/uploads/2014/05/pinout1-472x500.jpg 472w" sizes="auto, (max-width: 500px) 100vw, 500px" /><figcaption id="caption-attachment-1768-2" class="wp-caption-text">Navspark pinout from the User Manual</figcaption></figure>
<p>When I first tried to set it up, I&#8217;ve run into some issues. The <a title="Navspark community" href="http://www.navspark.com.tw/">Navspark community site</a> has a lot of information and many tools. I started at the <a title="Navspark resources " href="http://navspark.mybigcommerce.com/resources/">resources page</a>, downloading the User Manual and the customized Arduino IDE made for Navspark. First the IDE didn&#8217;t want to run on my 64bit Linux, but they figured it out and <a title="64bit Linux issue update" href="http://www.navspark.com.tw/forum/64bit-linux-issue">posted an update</a>. Then flashing the code to the board failed with a mysterious error message, but they got that one working as well in the <a title="Navspark flashing error fix" href="http://www.navspark.com.tw/forum/navspark-imege-failure-error-code-4">next update</a>. This all took about a day, after which I could happily develop with my brand new board, awesome!</p>
<h2>Beidou</h2>
<p>When I chose my reward during the campaign, I went for the GPS/Beidou version because my HTC Butterfly already has GLONASS reception, and wanted to try something new. Beidou is an interesting because it just wants to be regional, as opposed to GPS, GLONASS, and the European Galileo positioning network that are all going global. Being regional then it can  use geostationary satellites, and fewer than the other networks.</p>
<p>When I was thinking what should be my first project, I thought I use Navspark to take a look at the Beidou satellites, how do they behave.</p>
<figure id="attachment_1764" aria-describedby="caption-attachment-1764" style="width: 500px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-1764" src="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/navspark2.jpg" alt="Antenna hanging out of the window" width="500" height="333" /><figcaption id="caption-attachment-1764" class="wp-caption-text">Antenna hanging out of the window</figcaption></figure>
<p>I&#8217;ve tried the antenna, and it worked (naturally) better being outside, I hung it up on the little balcony outside of my window. Compiled the &#8220;demo_how_to_extract_gps_info&#8221; sketch, and flashed it.</p>
<p>I needed a few tries to start receiving data from the board, but that&#8217;s just because my memory was rusty of all the tools needed under Linux to get and to understand GPS/positioning data. Reminded myself how to use gpsd, and gpsmon, but those understood only the GPS part.</p>
<h3>Sidetrack: NMEA</h3>
<p>When I started to use gpscat, to just split all the &#8220;NMEA sentences&#8221; (or fragments of data) from the receiver, everything started to make more sense. The NMEA sentences have a 3-letter identifier, what data should be in that sentence. For example the GGA sentence has the location information, while the GSV sentence lists detailed satellite info, or ZDA lists the date and time.</p>
<p>In front of that 3-letter identifier, though there&#8217;s 2 more letters, which I didn&#8217;t pay attention before, but now it makes sense: those can be used to denote which positioning network the data is coming from. When I looked at the logs, I&#8217;ve seen for example &#8220;GPGSV&#8221;, and &#8220;BDGSV&#8221; sentences &#8211; both are detailed satellite data, but one from the GPS (&#8220;GP&#8221;) satellites, while  the other from the Beidou (&#8220;BD&#8221;) satellites. I&#8217;ve seen also &#8220;GN&#8221; as 2-letter identifier, so that&#8217;s probably GLONASS. Since this receiver does not have that function, no actual data shows up in those sentences.</p>
<p>There&#8217;s a lot of <a title="Google search for NMEA sentences" href="https://www.google.com.tw/search?&amp;q=nmea+sentences">NMEA sentence information online</a>, for more details. As an example, here&#8217;s a sentence that lists the first 4 of the Beidou satellites found by the receiver:</p>
<p><code>$BDGSV,2,1,05,203,59,206,34,208,58,181,42,201,56,140,44,204,00,000,34*6D</code></p>
<p>Without going into too much detail, here&#8217;s what&#8217;s inside this line:</p>
<p>&#8220;203&#8221;, &#8220;208&#8221;, &#8220;201&#8221;, and &#8220;204&#8221; are the pseudo-random number generator  (PRN) code of 4 different satellites, basically a way to identify them. For the GPS network, <a title="PRN list for GPS" href="http://en.wikipedia.org/wiki/List_of_GPS_satellites#Cross_reference_of_PRNs_to_satellite_blocks">PRN goes from 1-32</a>, so anything above that is something else. GLONASS has reserved the <a title="GLONASS numbers" href="http://webcache.googleusercontent.com/search?q=cache:91Tjzf2C0FAJ:www.microsurvey.com/helpdesk/index.php%3F_m%3Dknowledgebase%26_a%3Dviewarticle%26kbarticleid%3D268+&amp;cd=2&amp;hl=en&amp;ct=clnk&amp;gl=tw">numbers between 66-85</a> (will have to check this with my Butterfly). These 200+ numbers are again a different network, the Beidou satellites (though I haven&#8217;t found any source yet that spells them out directly).</p>
<p>The 3 numbers after each PRN code is the &#8220;elevation&#8221; (degree over the horizon), &#8220;azimuth&#8221; (horizontal direction in degrees), and signal-to-noise ratio (SNR) of the reception. For example satellite 203 has from my location elevation 59<span style="color: #545454;">°, direction 206° (south-by-south-west), and SNR of 34. The satellite 204 has 0 for elevation and azimuth, meaning it hasn&#8217;t been figured out by the system yet.</span></p>
<h3>Recording</h3>
<p>I&#8217;ve used gpscat to record some (so far about 8 hours) of satellite tracking data, all the NMEA sentences coming out of Navspark. When plugged in, the receiver showed up at /dev/ttyUSB0, and the incoming data stream was correctly received and logged with the command:</p>
<p><code>gpscat -s 115200N1 /dev/ttyUSBx &gt; navspark.log</code></p>
<p>Here the &#8220;-s&#8221; command sets a speed (baud rate) for the USB-serial connection to 115200 bits per second. The &#8220;N1&#8221; part sets No Parity, 1 stop bit, which is usually the case.. Sometime I could communicate without this setting, but often the wrong baud rate was detected, so I guessed that this receiver likes the highest speed that usually occurs (this 115200 baud rate). Finally, all the output is directed into the &#8220;navspark.log&#8221;file.</p>
<p>The 8 hours of data adds up to about 15Mb text, and I&#8217;ve written a Python script to extract the GPS and Beidou satellite location data. Another python script is used to visualize the tracks on the sky above with <a href="http://matplotlib.org/">Matplotlib</a>. The scripts used can be found in the <a title="Navspark supplementary files" href="/supplements/navspark-beidou/">supplementary files section</a>.</p>
<p>First the GPS tracks. This is quite familiar, fast lines across the sky.</p>
<figure id="attachment_1775" aria-describedby="caption-attachment-1775" style="width: 500px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/gps_tracks.png"><img loading="lazy" decoding="async" class="size-medium wp-image-1775" src="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/gps_tracks-500x375.png" alt="Plot of recorded GPS satellite paths " width="500" height="375" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/gps_tracks-500x375.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2014/05/gps_tracks-768x576.png 768w, https://gergely.imreh.net/blog/wp-content/uploads/2014/05/gps_tracks.png 800w" sizes="auto, (max-width: 500px) 100vw, 500px" /></a><figcaption id="caption-attachment-1775" class="wp-caption-text">GPS tracks on a polar plot. Azimuth on the circular axis, elevation on the radial axis. Filtered for satellites with more than 3000 records. Legend lists satellite PRN, and number of records in parentheses.</figcaption></figure>
<p>On the image 0<span style="color: #545454;">° is North, 180° is South, and so on. The centre of the image is right above my location, while the edge of the circle is on the horizon. The satellites are filtered to only show the ones with more than 3000 records, but it&#8217;s still a big mess. This is definitely not my greatest plot ever, but it more or less does the job.</span></p>
<p>Then I&#8217;ve plotted the Beidou tracks too. Similar filter is applied, except for the satellite with PRN 209, that I included as well with fewer records. The tracks look like this:</p>
<figure id="attachment_1778" aria-describedby="caption-attachment-1778" style="width: 500px" class="wp-caption aligncenter"><a href="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/bd_tracks.png"><img loading="lazy" decoding="async" class="wp-image-1778 size-medium" src="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/bd_tracks-500x375.png" alt="Path of the Beidou satellites plotted similarly as the GPS satellites." width="500" height="375" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2014/05/bd_tracks-500x375.png 500w, https://gergely.imreh.net/blog/wp-content/uploads/2014/05/bd_tracks-768x576.png 768w, https://gergely.imreh.net/blog/wp-content/uploads/2014/05/bd_tracks.png 800w" sizes="auto, (max-width: 500px) 100vw, 500px" /></a><figcaption id="caption-attachment-1778" class="wp-caption-text">Beidou satellite tracks, recorded in the same time frame.</figcaption></figure>
<p>The thing that should stand out is not that there are fewer tracks (of course, since there are fewer Beidou satellites), but that there are two very distinct behaviour.</p>
<p>Satellites 201, 203 and 204 stay pretty much at the same place (geostationary orbit), while 206, 207, 208, 209, 210 are tracing out a path.</p>
<p>Now trying to match this information up with the <a title="List of Beidou satellites " href="http://en.wikipedia.org/wiki/Beidou_Navigation_Satellite_System#List_of_satellites_.28as_of_December_2012.29">list of satellites on the Beidou Wikipedia page</a>, I get the following conclusions:</p>
<p>PRN 201, 203, and 204 should correspond to Compass-G1, Compass-G3, and Compass-G4 geostationary satellites. I haven&#8217;t double-checked where their location should be visible from here, but their East-West ordering in the group is correct according to this hypothesis. If that&#8217;s so, there still should be a PRN 205 (Compass-G5 although might not be visible from here), and no PRN 202 (Compass-G2 is not functioning). Not sure what number the latest geostationary Compass-G6 should have, because PRN 206 is already in use.</p>
<p>PRN 206, 207, and 208 seem to be on the same loop (the three colours adding up to a single loop-of-8). Then these could very well be the Compass-IGSO1, -IGSO2, and -IGSO3 satellites which fly a geosynchronous orbit at &#8220;118°E with inclination 55°&#8221;. Not sure yet how that orbit should look like, but the position of their loop compared to the geostationary satellites looks promising.</p>
<p>PRN 209 and 210 also seem to be of the same loop, so probably Compass-IGSO4, and -IGSO5, on a geosynchronous orbit &#8220;95°E with inclination 55°&#8221;.</p>
<p>It&#8217;s pretty cool that from a mere few hours of recording we can identify all the Beidou satellites.</p>
<p>An extra mystery</p>
<p>If I check the GPS tracks closely, there are two satellites with code 42 and 50 that don&#8217;t look GPS, but geostationary. A bit of search into what they might be showed that they are are the pair of <a title="Multi-functional Satellite Augmentation System" href="http://en.wikipedia.org/wiki/Multi-functional_Satellite_Augmentation_System">Multi-functional Satellite Augmentation System </a>birds from Japan, to supplement the GPS network. 42 and 50 are their NMEA code, which is equal to PRN-87, so I might have been misusing the &#8220;PRN code&#8221; terminology, but maybe not too much.</p>
<p>There&#8217;s one more satellite with PRN 193 that is out of ordinary. That shows up in a <a title="QZSS Research at UNSW" href="http://www.gmat.unsw.edu.au/snap/publications/glennon2011a.pdf">document</a> as <a title="Quasi-Zenith Satellite System" href="http://en.wikipedia.org/wiki/Quasi-Zenith_Satellite_System">Quasi-Zenith Satellite System</a> SV 1 bird. That system is for time transfer, and also to further improve GPS over Japan.</p>
<p>It&#8217;s interesting that this receiver can find them. And I guess the Japanese space program does worth to take a deeper look at!</p>
<h2>What to do next?</h2>
<p>This is a good first experiment, because there are a lot of questions answered, while almost as many new questions popped up. Already have more ideas what to do than time to do it.</p>
<ul>
<li>Should compare the position accuracy of this receiver and one of the other USB GPS receivers I have. Not totally fair, because they kinda have a more complete antenna, but maybe under open sky it would work.</li>
<li>Figure out how GPS and Beidou satellites are used together to get a location. Are they? Or separately?</li>
<li>Try out the other Navspark functions, which there are many! The examples show ADC, timestamping, SPI, two-wire, 400KHz PWM output. It&#8217;s also running on higher frequency (100MHz?) and more program memory (1Mb?) than Arduino.</li>
<li>Try other programs now playing with GPS, for example gpredict (orbital prediction and tracking). If they don&#8217;t have support for Beidou, maybe can try add to them?</li>
<li>Find my <a title="Orbital Mechanice for Engineering Students on Goodreads" href="https://www.goodreads.com/book/show/2534162.Orbital_Mechanics_for_Engineering_Students">Orbital Mechanics for Engineering Students</a> book, and get learning!</li>
</ul>
<p>What would <strong>you</strong> like to do with such hard core geo-positioning tool?</p>
<p>The post <a href="https://gergely.imreh.net/blog/2014/05/navspark-beidou/">Navspark: Arduino for GPS, GLONASS, and Beidou</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2014/05/navspark-beidou/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 18/22 objects using APC
Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: gergely.imreh.net @ 2026-10-26 21:43:32 by W3 Total Cache
-->