<?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>Wireless timer synchronization among nRF5 devices revisited</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92521/wireless-timer-synchronization-among-nrf5-devices-revisited</link><description>Hello to the community! 
 I have two nRF52832 sensor nodes and aim to implement synchronized sampling of all sensors, including synchronization between sensors of the two nodes. I went through this article . Yet, before starting work, I wish to make sure</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Nov 2022 20:40:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92521/wireless-timer-synchronization-among-nrf5-devices-revisited" /><item><title>RE: Wireless timer synchronization among nRF5 devices revisited</title><link>https://devzone.nordicsemi.com/thread/397279?ContentTypeID=1</link><pubDate>Wed, 23 Nov 2022 20:40:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6620ae9-a72e-4488-8d44-a06ca82433b1</guid><dc:creator>kont40</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the very helpful comments. So far I have succeeded to run the synchronization demo. Next questions are:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(1):&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/92521/wireless-timer-synchronization-among-nrf5-devices-revisited/389101"]More frequent connection interval and more connections in parallel will affect the accuracy of this synchronization module[/quote]
&lt;p&gt;(a) What would be the optimal connection interval to make sure the 100 Hz synchronization is ensured?&amp;nbsp; (I am currently using min connection interval of 7.5 ms and max connection interval of 10 ms, which were good for my application before considering the synchronization).&lt;/p&gt;
&lt;p&gt;(b) This eventually means, that in some applications it maybe challenging to achieve synchronization at frequencies higher than 100 Hz, as this would mean producing higher volumes of data requiring shorter connection intervals, which will make it more challenging to get timeslots properly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(2) I am currently concerned regarding the proper place to call the sensor sampling code at the master and slave side.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So far I am toggling the test pin into RADIO_IRQHandler: &lt;br /&gt;- for the slave device upon the end event of RADIO_STATE_RX;&lt;br /&gt;- for the master device upon the end event of RADIO_STATE_TX;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void RADIO_IRQHandler(void)
{
    if (NRF_RADIO-&amp;gt;EVENTS_END != 0)
    {
        NRF_RADIO-&amp;gt;EVENTS_END = 0;
        (void)NRF_RADIO-&amp;gt;EVENTS_END;
        
        if (m_radio_state == RADIO_STATE_RX &amp;amp;&amp;amp;
           (NRF_RADIO-&amp;gt;CRCSTATUS &amp;amp; RADIO_CRCSTATUS_CRCSTATUS_Msk) == (RADIO_CRCSTATUS_CRCSTATUS_CRCOk &amp;lt;&amp;lt; RADIO_CRCSTATUS_CRCSTATUS_Pos))
        {
            sync_timer_offset_compensate();
            ++m_rcv_count;
                    
                    /* slave node: the code to obtain sensor sample*/
                        nrf_drv_gpiote_out_toggle(10);
        }
                
                
                /* master node: the code to obtain sensor sample*/
        if (m_radio_state == RADIO_STATE_TX)
        {
                        nrf_drv_gpiote_out_toggle(10);
        }                
                
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this way, it seems like I am indeed getting the 100 Hz synchronized pulses of both nodes. &lt;br /&gt;However, I am not sure if these are the right places to put my sensor sample acquisition code;&lt;br /&gt;I am also not sure whether I have to add more conditions to the if (m_radio_state == RADIO_STATE_TX) condition.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(3) What could you suggest as an optimal solution for the MCUs on both sides to check whether the synchronization is happening properly? I aim to discard data or cancel measurements automatically in case of synchronization failure.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wireless timer synchronization among nRF5 devices revisited</title><link>https://devzone.nordicsemi.com/thread/389101?ContentTypeID=1</link><pubDate>Tue, 04 Oct 2022 05:03:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f33d37fc-1152-42d5-bfd0-2dc0aeaf493f</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user=""](1) Can we apply the method described in &amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/guides/short-range-guides/b/bluetooth-low-energy/posts/wireless-timer-synchronization-among-nrf5-devices"&gt;Wireless timer synchronization among nRF5 devices&lt;/a&gt;&amp;nbsp; irrespective of the communication mode; i.e., I am currently using notifications to send the sensor data to the client continuously? Is there any danger that implementing this method will affect the existing communication?[/quote]
&lt;p&gt;You should be able to use this synchronization method even using a BLE connection(s) in parallel. Audun (Author of that blog) has mentioned that &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsds_s132%2FSDS%2Fs1xx%2Fconcurrent_multiprotocol_tsl_api%2Ftsl_usage_examples.html&amp;amp;cp=4_7_3_0_8_2"&gt;Radio Timeslot API&lt;/a&gt;&amp;nbsp;was used to configure the radio and timers to have the maximum predictability when using this along with other protocols that also use Timeslot API. Note that the timeslot frequency is&amp;nbsp; 100Hz (10ms interval) so the connection interval of BLE connection(s) will affect the chances of this synchronization module getting a timeslot every 10ms. More frequent connection interval and more connections in parallel will affect the accuracy of this synchronization module as the chances of requested timeslots reduces with faster connection intervals.&lt;/p&gt;
[quote user=""](2) Synchronization in sampling shall remain valid continuously, e.g., after one hour of data collection. I guess per-sample synchronization may not be efficient, and the proper solution will involve synchronizing the sampling rate timers between the two nodes at regular intervals, e.g., every 10 seconds. Any recommendations regarding choosing the proper strategy and avoiding possible pitfalls will be appreciated.[/quote]
&lt;p&gt;Do you mean to say that over longer period of time the synchronization per-sample will jitter in itself? Hmm, I do not see why this should happen, but I haven&amp;#39;t processed the pitfalls of this communication completely as I have gone through this blog just today to be able to assist you. If you do care to help me explain what exactly are the details of this pitfalls, then maybe I can ask Audun or try myself to assist you with a strategy to come around that pitfall.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>