Use of analog signal input PD5/PD6
Antwort
13.10.15 06:04
Dear all

is there any documentation or information available about the use of the ADC inputs on pins PD5/PD6 of the extension board?

Thanks a lot
Jochen
0 (0 Stimmen)
Use of analog signal input PD5/PD6
Antwort
15.10.15 07:42 als Antwort auf Jochen Traub.
Dear Jochen,

copy & paste the following code in the app template should get the ADC input working (poll value (U = 0...2.5 V) and print over serial port).

--------------------------------------------------------------------
/* system header files */
#include <stdio.h>
#include <stdint.h>

/* additional interface header files */
#include "OS_operatingSystem_ih.h"
#include "FreeRTOS.h"
#include "timers.h"
#include "ADC_ih.h"                 /* added for ADC */

OS_taskHandle_tp Application_gdt;

#define ONESECONDDELAY         UINT32_C(1000)         /* one second */
#define TIMERBLOCKTIME        UINT32_C(0xffff)    /* blocktime of a timer */

#define ADC_INITSINGLE_OWN                                                           \
  { adcPRSSELCh0,              /* PRS ch0 (if enabled). */                          \
    adcAcqTime1,               /* 1 ADC_CLK cycle acquisition time. */              \
    adcRef2V5,                 /* 2.5V internal reference. */                       \
    adcRes12Bit,               /* 12 bit resolution. */                             \
    adcSingleInpCh0,           /* CH0 input selected. */                            \
    false,                     /* Single ended input. */                            \
    false,                     /* PRS disabled. */                                  \
    false,                     /* Right adjust. */                                  \
    false                      /* Deactivate conversion after one scan sequence. */ \
  }

ADC_singleAcq_t ADC_acquire_one = {ADC0,ADC_INITSINGLE_OWN,adcSingleInpCh6,0UL};        /*choose input channel 5 or 6*/
ADC_singleAcq_tp ADC_acquire_one_p = &ADC_acquire_one;

void Read_ADC(OS_timerHandle_tp pxTimer)
{
    (void) (pxTimer);
    uint32_t ADC_read_value;
    ADC_pollSingleData(ADC_acquire_one_p);
    ADC_read_value = ADC_scaleAdcValue(ADC_acquire_one_p);
    printf("PD5 = %ld mV\n\r", (long int) ADC_read_value);
}

void Application_init(void)
{
    /*Task for reading the ADC*/
    OS_timerHandle_tp timer_read_adc;
    timer_read_adc = OS_timerCreate(
            (const int8_t *) "Reading ADC", ONESECONDDELAY,OS_AUTORELOAD_ON, NULL, Read_ADC);
    OS_timerStart(timer_read_adc, TIMERBLOCKTIME);
}

void SSU_initSystem(OS_timerHandle_tp xTimer)
{
    (void) (xTimer);

    /*ADC initalization*/
    ADC_node_t ADC_node_one = {ADC0,cmuClock_ADC0,32000,ADC_INIT_DEFAULT};
    ADC_node_tp ADC_node_one_p = &ADC_node_one;
    ADC_init(ADC_node_one_p);

    Application_init();
}
----------------------------------------------------------------------

Sorry, but I didn't see any better possibility for posting the code.
Please let me know if it works or if I missed something.
Andreas

--
Update 15/10/15:
Code edited, so that there are no changes in ADC_cc.c and ADC_ih.h necessary, i.e. 'ADC_pollSingleData' stays 'void'.
Andreas
 
0 (0 Stimmen)
Use of analog signal input PD5/PD6
Antwort
15.10.15 09:09 als Antwort auf Andreas F..
 
Hi Andreas,

I executed your code which you modified today. I got the following output
 INFO | XDK DEVICE 1: PD5 = 2193 mV
 INFO | XDK DEVICE 1: PD5 = 2304 mV
 INFO | XDK DEVICE 1: PD5 = 2314 mV
 INFO | XDK DEVICE 1: PD5 = 2315 mV
 INFO | XDK DEVICE 1: PD5 = 2316 mV
 INFO | XDK DEVICE 1: PD5 = 2315 mV
 INFO | XDK DEVICE 1: PD5 = 2317 mV
 INFO | XDK DEVICE 1: PD5 = 2315 mV
 INFO | XDK DEVICE 1: PD5 = 2312 mV

But I did not connected any input to PD5 or 6. When I flash your code, it start displaying the above output. I need to connect the sensor on PD5 or PD6. Is there any solution.

Regards,
Sarathkumar.
0 (0 Stimmen)
Use of analog signal input PD5/PD6
Antwort
15.10.15 11:18 als Antwort auf Sarathkumar karunakaran.
Hi Sarathkumar,

for testing the code, I connected a potentiometer through the extension board so that I can change the input on the pins between 0 mV and 2500 mV.
Please test  your code again with an appropriate analog input on the pins (PD5 / PD6) and also keep in mind the labelling error on the "XDK Gateway" Version V1.0, described in the getting started documentation: https://xdk.bosch-connectivity.com/webdav/bcdscommunitygb/document_library/XDK_Downloads/Documentation/XDK_Getting_Started_v2.pdf

Regards,
Andreas
 
0 (0 Stimmen)
Use of analog signal input PD5/PD6
Antwort
15.10.15 21:47 als Antwort auf Andreas F..
Hi Andreas,

I just tested your sample and used a generator to produce 1.9V and successfully read the correct voltage on PD5/PD6.

My results are here:

 INFO | XDK DEVICE 1: PD5 = 1907 mV
 INFO | XDK DEVICE 1: PD5 = 1903 mV
 INFO | XDK DEVICE 1: PD5 = 1906 mV
 INFO | XDK DEVICE 1: PD5 = 1908 mV
 INFO | XDK DEVICE 1: PD5 = 1906 mV
 INFO | XDK DEVICE 1: PD5 = 1895 mV
 INFO | XDK DEVICE 1: PD5 = 1901 mV


Thanks for sharing this code snippet.

- Florian
0 (0 Stimmen)
Use of analog signal input PD5/PD6
Antwort
16.10.15 08:40 als Antwort auf Florian Harr.
Hi Florian,

thanks for the confirmation.

I remember a bug, which I stumbled over when writing the above code. I think it was one of the "... _SAMPLING_MAX_VAL" in "ADC_cc.c" defined wrong (4096 instead of 4095 or something like this). I just fixed it in my code, so I can't find it anymore. Could someone check it? Thanks.

Andreas
 
0 (0 Stimmen)