<?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>nRF52832 SAADC inaccurate measurement</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement</link><description>Hi! 
 
 I&amp;#39;m working on using the SAADC in 14-bit sampling mode (oversampling set to x2) using nRF SDK 17. The supply voltage for my chip is 3.3V, and I have the reference set to VDD4 with a gain of 4. My understanding is that I should be able to get a</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 01 Mar 2021 13:40:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement" /><item><title>RE: nRF52832 SAADC inaccurate measurement</title><link>https://devzone.nordicsemi.com/thread/296861?ContentTypeID=1</link><pubDate>Mon, 01 Mar 2021 13:40:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a24f0d1b-fb12-4b6b-a1d7-befb9d5540fe</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="macklenc0"]sorry about the slow reply[/quote]
&lt;p&gt;No problem at all - we&amp;#39;ll proceed whenever you are ready, no worries.&lt;/p&gt;
[quote user="macklenc0"]I am sampling about once a second, but the nRF shouldn&amp;#39;t be able to drain an entire 1uF after it&amp;#39;s charged, right?[/quote]
&lt;p&gt;This is correct - the capacitor will not be completely drained by the sampling - so as long as the capacitor has enough time in between samples to always reach its steady state charge, then it would be fine.&amp;nbsp;&lt;br /&gt;However, the capacitor does not need to be drained entirely for the samplings to be off - in your case, the capacitor takes much longer than the sampling interval to fill completely, and because of the &lt;a href="https://lh3.googleusercontent.com/proxy/0ftQFRTR5YEdEXNCgJRhu51mQ8SsgqeoFX_LMTqY0Uh_IfKWAjEescpRLlGHuDJjhI1bnNp99Aii4LTstligqW6PaMpluprG5uF9oQ0NkTQBQN75c9vM"&gt;unlinearity of capacitor charging curves&lt;/a&gt;, it will never make it to the steady state once sampling starts, and thus your samples will always be fluctuating because of it.&lt;br /&gt;So, by oversizing the capacitor you are also increasing the time required in between samples to ensure correct readings.&lt;/p&gt;
[quote user="macklenc0"]But I will give installing new capacitors a try, unfortunately it&amp;#39;s not easy to modify the current platform so it&amp;#39;ll be one of the last things I try just in case I have to go back.[/quote]
&lt;p&gt;Perhaps you could test just the sampling part of a separate platform, instead of modifying your main test platform, to see how this improves your sampling accuracy.&lt;br /&gt;Alternatively, you could also test the effects of this on your current platform by increasing the time between samples to match or exceed the required charging time of your capacitors.&lt;/p&gt;
[quote user="macklenc0"]I think I added the relevant configs to the original post, did I miss anything there? We are doing some fancy stuff by sampling 6 of the ADC channels in single-ended mode, but two of the pins are reserved for differential measurement.[/quote]
&lt;p&gt;The config you showed there covers the main parameters, but it would be good to see the entire section where you setup and configure the SAADC.&lt;br /&gt;I suppose this can wait until the capacitor-size tests have concluded, if you are reluctant to share code.&lt;/p&gt;
[quote user="macklenc0"]I&amp;#39;ll report back with the findings from the new ADC reference as soon as I can. Thanks again![/quote]
&lt;p&gt;Great, I look forward to hearing how the tests went! :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SAADC inaccurate measurement</title><link>https://devzone.nordicsemi.com/thread/296138?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 05:11:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b36344ee-1e73-474f-b1f5-7b5f9d58fad2</guid><dc:creator>macklenc</dc:creator><description>&lt;p&gt;Hey Karl, sorry about the slow reply, I&amp;#39;ve been trying to get as much data collected as possible.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement/294623#294623"]How often do you intend to sample - are you not sampling every second?[/quote]
&lt;p&gt;I am sampling about once a second, but the nRF shouldn&amp;#39;t be able to drain an entire 1uF after it&amp;#39;s charged, right? But I will give installing new capacitors a try, unfortunately it&amp;#39;s not easy to modify the current platform so it&amp;#39;ll be one of the last things I try just in case I have to go back.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement/294623#294623"]Could you also share with me the SAADC and channel configuration you are using?[/quote]
&lt;p&gt;I think I added the relevant configs to the original post, did I miss anything there? We are doing some fancy stuff by sampling 6 of the ADC channels in single-ended mode, but two of the pins are reserved for differential measurement.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement/294623#294623"]If you externally ensure that the supplied VDD is constant, then I suppose this will not be an issue for you.[/quote]
&lt;p&gt;I think you may be on to something there, I double checked the Vpp noise on the 3.3V rail, and it does oscillate by about 10mVpp due to the buck converter. I&amp;#39;ve tasked our resident engineer with testing the accuracy when measuring with the 0.6V reference.&lt;/p&gt;
&lt;p&gt;As a side note, I did try to measure the differential voltage with an oscilloscope at the ADC pins, but the impedance was so high all I was able to read was an AC 60Hz signal, probably coming from mains in the building. Though that AC signal vanishes when I read one pin relative to ground, so I&amp;#39;m not 100% sure that the signal I&amp;#39;m seeing doesn&amp;#39;t exist on the board.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll report back with the findings from the new ADC reference as soon as I can. Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SAADC inaccurate measurement</title><link>https://devzone.nordicsemi.com/thread/294623?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 12:47:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43e40534-7a55-4c3e-9b0f-f0628084a276</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="macklenc0"]Thanks for the fast reply![/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="macklenc0"]I oversized the caps in an attempt to make the final BOM a touch cheaper, and figured the increase in size wouldn&amp;#39;t hurt. I didn&amp;#39;t really do any calculations beyond the tutorial you referenced figuring that was a lower bound on what was required.[/quote]
&lt;p&gt;Ah, I see. I must recommend that you always do these calculations prior to building a circuit, so that you have full control over what to expect when the circuit is live.&lt;br /&gt;As you can see from the tutorial, the calculated capacitor value they arrive at is 10 nF - which is 100 times smaller than the 1 µF you currently are using.&lt;/p&gt;
[quote user="macklenc0"]and approximating a fully charged capacitor to be at 5 time constants would give me 5*R*C=3.1 seconds.[/quote]
&lt;p&gt;How often do you intend to sample - are you not sampling every second?&lt;/p&gt;
[quote user="macklenc0"]I&amp;#39;ll go through the calculations you pointed out again and see what I get, do you think having a smaller capacitor would help? [/quote]
&lt;p&gt;Yes, a smaller capacitor will charge faster - it needs to be small enough to have reached the steady-state voltage level in time for your sampling, for your measurements to be accurate.&lt;/p&gt;
[quote user="macklenc0"]Sure! As an example reading, from my Fluke 87 I&amp;#39;m seeing 195mV, and the microcontroller is reporting 216mV after applying the following math: (raw_value * 3.3)/(2^14) * 2.6. Where the extra 2.6 is from the voltage divider. The actual code is as follows (fixed point,&amp;nbsp;three decimal places, trying to avoid floating point ops for performance):[/quote]
&lt;p&gt;Thank you for clarifying!&lt;br /&gt;Could you also share with me the SAADC and channel configuration you are using?&lt;br /&gt;You will need to expect &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/8830/nrf52-adc-enob"&gt;some LSB of noise in your measurements&lt;/a&gt;, so what you describe here could in part be a result of your chosen input range.&lt;/p&gt;
[quote user="macklenc0"]Makes sense, do you know how this would/could affect the range and/or accuracy? Though I think in my setup it doesn&amp;#39;t matter as much since the battery voltage goes through a buck converter before being consumed by the nRF chip.[/quote]
&lt;p&gt;If you externally ensure that the supplied VDD is constant, then I suppose this will not be an issue for you.&lt;br /&gt;However, in the case that VDD is declining with the voltage level of the battery, then your measurements over time will get skewed since the measurements rely on a non-constant reference.&lt;br /&gt;The degree of skewing will depend on the VDD range of your supply.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SAADC inaccurate measurement</title><link>https://devzone.nordicsemi.com/thread/294510?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 03:51:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d96c9aaa-5531-4216-9b84-8a81a4cdc179</guid><dc:creator>macklenc</dc:creator><description>&lt;p&gt;Thanks for the fast reply!&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement/294428#294428"]Thank you for including a rough schematic [/quote]
&lt;p&gt;No problem, I try to give as much info as I can.&lt;/p&gt;
&lt;p&gt;I did see that tutorial, it was very helpful in understanding the SAADC a little better and was actually the reason I added capacitors in the first place. I oversized the caps in an attempt to make the final BOM a touch cheaper, and figured the increase in size wouldn&amp;#39;t hurt. I didn&amp;#39;t really do any calculations beyond the tutorial you referenced figuring that was a lower bound on what was required.&lt;/p&gt;
&lt;p&gt;I just wen&amp;#39;t through some probably over-simplified math, my understanding is that the Thevinin resistance would be&amp;nbsp;620k, and approximating a fully charged capacitor to be at 5 time constants would give me 5*R*C=3.1 seconds.&amp;nbsp;I&amp;#39;ll go through the calculations you pointed out again and see what I get, do you think having a smaller capacitor would help? The battery is always plugged in, so I shouldn&amp;#39;t have to worry about the charge up time in theory.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement/294428#294428"]For future debugging it would also be helpful if you could include some of the SAADC outputs you are seeing, compared to the value you are measuring with your DMM.[/quote]
&lt;p&gt;Sure! As an example reading, from my Fluke 87 I&amp;#39;m seeing 195mV, and the microcontroller is reporting 216mV after applying the following math: (raw_value * 3.3)/(2^14) * 2.6. Where the extra 2.6 is from the voltage divider. The actual code is as follows (fixed point,&amp;nbsp;three decimal places, trying to avoid floating point ops for performance):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;26 * (raw_data * 330) / (1 &amp;lt;&amp;lt; 14);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here are several sample readings:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;table height="205" width="385"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DMM&lt;/td&gt;
&lt;td&gt;Characteristic Value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;195&lt;/td&gt;
&lt;td&gt;215.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;106&lt;/td&gt;
&lt;td&gt;119.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;93&lt;/td&gt;
&lt;td&gt;106.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;91&lt;/td&gt;
&lt;td&gt;93.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;78&lt;/td&gt;
&lt;td&gt;67.6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;69&lt;/td&gt;
&lt;td&gt;59.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;56&lt;/td&gt;
&lt;td&gt;46.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;47&lt;/td&gt;
&lt;td&gt;39&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;39&lt;/td&gt;
&lt;td&gt;18.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Here&amp;#39;s a plot of the values, the x-axis is averaged between the DMM and nRF readings to make the plot appear more linear:&lt;/p&gt;
&lt;p&gt;&lt;img height="306" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1613447444253v1.png" width="429" alt=" " /&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/71618/nrf52832-saadc-inaccurate-measurement/294428#294428"]On a general note I would also recommend using the internal 600 mV reference when measuring VDD voltage, since the results using VDD4 when measuring VDD will skew over time(as the battery discharges).[/quote]
&lt;p&gt;Makes sense, do you know how this would/could affect the range and/or accuracy? Though I think in my setup it doesn&amp;#39;t matter as much since the battery voltage goes through a buck converter before being consumed by the nRF chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SAADC inaccurate measurement</title><link>https://devzone.nordicsemi.com/thread/294428?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 15:01:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af333a26-1982-43a4-8994-dd8119d9a9cf</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]Please reference the rough schematic below for details.[/quote]
&lt;p&gt;Thank you for including a rough schematic - this is very helpful in order to quickly familiarize with the issue.&lt;br /&gt;My immediate thought when seeing this schematic is that your capacitors C1 and C2 are enormous for the task.&lt;br /&gt;I have not done any calculations on this yet, but I suspect that it takes a very long time to get the correct voltage levels here with such big capacitors.&amp;nbsp;&lt;br /&gt;If you have not seen it already, I highly recommend reading through this blog post detailing &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/measuring-lithium-battery-voltage-with-nrf52"&gt;how to measure the voltage of a lithium ion battery&lt;/a&gt;. In the blogpost, the circuit design and calculations are demonstrated.&lt;br /&gt;&lt;br /&gt;Could you go through the blogpost I referenced above, and recheck your capacitor value-calculations, and then try again with the new capacitor values if the results diverge from your previous calculations?&lt;br /&gt;You could also share your previous capacitor value calculation, and I&amp;#39;ll take a look.&lt;br /&gt;&lt;br /&gt;For future debugging it would also be helpful if you could include some of the SAADC outputs you are seeing, compared to the value you are measuring with your DMM.&lt;br /&gt;&lt;br /&gt;On a general note I would also recommend using the internal 600 mV reference when measuring VDD voltage, since the results using VDD4 when measuring VDD will skew over time(as the battery discharges).&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>