<?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>Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16152/unable-to-get-adc-results-using-accelerometer</link><description>hi,
i am working on ble_app_uart_simple_adc example which is referred from the link github.com/.../nrf51-ADC-examples 
i flashed the code successfully. and detecting the device using NRFTool box application. during the circuit setup i connected accelerometer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Apr 2017 16:13:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16152/unable-to-get-adc-results-using-accelerometer" /><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61624?ContentTypeID=1</link><pubDate>Wed, 12 Apr 2017 16:13:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a157e181-8215-496f-96f4-3a0122f4eef0</guid><dc:creator>Kevin</dc:creator><description>&lt;p&gt;Thank you, Stefan. This is the only example I&amp;#39;ve found for modifying the ADC config with the softdevice from the default setting. Works perfectly :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61633?ContentTypeID=1</link><pubDate>Tue, 06 Sep 2016 14:01:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e742399a-0268-427d-a270-d4dd701970ef</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;If you have configured the ADC to sample on P0.01, and the ADC output values rises, that is because the voltage on P0.01 is rising. Then the accelerometer is not outputting the sensor reading properly. Try to connect e.g. multimeter to the accelerometer to see if the output makes sense.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61632?ContentTypeID=1</link><pubDate>Tue, 06 Sep 2016 13:57:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56c63d91-5089-4440-b2a9-5c4714e9ac50</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;You must implement the transfer function yourself from ADC output value to meaningful g value. For example, if the specification for the accelerometer says that 2.0V output is positive 10g acceleration, 1.0V is no acceleration and 0V is negative 10g acceleration, and the relationship between acceleration and accelerometer voltage output is linear, then you can &lt;a href="http://www.mathplanet.com/education/algebra-1/formulating-linear-equations/writing-linear-equations-using-the-slope-intercept-form"&gt;with algebra find the transfer function&lt;/a&gt; where you have ADC output value on one axis and g value on the other.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61623?ContentTypeID=1</link><pubDate>Tue, 06 Sep 2016 13:38:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a8a0d6d-c9da-4e63-a65d-4fee94e4c390</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;The accelerometer should output a different voltage I assume depending on its acceleration. You need to realize what voltage range the accelerometer outputs and adjust the voltage range of the ADC output accordingly. In the ble_app_uart_adc_simple the ADC channel that samples on pin P0.01 is set up with default configuration which is without prescaling, which results in ADC voltage input range of 0V - 1.2V. Sorry for assuming before that the range was 0V - 3.6V, my bad. To configure the range to 0V - 3.6V you need to explicitly set the prescaler to 1/3 as in the following code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void adc_config(void)
{
	ret_code_t ret_code;
	nrf_drv_adc_config_t config = NRF_DRV_ADC_DEFAULT_CONFIG;

	ret_code = nrf_drv_adc_init(&amp;amp;config, adc_event_handler);
	APP_ERROR_CHECK(ret_code);
	
	m_channel_config.config.config.input = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD;

	nrf_drv_adc_channel_enable(&amp;amp;m_channel_config);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61626?ContentTypeID=1</link><pubDate>Tue, 06 Sep 2016 11:35:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fd023a1-5b35-49bc-bef8-f58cecbfe32f</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;Thanks for the reply Stefan, I understand what you conveyed there.
I have used example at &lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples"&gt;github.com/.../nrf51-ADC-examples&lt;/a&gt; and
getting 1023 decimal value if analog pin p0.01 is connected to VDD and 511 if I left it open in air.
I am using ADXL335 that has 3.3v connected to its VCC.&lt;/p&gt;
&lt;p&gt;When I connect accelerometer xout to the p0.01 decimal value sent to uart and nrfconnect app keeps on increasing (for e.g. 241 to 468) even I have accelerometer idle. Can you tell me, where could I have possibly gone wrong and what is the ADC configuration I should be using ?&lt;/p&gt;
&lt;p&gt;If you can also let me know what should be my interfacing setup it would be of a great help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61631?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 16:02:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25b448a6-2c25-478b-89d4-e3da17e8c457</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Good, now we are making progress.   The value 00-02-00-02-00-02-00-02 are 4 hex values all with values 0x0002. This value should be ideally 0x0000, but apparently there is 2 LSB offset error. This might improve if you run the ADC offset calibration task. Anyway, close enough.&lt;/p&gt;
&lt;p&gt;If you change the adc buffer size to 1, i.e. set ADC_BUFFER_SIZE to 1, then you would only get one 0x0002 value instead of four.  The value 0x01ff when you leave the pin open is equal to decimal 511.&lt;/p&gt;
&lt;p&gt;The ADC output range with 10 bit configuration as in this example is 0-1023, which corresponds to the input range of 0V-3.6V.  So if you get e.g. ADC output code of 600 = 0x0258 that corresponds to 3.6V*600/1023=2.11V input voltage on the P0.01 ADC input pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61630?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 12:44:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1952aef6-448f-415c-98d8-732e1b0728b4</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;hi, if i use nrf connect application getting information like this
&amp;quot;???(*&amp;quot; recieved
value:(0x)00-02-00-02-00-02-00-02 (if i connect ground to p0.01)
where as i left p0.01 openthis value is like this value: (0x)01-ff-01-ff-01-ff-01-ff
if i am connected accelerometer analog input to the p0.01 values are changing. but how i can measure this alues in to voltages.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61629?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 11:57:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b549d827-453b-4a93-8fc3-5bee3cd342fa</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Yeah, the nRFtoolbox displays the characters in a strange way. Try to use the nRF Connect app instead in order to see the real ADC output in hexadecimal format. You can not see the real values on nRFToolbox UART app.&lt;/p&gt;
&lt;p&gt;What the code is doing in the adc_event_handler is to split every 10-bit ADC output value into two 8-bit values before sending it over BLE. Since the ADC buffer size is 4, the adc_event_handler is called every 4 samples. This will result in 4 samples to be sent every time over BLE, i.e. 8 bytes. You can see the values of those 8 bytes if you connect with nRF Connect app.  You can also see the ADC output values if you connect to the UART output as described in the &lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples/tree/master/ble_app_uart_adc_simple"&gt;documentation for the example&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When you disconnect the accelerometer from the ADC input pin the input pin will be floating, so the input voltage to the ADC input pin P0.01 can be whatever, and you will see whatever value on the ADC output. To test, you can try to get zero ADC output by shorting P0.01 to GND or get a positive ADC output by shorting P0.01 to VDD on the nRF51-DK board.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61628?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 11:44:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07f33ab4-f62b-4ef2-a4e8-0869c36638f3</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;even i am disconnected accelerometer at p0.01. it is displaying symbols like this only &amp;quot;????&amp;quot;,&amp;quot;))-(&amp;quot;
this is the existing adc_event_handler function
static void adc_event_handler(nrf_drv_adc_evt_t const * p_event)
{
uint8_t adc_result[ADC_BUFFER_SIZE*2];&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (p_event-&amp;gt;type == NRF_DRV_ADC_EVT_DONE)
{
    adc_event_counter++;
    printf(&amp;quot;    ADC event counter: %d\r\n&amp;quot;, adc_event_counter);			
    uint32_t i;
    for (i = 0; i &amp;lt; p_event-&amp;gt;data.done.size; i++)
    {
        printf(&amp;quot;Sample value %d: %d\r\n&amp;quot;, i+1, p_event-&amp;gt;data.done.p_buffer[i]);   //Print ADC result on hardware UART
        adc_result[(i*2)] = p_event-&amp;gt;data.done.p_buffer[i] &amp;gt;&amp;gt; 8;
        adc_result[(i*2)+1] = p_event-&amp;gt;data.done.p_buffer[i];					
    }
    if(ADC_BUFFER_SIZE &amp;lt;= 10)
    {
        ble_nus_string_send(&amp;amp;m_nus, &amp;amp;adc_result[0], ADC_BUFFER_SIZE*2);           //Send ADC result over BLE via NUS service
    }		
    LEDS_INVERT(BSP_LED_3_MASK);				                                          //Indicate sampling complete on LED 4
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}
how i can display exact adc valuse in nrftool box application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61627?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 11:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d9860f2-c949-4ecc-9b3b-2cbc64bd853c</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;i replaced adc_event_handler function with your function it is displaying cafe continuously. where as with existing ble_app_uart_simple_adc examples adc_event_handler function it is first displaying alphabets and after symbols like this &amp;quot;?????&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to get ADC results using accelerometer</title><link>https://devzone.nordicsemi.com/thread/61625?ContentTypeID=1</link><pubDate>Fri, 02 Sep 2016 10:52:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:add72fe2-8bfd-48c0-965b-9991206d106f</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The nRFtoolbox UART app is probably receiving the correct ADC values, but it displays the values as &lt;a href="http://www.theasciicode.com.ar/"&gt;ascii characters&lt;/a&gt;. If you would instead send readable ascii characters, then the nrftoolbox UART app would be able to display it correctly. E.g. if you would write the adc_event_handler as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void adc_event_handler(nrf_drv_adc_evt_t const * p_event)
{
	uint8_t adc_result_temp[] = {&amp;#39;c&amp;#39;,&amp;#39;a&amp;#39;,&amp;#39;f&amp;#39;,&amp;#39;e&amp;#39;};
	
	if (p_event-&amp;gt;type == NRF_DRV_ADC_EVT_DONE)
	{
		ble_nus_string_send(&amp;amp;m_nus, &amp;amp;adc_result_temp[0], 4);
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it would write &amp;quot;cafe&amp;quot; in nRFtoolbox. If you want to see the real ADC values however, it is better to connect with nRF Connect app, then you see the raw hexadecimal values instead of ascii characters.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>