<?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>Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69654/limits-to-software-quadrature-decoder-with-nrf52840-with-softdevice</link><description>Hello list, 
 Starting from the ble_app_uart example I am trying to create 2 dc motor control loops. Instead of using the uart I use the scheduler to create a simple command loop over BLE to control the app. 
 There is only 1 QDEC device so I need a software</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Jan 2021 11:07:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69654/limits-to-software-quadrature-decoder-with-nrf52840-with-softdevice" /><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/287193?ContentTypeID=1</link><pubDate>Mon, 04 Jan 2021 11:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1327fe60-6b63-4234-ba10-7c766d82ac8e</guid><dc:creator>Sietse</dc:creator><description>&lt;p&gt;Thanks for the help!&lt;/p&gt;
&lt;p&gt;I wasn&amp;#39;t able to mark you last reply as the correct answer, but this will do I guess.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/287146?ContentTypeID=1</link><pubDate>Mon, 04 Jan 2021 09:02:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5b3c1ac-01c4-420c-b1d9-ffae351bab84</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Sietse"]&lt;p&gt;I found the reason for the long delay, I think!&lt;/p&gt;
&lt;p&gt;During debugging I did set the gcc optimalisation&amp;nbsp; to -O0. Setting it to -O3 again made the time drop to a little less than 5 msec.&lt;/p&gt;[/quote]
&lt;p&gt;Ah, good news. That could make sense.&lt;/p&gt;
[quote user="Sietse"]Is it possible for force there to be NO low power mode when the motor is used, so programmatically? That would hopefully reduce the latency even further![/quote]
&lt;p&gt;Yes. A typical SoftDevice application enters&amp;nbsp;system ON low power mode by calling sd_app_evt_wait() in the main loop, either directly or via for instance&amp;nbsp;nrf_pwr_mgmt_run(). To not enter a low power mode, simply do not call any of these functions in the main loop (so here you could check if the motor is in use, and only enter low power mode if it is not).&lt;/p&gt;
&lt;p&gt;Happy New Year!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/286458?ContentTypeID=1</link><pubDate>Wed, 23 Dec 2020 12:52:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fb41721-97c0-4211-8019-5232dbc49e0c</guid><dc:creator>Sietse</dc:creator><description>&lt;p&gt;I found the reason for the long delay, I think!&lt;/p&gt;
&lt;p&gt;During debugging I did set the gcc optimalisation&amp;nbsp; to -O0. Setting it to -O3 again made the time drop to a little less than 5 msec.&lt;/p&gt;
&lt;p&gt;When the motor/encoder is to be used, there is no need for a low power mode because the motor is already consuming a lot. Is it possible for force there to be NO low power mode when the motor is used, so programmatically? That would hopefully reduce the latency even further!&lt;/p&gt;
&lt;p&gt;Thanks in advance and happy holidays!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/286278?ContentTypeID=1</link><pubDate>Tue, 22 Dec 2020 12:19:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30228d10-eb70-45e6-b778-f4c826a891dd</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see. So you are measuring (with a logic analyzer or similar) the time from a change on a GPIO input to a change on a GPIO output? If so, 20 ms is much, I agree. If the device is in system on low power mode (after a call to sd_app_evt_wait() or _WFE()) the HFINT clock needs to be started, which adds about 4 ms. There are also some microseconds for CPU startup etc, and some CPU cycles for your logic. But it should not add up to anything close to 20 ms.&lt;/p&gt;
&lt;p&gt;Can you share a project that reproduce this so that I can test on my side? Please note that I will be off for Christmas holiday until beginning of January though, so my next reply will probably be delayed until then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/286090?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 14:56:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27a7b31d-a8ec-46df-af42-de0cd277d66b</guid><dc:creator>Sietse</dc:creator><description>&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;I am not using QDEC, now only testing the software encoder using 2 gpiote interrupts.&lt;/p&gt;
&lt;p&gt;From &amp;#39;Interrupt latency due to SoC framework&amp;#39; I read that there is up to 4 microseconds latency to be expected. Why am I seeing 20 microseconds? I would have thought that only a gpiote interrupt has to be redirected to the app.&lt;/p&gt;
&lt;p&gt;What am I doing wrong here. Nothing is happening: the softdevice is &amp;quot;idling&amp;quot; in the connected state and there can be 2&amp;nbsp; interrupts from the encoder signal. Nothing more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/286004?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 10:21:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a805d2-06b8-4889-a3cb-d4182a4bfef5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am not entirely sure I understand the question or context. How have you configured the QDEC? The sample period is important here, and the shortest period you can configure is 128 us. There is no way to get higher time resolution then that.&lt;/p&gt;
&lt;p&gt;Though that may not be relevant, you can see the duration of time the SoftDevice will block the application from the SoftDevice specification under &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/processor_usage_patterns.html"&gt;Processor usage patterns and availability&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/285946?ContentTypeID=1</link><pubDate>Sun, 20 Dec 2020 16:38:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fda03401-ea81-4d01-a1e4-225042c11e56</guid><dc:creator>Sietse</dc:creator><description>&lt;p&gt;Further investigation with scope and logic analyzer reveals that the encoder signals are not clean. When running faster they probably create the problems. So probably a problem in my hardware setup, sorry.&lt;/p&gt;
&lt;p&gt;But I would very much like to understand the issues with the delays I mentioned. What is happening during the 20 microsecond? This to learn whether it is feasible or not, having very short interrupts every, say, 200 or more microseconds.&lt;/p&gt;
&lt;p&gt;And why is it so constant? This suggests that it has nothing to do with a busy softdevice. Note that the testing is done while connected with bluetooth and no communication over bluetooth, so i would imagine the softdevice is more or less at &amp;quot;rest&amp;quot;.&lt;/p&gt;
&lt;p&gt;I tried the tests with the gpiote interrupt levels 6 and 2. Thanks again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Limits to software quadrature decoder with nrf52840 with softdevice.</title><link>https://devzone.nordicsemi.com/thread/285788?ContentTypeID=1</link><pubDate>Fri, 18 Dec 2020 10:29:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e64fb65-cf78-472a-a202-fa660beba5d2</guid><dc:creator>Sietse</dc:creator><description>&lt;p&gt;It is a but more complicated. When using a gpio in the handler and a scope I see that all interrupts are coming through!&lt;/p&gt;
&lt;p&gt;There is a constant delay from the encoder edge and the toggling of the gpio of 20 microseconds. And it occasionally jumps to 150 microseconds.I find the constant 20 microsecond a very long and also strange that it is so very constant, but for my use case it is ok. The minimum distance between encoder interrupts is 200 micoseconds, so it could work.&lt;/p&gt;
&lt;p&gt;I will first investigate further.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>