<?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>Prescaling on ADC battery voltage measurement</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/1754/prescaling-on-adc-battery-voltage-measurement</link><description>I&amp;#39;m trying to measure a scaled down battery voltage level on an ADC pin. Given my resistor values the voltage on the pin should be about 0.279 times VBATT, to fit within 1.2V. It&amp;#39;s a lithium ion battery that shouldn&amp;#39;t go over about 4.1V or 4.2V. 
 Here</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Feb 2014 16:39:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/1754/prescaling-on-adc-battery-voltage-measurement" /><item><title>RE: Prescaling on ADC battery voltage measurement</title><link>https://devzone.nordicsemi.com/thread/7678?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2014 16:39:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70caea09-c004-4f21-80b6-91567c610529</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Bingo! Thanks very much.&lt;/p&gt;
&lt;p&gt;I do indeed have a cap in there btw, just neglected to mention it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prescaling on ADC battery voltage measurement</title><link>https://devzone.nordicsemi.com/thread/7677?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2014 16:23:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf1284d9-05e6-4eb4-b09e-936c58236641</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Eliot,&lt;/p&gt;
&lt;p&gt;You setup the ADC to be 8 bit, meaning that a value of 255 = 1.2V, although you&amp;#39;re treating the ADC result as it&amp;#39;s a 10 bit number.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re getting 234 from the RESULT register, then this would be 234/255*1.2V = 1,1V on the ADC pin.
Note: if you&amp;#39;re using resistors in the Mohm-area, it&amp;#39;s recommended to use a capacitor as well (due to ADC input impedance during conversion)&lt;/p&gt;
&lt;p&gt;Best regards
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prescaling on ADC battery voltage measurement</title><link>https://devzone.nordicsemi.com/thread/7676?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2014 16:09:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:831f4b12-6282-432a-98a9-e9dd9fdf96b2</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Here are my constants:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BATTERY_ADC_FACTOR (0.279f)
#define BATTERY_REFERENCE_VOLTAGE (1.2f)
#define BATTERY_ADC_MAX (1024)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And here&amp;#39;s my arithmetic, with the values I&amp;#39;m seeing:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	// This gets us a fractional number from 0 to 1, a proportion of the maximum.
	float adc_result_proportion = ((float)NRF_ADC-&amp;gt;RESULT/(float)BATTERY_ADC_MAX);
	// eg. 234 / 1024 = 0.229

	// This gets us the actual voltage on the ADC pin.
	float pin_voltage = adc_result_proportion * BATTERY_REFERENCE_VOLTAGE;
	// eg. 0.229 * 1.2V = 0.274V &amp;lt;-- Too low considering I measure 4.2V across the battery directly.

	// This gets us the corresponding voltage across the battery terminals.
	m_battery_voltage = pin_voltage / BATTERY_ADC_FACTOR;
	// eg. 0.274V / 0.279 = 0.983
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let me know if you need my resistor values, but they&amp;#39;re not too far off those posted in the other thread. Same orders of magnitude, anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prescaling on ADC battery voltage measurement</title><link>https://devzone.nordicsemi.com/thread/7675?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2014 16:05:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85704619-4c98-44bc-92da-802d4632f222</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Oh, I see. I don&amp;#39;t understand why I&amp;#39;m seeing the NRF_ADC-&amp;gt;RESULT value I am in that case. Will post more detail below.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prescaling on ADC battery voltage measurement</title><link>https://devzone.nordicsemi.com/thread/7674?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2014 15:47:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7eecb7e7-983f-4436-9883-90d2c78ff2a0</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Eliot,&lt;/p&gt;
&lt;p&gt;He&amp;#39;s using a factor of 4 due to the external resistors (1M and 250K).
Could you elaborate on the error in your measurement?&lt;/p&gt;
&lt;p&gt;Note that the ADC input resistance will change while sampling! (you&amp;#39;ll see the numbers in the thread you linked to.)&lt;/p&gt;
&lt;p&gt;BR
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>