<?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>Getting correct values from encoder with interrupts</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86745/getting-correct-values-from-encoder-with-interrupts</link><description>Hello! 
 I have to decode signals from two quadrature encoders. I know nordic has a driver for this, QDEC, however. there are a couple problems: 
 1. I need to control two encoders, and this driver only works with one at a time. I would have to un-init</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Apr 2022 14:40:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86745/getting-correct-values-from-encoder-with-interrupts" /><item><title>RE: Getting correct values from encoder with interrupts</title><link>https://devzone.nordicsemi.com/thread/362897?ContentTypeID=1</link><pubDate>Mon, 11 Apr 2022 14:40:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9eefa6c8-259d-4d23-8725-04c84c1deb4a</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user=""] I assume it is because I print out the values into the terminal every time it is triggered, and maybe it can&amp;#39;t keep up.[/quote]
&lt;p&gt;I think that could be the main issue here. &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/56061/migrate-printk-from-uart-to-rtt"&gt;Try redirecting printk to RTT&lt;/a&gt;&amp;nbsp; instead of UART(if you are already not doing that)&lt;/p&gt;
[quote user=""]I am expecting to get something like 2048 pulses, because that is the resolution of the encoder.[/quote]
&lt;p&gt;So 2048 pulses per second? I am not sure if your interrupt is able to fire that fast if there are other activities happening parallel to this computation.&lt;/p&gt;
&lt;p&gt;Doing anything on GPIO interrupt with that frequency will consume a lot of your MCU time so there is not much the MCU can do in other contexts. This method seems very power intense.&amp;nbsp; Maybe you can use one QDEC for one encoder and the GPIO interrupt for the other?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>