<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Best timing accuracy between iOS device and peripheral device</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11656/best-timing-accuracy-between-ios-device-and-peripheral-device</link><description>Hi,
I&amp;#39;d like to know how tp estimate of the best &amp;quot;timing accuracy&amp;quot; I could expect to achieve between an iOS device and a peripheral device. The objective is to make a specific thing happen at the same time on these two devices. 
 Using BLE, one approach</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Feb 2016 13:26:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11656/best-timing-accuracy-between-ios-device-and-peripheral-device" /><item><title>RE: Best timing accuracy between iOS device and peripheral device</title><link>https://devzone.nordicsemi.com/thread/44046?ContentTypeID=1</link><pubDate>Tue, 02 Feb 2016 13:26:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ea40b4f-cd15-4bf1-9334-a2cb6e0bb842</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You will inevitably experience multiple delays from the initial call from the tx side application to when the message is received at the rx side application. You may also experience large differences in the delay (&lt;a href="https://en.wikipedia.org/wiki/Jitter"&gt;jitter&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;You will have roughly the following sources for delay:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Preparing the packet&lt;/li&gt;
&lt;li&gt;Waiting for transmission&lt;/li&gt;
&lt;li&gt;Transmission time&lt;/li&gt;
&lt;li&gt;Propagation delay&lt;/li&gt;
&lt;li&gt;Reception operations&lt;/li&gt;
&lt;li&gt;Propagating message to application&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Points 1, 5 and 6 may take several ms on a smartphone, depending on system state. It varies from system to system, and I do not have the numbers for this. It would probably be best to test it yourself on the smartphone you are using. If you do it would be great if you could share your findings. Point 2 is on average half the connection interval. Point 3 can be calculated from BLE transmission rate and packet size. Point 4 is negligible due to the short range of BLE (signal propagates 10 meters in ~33 ns).&lt;/p&gt;
&lt;p&gt;The initial suggestion was to let the smartphone write a characteristic on the nRF device. Using 1.5 ms as a rough estimate for the sum of transmission time and nRF side delays, and 10 ms average for waiting for transmission (20 ms connection interval), one would expect a delay of x + 11.5 ms, where x is the smartphone side delay. The jitter would be substantial (± 10 ms from connection interval, in addition to smartphone and nRF stack jitter.)&lt;/p&gt;
&lt;p&gt;If the smartphone API signals the application when the BLE packet is sent, you can do better. Instead of points 1-3 adding to the delay and jitter, you will get a delay for propagating the signal of &amp;quot;packet sent&amp;quot; to the smartphone app. This would happen concurrently with reception related operations and propagation to application on the nRF side. In this scenario, time used for notifying the application on the nRF side (~1 ms range) is probably shorter than that on the smartphone side, meaning the nRF is triggered a few ms before the application on the smartphone. In any case you have eliminated the connection interval related delay and jitter.&lt;/p&gt;
&lt;p&gt;Depending on your needs and on the application, you may have a look at algorithms for &lt;a href="https://en.wikipedia.org/wiki/Clock_synchronization"&gt;clock synchronisation&lt;/a&gt; similar to the one used for &lt;a href="https://en.wikipedia.org/wiki/Network_Time_Protocol"&gt;Network Time Protocol&lt;/a&gt; (NTP). The basic idea is packet exchanges back and forth between devices A and B, that are timestamped using the RX side clock on RX and the TX side clock on TX. The delay is assumed to behave the same in both directions, and an estimate is calculated for the time difference between the two clocks. When the clocks are synchronised, the devices can perform simultaneous actions. The synchronisation process is kept running (using a longer interval) to keep the clocks from drifting out of sync. The accuracy will often be high compared to network delay and jitter.&lt;/p&gt;
&lt;p&gt;For other options, I suggest that you have a look at these other related questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/question/7184/synchronisation-with-advertisement/"&gt;Synchronisation with advertisement&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/question/38210/multiple-peripherals-accepting-a-packet-from-central/"&gt;Multiple Peripherals accepting a packet from Central&lt;/a&gt; (The questioner needs 1 ms accuracy.)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/question/5269/nrf51-time-synchronize-sensors/"&gt;NRF51 time synchronize sensors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/question/17987/synchronize-two-devices/"&gt;&amp;quot;synchronize&amp;quot; two devices&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Regards, Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>