<?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>SAADC readings are frequency-dependent?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66332/saadc-readings-are-frequency-dependent</link><description>Hello, 
 I am using the SAADC of a nRF52832 with a sample-rate of 1ms (1kHz). 
 The following code shows, how my SAADC is intialized: 
 
 My problem is, that it looks like, that the readings of the SAADC are frequency-dependent. 
 I applied the following</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Sep 2020 09:14:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66332/saadc-readings-are-frequency-dependent" /><item><title>RE: SAADC readings are frequency-dependent?</title><link>https://devzone.nordicsemi.com/thread/271470?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 09:14:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3b1ba53-d67c-4ab1-91cc-831ab1d73ba7</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;If you set&amp;nbsp;&lt;span&gt;SAMPLES_IN_BUFFER to 1 then you will have sampling errors when the SoftDevice is running. A&amp;nbsp;SAMPLES_IN_BUFFER of 4 is still critically low. At high buffer sizes the likelihood of sampling error will be reduced, but not eliminated. The v2 driver further reduces this likelihood.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;See&amp;nbsp;modules\nrfx\drivers\src\nrfx_saadc.c and&amp;nbsp;modules\nrfx\drivers\include\nrfx_saadc_v2.h&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC readings are frequency-dependent?</title><link>https://devzone.nordicsemi.com/thread/271458?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 08:30:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e4c7981-8c15-4e9a-919c-5ba82b13fc44</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thank you for your reply.&lt;/p&gt;
&lt;p&gt;With your advice to take a look to the SAMPLES_IN_BUFFER I was able to figure out the problem.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SAMPLES_IN_BUFFER&amp;nbsp;was set to 4, which is okey if I use four channels. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I set SAMPLES_IN_BUFFER&amp;nbsp;to 1 (At the moment I am using only one channel). I&amp;nbsp;receive correct readings from the saadc now.&lt;/span&gt;&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/66332/saadc-readings-are-frequency-dependent/271434"]I also suggest you try out the&amp;nbsp;&lt;a title="SAADC v2 driver" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__saadc__v2.html?cp=7_1_6_8_0_30_2"&gt;SAADC v2 driver&lt;/a&gt;&amp;nbsp;in nRF5 SDK17,[/quote]
&lt;p&gt;&lt;span&gt;Unfortunaly, I can&amp;acute;t find anything within this link.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Finally, thank you very much for&amp;nbsp;your support.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC readings are frequency-dependent?</title><link>https://devzone.nordicsemi.com/thread/271434?ContentTypeID=1</link><pubDate>Fri, 25 Sep 2020 06:59:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc543d43-8b69-4931-8204-ceed93dd508e</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;The SoftDevice is most likely blocking/delaying your buffer handling, but you probably also have an issue with your signal source.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I suggest you start by increasing the buffer size to a proper size, there&amp;#39;s no point in creating multiple arrays from a single buffer if they&amp;#39;re going to contain the same samples as if you just used one big one.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I also suggest you try out the&amp;nbsp;&lt;a title="SAADC v2 driver" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__saadc__v2.html?cp=7_1_6_8_0_30_2"&gt;SAADC v2 driver&lt;/a&gt;&amp;nbsp;in nRF5 SDK17, as it has a better buffer handling than the standard one.&lt;br /&gt;&lt;br /&gt;The SAADC is accurate up to 200ksps, 1ksps is not a problem.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC readings are frequency-dependent?</title><link>https://devzone.nordicsemi.com/thread/271380?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 14:55:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a9fabad-12d2-43c6-9ca1-90875d478c61</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thank you very much for your quick response.&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/66332/saadc-readings-are-frequency-dependent/271357"]Can you share raw samples of the two signals?[/quote]
&lt;p&gt;50Hz signal (1 periode): [20 values] 42,39,38,36,35,34,34,35,37,39,41,43,45,47,48,48,48,47,46,43&lt;/p&gt;
&lt;p&gt;5Hz signal (1 periode): [200 values]&amp;nbsp; from 23 to 60&lt;/p&gt;
&lt;p&gt;-&amp;gt; the raw samples, which the SAADC outputs, are equal to the pictures.&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/66332/saadc-readings-are-frequency-dependent/271357"]What is your buffer size?[/quote]
&lt;p&gt;I set SAADC_SAMPLES_IN_BUFFER to 4. But I do not use this buffer, instead I created my own array for collecting the SAADC readings for further processing. Every time the SAADC callback function gets called, the SAADC reading gets written into this array:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define SAADC_SAMPLES_IN_BUFFER         4

static nrf_saadc_value_t       m_buffer_pool[2][SAADC_SAMPLES_IN_BUFFER];

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        ...
        ret_code_t err_code;
        err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
        ...
        if (counter &amp;lt;= 40){
            ch_values1[counter-1] = p_event-&amp;gt;data.done.p_buffer[0];
        }
        if (counter == 40){     
            counter = 0;
            ble_nus_data_send(...,ch_values1,...)
        }
        counter++;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I read out the raw samples, which i mentioned earlier, from this ch_values1 array.&lt;/p&gt;
[quote userid="13562" url="~/f/nordic-q-a/66332/saadc-readings-are-frequency-dependent/271357"]Are you running the SoftDevice as well?[/quote]
&lt;p&gt;Yes, s132. The SAADC readings were send to the central via NUS every 40ms.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In conclusion, it looks like&amp;nbsp;that I am receiving wrong values from the SAADC.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Do you have an&amp;nbsp;idea what causes this issue?&lt;/p&gt;
&lt;p&gt;2. Do you have any suggestions how to solve this problem?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC readings are frequency-dependent?</title><link>https://devzone.nordicsemi.com/thread/271357?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 13:26:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2db3b0c-b2be-4083-9928-2aa8117b2111</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Can you share raw samples of the two signals? We need to know whether the signals are sampled correctly or not.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;What is your buffer size?&lt;br /&gt;&lt;br /&gt;Are you running the SoftDevice as well?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>