<?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>Using Comparator as &amp;quot;Window&amp;quot; for potentiometer wake up.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30819/using-comparator-as-window-for-potentiometer-wake-up</link><description>I am trying to use the comparator to wake me up when a potentiometer is moved a certain amount. 
 Before I sleep I read the ADC value of the comparator and use this to set the upper and lower value of the comparator. 
 My issue is this only works when</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 07 Mar 2018 20:55:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30819/using-comparator-as-window-for-potentiometer-wake-up" /><item><title>RE: Using Comparator as "Window" for potentiometer wake up.</title><link>https://devzone.nordicsemi.com/thread/123321?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2018 20:55:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8345c01-e469-4dac-9692-8d58054d0e84</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, this is correct. You will only get events when the output change.&lt;/p&gt;
&lt;p&gt;What is your detection delay and current consumption requirements? The SAADC can do periodic sampling with &lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/saadc_low_power"&gt;quite low average current consumption&lt;/a&gt;,&amp;nbsp;and it might not be that much higher than the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/comp.html?cp=2_1_0_37_3#unique_108605566"&gt;COMP run current&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Comparator as "Window" for potentiometer wake up.</title><link>https://devzone.nordicsemi.com/thread/123145?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 22:24:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:892768ce-7305-459e-aa36-e6b471def3a5</guid><dc:creator>LukeC</dc:creator><description>&lt;p&gt;So, the end conclusion of this would then mean I cannot set the upper and lower thresholds above and below my current input voltage and interrupt when the potentiometer is moved up or down correct?&amp;nbsp; If VIN has to cross both thresholds to get an event then I would have to pick one direction for the POT to move in order to get an event.&lt;/p&gt;
&lt;p&gt;Are there&amp;nbsp;any other means to do this?&amp;nbsp; The only other option i can think of is to wake periodically and read the input as an ADC to see if the user changed the POT position.&amp;nbsp; This seems like it would cause much worse battery life and average power consumption.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Comparator as "Window" for potentiometer wake up.</title><link>https://devzone.nordicsemi.com/thread/123110?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 15:03:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa565b80-598e-436d-bb32-c5f4cad643c9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I think your understanding should be correct. This is taken from the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/comp.html?cp=2_1_0_37#topic"&gt;product specifications&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Event generation on output changes&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;UP event on VIN- &amp;gt; VIN+&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;DOWN event on VIN- &amp;lt; VIN+&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;CROSS event on VIN+ and VIN- crossing&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;READY event on core and internal reference (if used) ready&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Use the&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/comp.html#register.PSEL"&gt;PSEL&lt;/a&gt;&amp;nbsp;register to select any of the AIN0-AIN7 pins as VIN+ input, irregardless of the operation mode selected for the comparator. The source of VIN- depends on which operation mode is used:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Differential mode: Derived directly from AIN0 to AIN7&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Single-ended mode: Derived from VREF. VREF can be derived from VDD, AIN0-AIN7 or internal 1.2 V, 1.8 V and 2.4 V references.&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The events should be generated on output changes (OUTPUT: 0&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;= BELOW (VIN+ &amp;lt; VIN-),&amp;nbsp;&lt;/span&gt;1&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;= ABOVE (VIN+ &amp;gt; VIN-)).&amp;nbsp;When the events will be generated will depend on the initial value of VIN+. Please study the diagram in Figure 5 in the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/comp.html?cp=2_1_0_37_1#unique_40716891"&gt;single-ended mode chapter&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Comparator as "Window" for potentiometer wake up.</title><link>https://devzone.nordicsemi.com/thread/122526?ContentTypeID=1</link><pubDate>Fri, 02 Mar 2018 00:41:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daa21a4f-6016-45af-87d0-25995e01e5c2</guid><dc:creator>LukeC</dc:creator><description>&lt;p&gt;I am verifying the up/down threshhold view an NRF_LOG print out.&lt;/p&gt;
&lt;p&gt;Perhaps I am misunderstanding what causes an event?&lt;/p&gt;
&lt;p&gt;My thinking was that if the input went outside of just&amp;nbsp;&lt;em&gt;one&lt;/em&gt; of the thresholds, then an event would be generated for that threshold.&lt;/p&gt;
&lt;p&gt;What I am seeing is that it seems like the input as to move past&amp;nbsp;&lt;em&gt;both&amp;nbsp;&lt;/em&gt;thresholds.&amp;nbsp; Is this right?&amp;nbsp; That would invalidate my approach.&lt;/p&gt;
&lt;p&gt;I tried forcing the system to only see UP events and to not stop after event.&lt;/p&gt;
&lt;p&gt;nrf_drv_comp_start( NRF_DRV_COMP_EVT_EN_UP_MASK ,&lt;br /&gt; NULL );&lt;/p&gt;
&lt;p&gt;I just hard coded some different thresholds to see what happens.&lt;/p&gt;
&lt;p&gt;myCompConfig.threshold.th_down = 20;&lt;br /&gt; myCompConfig.threshold.th_up = 40;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; It seems like I have to go under the lower threshold and back up to trip the upper.&amp;nbsp; That doesn&amp;#39;t seem right to me, but again maybe I misunderstand how the thresholds work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Comparator as "Window" for potentiometer wake up.</title><link>https://devzone.nordicsemi.com/thread/122244?ContentTypeID=1</link><pubDate>Wed, 28 Feb 2018 09:35:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b2ff5e6-ca35-46c4-8be1-153e5d1f644b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This looks correct. Are you not getting any UP events at all? I tried this without ADC reading on the DK, and I get both UP and DOWN events.&amp;nbsp;Had to change your code to call&amp;nbsp;nrf_drv_comp_start() in the callback to receive multiple events, as the&amp;nbsp;NRF_DRV_COMP_SHORT_STOP_AFTER_XX_EVT parameters will stop the comp after one event.&lt;/p&gt;
&lt;p&gt;What values are you normally passing to&amp;nbsp;threshold.th_down and&amp;nbsp;myCompConfig.threshold.th_up? If these are way off, you might not reach the upper treashold to trigger the up event.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>